debuggers.hg

changeset 20685:5ea096ef7603

HVM vcpu add/remove: parse 'vcpu_avail' to firmware and set up madt
accordingly

-- currently firmware has got 'vcpus' from xend, this patch add parse
'vcpu_avail' to firmware;
-- setup madt 'lapic' subitems of processors accoring to vcpus and
vcpu_avail which finally come from config;

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Dec 14 09:25:47 2009 +0000 (2009-12-14)
parents eaea340b371d
children 22a28ffb6034
files tools/firmware/hvmloader/acpi/build.c tools/firmware/hvmloader/config.h tools/firmware/hvmloader/util.h tools/python/xen/lowlevel/xc/xc.c tools/python/xen/xend/image.py xen/include/public/hvm/hvm_info_table.h
line diff
     1.1 --- a/tools/firmware/hvmloader/acpi/build.c	Mon Dec 14 09:14:26 2009 +0000
     1.2 +++ b/tools/firmware/hvmloader/acpi/build.c	Mon Dec 14 09:25:47 2009 +0000
     1.3 @@ -115,7 +115,7 @@ static int construct_madt(struct acpi_20
     1.4  
     1.5      lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
     1.6      madt_lapic0_addr = (uint32_t)lapic;
     1.7 -    for ( i = 0; i < MAX_VCPUS; i++ )
     1.8 +    for ( i = 0; i < HVM_MAX_VCPUS; i++ )
     1.9      {
    1.10          memset(lapic, 0, sizeof(*lapic));
    1.11          lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
    1.12 @@ -123,7 +123,9 @@ static int construct_madt(struct acpi_20
    1.13          /* Processor ID must match processor-object IDs in the DSDT. */
    1.14          lapic->acpi_processor_id = i;
    1.15          lapic->apic_id = LAPIC_ID(i);
    1.16 -        lapic->flags = (i < hvm_info->nr_vcpus) ? ACPI_LOCAL_APIC_ENABLED : 0;
    1.17 +        lapic->flags = ((i < hvm_info->nr_vcpus) &&
    1.18 +                        test_bit(i, hvm_info->vcpu_online)
    1.19 +                        ? ACPI_LOCAL_APIC_ENABLED : 0);
    1.20          offset += sizeof(*lapic);
    1.21          lapic++;
    1.22      }
     2.1 --- a/tools/firmware/hvmloader/config.h	Mon Dec 14 09:14:26 2009 +0000
     2.2 +++ b/tools/firmware/hvmloader/config.h	Mon Dec 14 09:25:47 2009 +0000
     2.3 @@ -50,9 +50,6 @@ extern unsigned long pci_mem_start, pci_
     2.4  #define XEN_PF_IOBASE   0x10
     2.5  #define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
     2.6  
     2.7 -/* Maximum we can support with current vLAPIC ID mapping. */
     2.8 -#define MAX_VCPUS 128
     2.9 -
    2.10  /* Located at BIOS_INFO_PHYSICAL_ADDRESS. */
    2.11  struct bios_info {
    2.12      uint8_t  com1_present:1;    /* 0[0] - System has COM1? */
     3.1 --- a/tools/firmware/hvmloader/util.h	Mon Dec 14 09:14:26 2009 +0000
     3.2 +++ b/tools/firmware/hvmloader/util.h	Mon Dec 14 09:25:47 2009 +0000
     3.3 @@ -30,6 +30,11 @@ void __bug(char *file, int line) __attri
     3.4  #define BUG_ON(p) do { if (p) BUG(); } while (0)
     3.5  #define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
     3.6  
     3.7 +static inline int test_bit(unsigned int b, void *p)
     3.8 +{
     3.9 +    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
    3.10 +}
    3.11 +
    3.12  /* MSR access */
    3.13  void wrmsr(uint32_t idx, uint64_t v);
    3.14  uint64_t rdmsr(uint32_t idx);
     4.1 --- a/tools/python/xen/lowlevel/xc/xc.c	Mon Dec 14 09:14:26 2009 +0000
     4.2 +++ b/tools/python/xen/lowlevel/xc/xc.c	Mon Dec 14 09:25:47 2009 +0000
     4.3 @@ -915,13 +915,14 @@ static PyObject *pyxc_hvm_build(XcObject
     4.4  #endif
     4.5      char *image;
     4.6      int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1;
     4.7 +    uint64_t vcpu_avail = 1;
     4.8  
     4.9      static char *kwd_list[] = { "domid",
    4.10 -                                "memsize", "image", "target", "vcpus", "acpi",
    4.11 -                                "apic", NULL };
    4.12 -    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_list,
    4.13 +                                "memsize", "image", "target", "vcpus", 
    4.14 +                                "vcpu_avail", "acpi", "apic", NULL };
    4.15 +    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iilii", kwd_list,
    4.16                                        &dom, &memsize, &image, &target, &vcpus,
    4.17 -                                      &acpi, &apic) )
    4.18 +                                      &vcpu_avail, &acpi, &apic) )
    4.19          return NULL;
    4.20  
    4.21      if ( target == -1 )
    4.22 @@ -942,6 +943,8 @@ static PyObject *pyxc_hvm_build(XcObject
    4.23      va_hvm->acpi_enabled = acpi;
    4.24      va_hvm->apic_mode    = apic;
    4.25      va_hvm->nr_vcpus     = vcpus;
    4.26 +    ((uint64_t *)va_hvm->vcpu_online)[0] = vcpu_avail;
    4.27 +    ((uint64_t *)va_hvm->vcpu_online)[1] = 0;    
    4.28      for ( i = 0, sum = 0; i < va_hvm->length; i++ )
    4.29          sum += ((uint8_t *)va_hvm)[i];
    4.30      va_hvm->checksum -= sum;
    4.31 @@ -1810,6 +1813,7 @@ static PyMethodDef pyxc_methods[] = {
    4.32        " dom     [int]:      Identifier of domain to build into.\n"
    4.33        " image   [str]:      Name of HVM loader image file.\n"
    4.34        " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
    4.35 +      " vcpu_avail [long, 1]: Which Virtual CPUS available.\n\n"
    4.36        "Returns: [int] 0 on success; -1 on error.\n" },
    4.37  
    4.38      { "hvm_get_param", 
     5.1 --- a/tools/python/xen/xend/image.py	Mon Dec 14 09:14:26 2009 +0000
     5.2 +++ b/tools/python/xen/xend/image.py	Mon Dec 14 09:25:47 2009 +0000
     5.3 @@ -938,6 +938,7 @@ class HVMImageHandler(ImageHandler):
     5.4          log.debug("memsize        = %d", memmax_mb)
     5.5          log.debug("target         = %d", mem_mb)
     5.6          log.debug("vcpus          = %d", self.vm.getVCpuCount())
     5.7 +        log.debug("vcpu_avail     = %li", self.vm.getVCpuAvail())
     5.8          log.debug("acpi           = %d", self.acpi)
     5.9          log.debug("apic           = %d", self.apic)
    5.10  
    5.11 @@ -946,6 +947,7 @@ class HVMImageHandler(ImageHandler):
    5.12                            memsize        = memmax_mb,
    5.13                            target         = mem_mb,
    5.14                            vcpus          = self.vm.getVCpuCount(),
    5.15 +                          vcpu_avail     = self.vm.getVCpuAvail(),
    5.16                            acpi           = self.acpi,
    5.17                            apic           = self.apic)
    5.18          rc['notes'] = { 'SUSPEND_CANCEL': 1 }
     6.1 --- a/xen/include/public/hvm/hvm_info_table.h	Mon Dec 14 09:14:26 2009 +0000
     6.2 +++ b/xen/include/public/hvm/hvm_info_table.h	Mon Dec 14 09:25:47 2009 +0000
     6.3 @@ -29,6 +29,9 @@
     6.4  #define HVM_INFO_OFFSET      0x800
     6.5  #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
     6.6  
     6.7 +/* Maximum we can support with current vLAPIC ID mapping. */
     6.8 +#define HVM_MAX_VCPUS        128
     6.9 +
    6.10  struct hvm_info_table {
    6.11      char        signature[8]; /* "HVM INFO" */
    6.12      uint32_t    length;
    6.13 @@ -64,6 +67,9 @@ struct hvm_info_table {
    6.14       *    RAM above 4GB
    6.15       */
    6.16      uint32_t    high_mem_pgend;
    6.17 +
    6.18 +    /* Bitmap of which CPUs are online at boot time. */
    6.19 +    uint8_t     vcpu_online[HVM_MAX_VCPUS/8];
    6.20  };
    6.21  
    6.22  #endif /* __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__ */