WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] HVM vcpu add/remove: parse 'vcpu_avail' t

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] HVM vcpu add/remove: parse 'vcpu_avail' to firmware and set up madt
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Dec 2009 01:45:29 -0800
Delivery-date: Mon, 14 Dec 2009 01:46:40 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1260782747 0
# Node ID 5ea096ef7603da465562d7e4177225bc3a298723
# Parent  eaea340b371dbb2c7d5261c915143ce87d6c1270
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@xxxxxxxxx>
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
 tools/firmware/hvmloader/acpi/build.c   |    6 ++++--
 tools/firmware/hvmloader/config.h       |    3 ---
 tools/firmware/hvmloader/util.h         |    5 +++++
 tools/python/xen/lowlevel/xc/xc.c       |   12 ++++++++----
 tools/python/xen/xend/image.py          |    2 ++
 xen/include/public/hvm/hvm_info_table.h |    6 ++++++
 6 files changed, 25 insertions(+), 9 deletions(-)

diff -r eaea340b371d -r 5ea096ef7603 tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Mon Dec 14 09:14:26 2009 +0000
+++ b/tools/firmware/hvmloader/acpi/build.c     Mon Dec 14 09:25:47 2009 +0000
@@ -115,7 +115,7 @@ static int construct_madt(struct acpi_20
 
     lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
     madt_lapic0_addr = (uint32_t)lapic;
-    for ( i = 0; i < MAX_VCPUS; i++ )
+    for ( i = 0; i < HVM_MAX_VCPUS; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
         lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
@@ -123,7 +123,9 @@ 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 = (i < hvm_info->nr_vcpus) ? ACPI_LOCAL_APIC_ENABLED : 0;
+        lapic->flags = ((i < hvm_info->nr_vcpus) &&
+                        test_bit(i, hvm_info->vcpu_online)
+                        ? ACPI_LOCAL_APIC_ENABLED : 0);
         offset += sizeof(*lapic);
         lapic++;
     }
diff -r eaea340b371d -r 5ea096ef7603 tools/firmware/hvmloader/config.h
--- a/tools/firmware/hvmloader/config.h Mon Dec 14 09:14:26 2009 +0000
+++ b/tools/firmware/hvmloader/config.h Mon Dec 14 09:25:47 2009 +0000
@@ -50,9 +50,6 @@ extern unsigned long pci_mem_start, pci_
 #define XEN_PF_IOBASE   0x10
 #define PFFLAG_ROM_LOCK 1 /* Sets whether ROM memory area is RW or RO */
 
-/* Maximum we can support with current vLAPIC ID mapping. */
-#define MAX_VCPUS 128
-
 /* Located at BIOS_INFO_PHYSICAL_ADDRESS. */
 struct bios_info {
     uint8_t  com1_present:1;    /* 0[0] - System has COM1? */
diff -r eaea340b371d -r 5ea096ef7603 tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Mon Dec 14 09:14:26 2009 +0000
+++ b/tools/firmware/hvmloader/util.h   Mon Dec 14 09:25:47 2009 +0000
@@ -29,6 +29,11 @@ void __bug(char *file, int line) __attri
 #define BUG() __bug(__FILE__, __LINE__)
 #define BUG_ON(p) do { if (p) BUG(); } while (0)
 #define BUILD_BUG_ON(p) ((void)sizeof(char[1 - 2 * !!(p)]))
+
+static inline int test_bit(unsigned int b, void *p)
+{
+    return !!(((uint8_t *)p)[b>>3] & (1u<<(b&7)));
+}
 
 /* MSR access */
 void wrmsr(uint32_t idx, uint64_t v);
diff -r eaea340b371d -r 5ea096ef7603 tools/python/xen/lowlevel/xc/xc.c
--- a/tools/python/xen/lowlevel/xc/xc.c Mon Dec 14 09:14:26 2009 +0000
+++ b/tools/python/xen/lowlevel/xc/xc.c Mon Dec 14 09:25:47 2009 +0000
@@ -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,8 @@ static PyObject *pyxc_hvm_build(XcObject
     va_hvm->acpi_enabled = acpi;
     va_hvm->apic_mode    = apic;
     va_hvm->nr_vcpus     = vcpus;
+    ((uint64_t *)va_hvm->vcpu_online)[0] = vcpu_avail;
+    ((uint64_t *)va_hvm->vcpu_online)[1] = 0;    
     for ( i = 0, sum = 0; i < va_hvm->length; i++ )
         sum += ((uint8_t *)va_hvm)[i];
     va_hvm->checksum -= sum;
@@ -1810,6 +1813,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 eaea340b371d -r 5ea096ef7603 tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Mon Dec 14 09:14:26 2009 +0000
+++ b/tools/python/xen/xend/image.py    Mon Dec 14 09:25:47 2009 +0000
@@ -938,6 +938,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)
 
@@ -946,6 +947,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 eaea340b371d -r 5ea096ef7603 xen/include/public/hvm/hvm_info_table.h
--- a/xen/include/public/hvm/hvm_info_table.h   Mon Dec 14 09:14:26 2009 +0000
+++ b/xen/include/public/hvm/hvm_info_table.h   Mon Dec 14 09:25:47 2009 +0000
@@ -28,6 +28,9 @@
 #define HVM_INFO_PFN         0x09F
 #define HVM_INFO_OFFSET      0x800
 #define HVM_INFO_PADDR       ((HVM_INFO_PFN << 12) + HVM_INFO_OFFSET)
+
+/* Maximum we can support with current vLAPIC ID mapping. */
+#define HVM_MAX_VCPUS        128
 
 struct hvm_info_table {
     char        signature[8]; /* "HVM INFO" */
@@ -64,6 +67,9 @@ struct hvm_info_table {
      *    RAM above 4GB
      */
     uint32_t    high_mem_pgend;
+
+    /* Bitmap of which CPUs are online at boot time. */
+    uint8_t     vcpu_online[HVM_MAX_VCPUS/8];
 };
 
 #endif /* __XEN_PUBLIC_HVM_HVM_INFO_TABLE_H__ */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] HVM vcpu add/remove: parse 'vcpu_avail' to firmware and set up madt, Xen patchbot-unstable <=