All of lore.kernel.org
 help / color / mirror / Atom feed
* HVM vcpu add/remove: parse 'vcpu_avail' to firmware logic and set up madt
@ 2009-12-09  9:31 Liu, Jinsong
  0 siblings, 0 replies; only message in thread
From: Liu, Jinsong @ 2009-12-09  9:31 UTC (permalink / raw)
  To: xen-devel; +Cc: Keir Fraser

[-- Attachment #1: Type: text/plain, Size: 295 bytes --]

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

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

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>

[-- Attachment #2: ras_xen_hvminfo_3.patch --]
[-- Type: application/octet-stream, Size: 4981 bytes --]

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

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

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>

diff -r 2ecdf6b11612 tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c	Tue Dec 08 16:49:01 2009 +0800
+++ b/tools/firmware/hvmloader/acpi/build.c	Tue Dec 08 20:25:52 2009 +0800
@@ -24,6 +24,8 @@
 
 #define align16(sz)        (((sz) + 15) & ~15)
 #define fixed_strcpy(d, s) strncpy((d), (s), sizeof(d))
+
+#define MAX_HVM_VCPUS 128
 
 extern struct acpi_20_rsdp Rsdp;
 extern struct acpi_20_rsdt Rsdt;
@@ -76,7 +78,7 @@ static int construct_madt(struct acpi_20
     /* seup local APIC sub-entries */
     lapic = (struct acpi_20_madt_lapic *)(madt + 1);
     *(uint32_t *)APIC_MADT_PTR = (uint32_t)lapic;
-    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
+    for ( i = 0; i < MAX_HVM_VCPUS; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
         lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
@@ -84,7 +86,11 @@ static int construct_madt(struct acpi_20
         /* Processor ID must match processor-object IDs in the DSDT. */
         lapic->acpi_processor_id = i;
         lapic->apic_id = LAPIC_ID(i);
-        lapic->flags   = ACPI_LOCAL_APIC_ENABLED;
+        if ( (i < hvm_info->nr_vcpus) &&
+            ((1 << i) & hvm_info->vcpu_avail) )
+            lapic->flags   = ACPI_LOCAL_APIC_ENABLED;
+        else
+            lapic->flags   = 0;
         offset += sizeof(*lapic);
         lapic++;
     }
diff -r 2ecdf6b11612 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c	Tue Dec 08 16:49:01 2009 +0800
+++ b/tools/python/xen/lowlevel/xc/xc.c	Tue Dec 08 20:25:52 2009 +0800
@@ -915,13 +915,14 @@ static PyObject *pyxc_hvm_build(XcObject
 #endif
     char *image;
     int memsize, target=-1, vcpus = 1, acpi = 0, apic = 1;
+    uint64_t vcpu_avail = 1;
 
     static char *kwd_list[] = { "domid",
-                                "memsize", "image", "target", "vcpus", "acpi",
-                                "apic", NULL };
-    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iiii", kwd_list,
+                                "memsize", "image", "target", "vcpus", 
+                                "vcpu_avail", "acpi", "apic", NULL };
+    if ( !PyArg_ParseTupleAndKeywords(args, kwds, "iis|iilii", kwd_list,
                                       &dom, &memsize, &image, &target, &vcpus,
-                                      &acpi, &apic) )
+                                      &vcpu_avail, &acpi, &apic) )
         return NULL;
 
     if ( target == -1 )
@@ -942,6 +943,7 @@ static PyObject *pyxc_hvm_build(XcObject
     va_hvm->acpi_enabled = acpi;
     va_hvm->apic_mode    = apic;
     va_hvm->nr_vcpus     = vcpus;
+    va_hvm->vcpu_avail   = vcpu_avail;
     for ( i = 0, sum = 0; i < va_hvm->length; i++ )
         sum += ((uint8_t *)va_hvm)[i];
     va_hvm->checksum -= sum;
@@ -1810,6 +1812,7 @@ static PyMethodDef pyxc_methods[] = {
       " dom     [int]:      Identifier of domain to build into.\n"
       " image   [str]:      Name of HVM loader image file.\n"
       " vcpus   [int, 1]:   Number of Virtual CPUS in domain.\n\n"
+      " vcpu_avail [long, 1]: Which Virtual CPUS available.\n\n"
       "Returns: [int] 0 on success; -1 on error.\n" },
 
     { "hvm_get_param", 
diff -r 2ecdf6b11612 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py	Tue Dec 08 16:49:01 2009 +0800
+++ b/tools/python/xen/xend/image.py	Tue Dec 08 20:25:52 2009 +0800
@@ -939,6 +939,7 @@ class HVMImageHandler(ImageHandler):
         log.debug("memsize        = %d", memmax_mb)
         log.debug("target         = %d", mem_mb)
         log.debug("vcpus          = %d", self.vm.getVCpuCount())
+        log.debug("vcpu_avail     = %li", self.vm.getVCpuAvail())
         log.debug("acpi           = %d", self.acpi)
         log.debug("apic           = %d", self.apic)
 
@@ -947,6 +948,7 @@ class HVMImageHandler(ImageHandler):
                           memsize        = memmax_mb,
                           target         = mem_mb,
                           vcpus          = self.vm.getVCpuCount(),
+                          vcpu_avail     = self.vm.getVCpuAvail(),
                           acpi           = self.acpi,
                           apic           = self.apic)
         rc['notes'] = { 'SUSPEND_CANCEL': 1 }
diff -r 2ecdf6b11612 xen/include/public/hvm/hvm_info_table.h
--- a/xen/include/public/hvm/hvm_info_table.h	Tue Dec 08 16:49:01 2009 +0800
+++ b/xen/include/public/hvm/hvm_info_table.h	Tue Dec 08 20:25:52 2009 +0800
@@ -64,6 +64,9 @@ struct hvm_info_table {
      *    RAM above 4GB
      */
     uint32_t    high_mem_pgend;
+
+    /* Which CPUs does this domain currently available? */
+    uint64_t    vcpu_avail;
 };
 
 #endif /* __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__ */

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-09  9:31 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-09  9:31 HVM vcpu add/remove: parse 'vcpu_avail' to firmware logic and set up madt Liu, Jinsong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.