[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v1 06/20] acpi/hvmloader: Collect processor and NUMA info in hvmloader



No need for ACPI code to rely on hvm_info.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
---

Changes in v1:
* Pass hvm_info_table pointer in acpi_config

 tools/firmware/hvmloader/acpi/build.c   |   53 ++++++++++++++++---------------
 tools/firmware/hvmloader/acpi/libacpi.h |   13 +++++++
 tools/firmware/hvmloader/util.c         |    9 +++++
 3 files changed, 49 insertions(+), 26 deletions(-)

diff --git a/tools/firmware/hvmloader/acpi/build.c 
b/tools/firmware/hvmloader/acpi/build.c
index 95f6cf8..d6e7798 100644
--- a/tools/firmware/hvmloader/acpi/build.c
+++ b/tools/firmware/hvmloader/acpi/build.c
@@ -54,7 +54,7 @@ static void set_checksum(
     p[checksum_offset] = -sum;
 }
 
-static struct acpi_20_madt *construct_madt(struct acpi_info *info)
+static struct acpi_20_madt *construct_madt(struct acpi_config *config)
 {
     struct acpi_20_madt           *madt;
     struct acpi_20_madt_intsrcovr *intsrcovr;
@@ -65,7 +65,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_info 
*info)
     sz  = sizeof(struct acpi_20_madt);
     sz += sizeof(struct acpi_20_madt_intsrcovr) * 16;
     sz += sizeof(struct acpi_20_madt_ioapic);
-    sz += sizeof(struct acpi_20_madt_lapic) * hvm_info->nr_vcpus;
+    sz += sizeof(struct acpi_20_madt_lapic) * config->hvminfo->nr_vcpus;
 
     madt = mem_alloc(sz, 16);
     if (!madt) return NULL;
@@ -118,9 +118,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_info 
*info)
     io_apic->ioapic_addr = IOAPIC_BASE_ADDRESS;
 
     lapic = (struct acpi_20_madt_lapic *)(io_apic + 1);
-    info->nr_cpus = hvm_info->nr_vcpus;
-    info->madt_lapic0_addr = (uint32_t)lapic;
-    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
+    config->ainfo.nr_cpus =config-> hvminfo->nr_vcpus;
+    config->ainfo.madt_lapic0_addr = (uint32_t)lapic;
+    for ( i = 0; i < config->hvminfo->nr_vcpus; i++ )
     {
         memset(lapic, 0, sizeof(*lapic));
         lapic->type    = ACPI_PROCESSOR_LOCAL_APIC;
@@ -128,7 +128,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_info 
*info)
         /* Processor ID must match processor-object IDs in the DSDT. */
         lapic->acpi_processor_id = i;
         lapic->apic_id = LAPIC_ID(i);
-        lapic->flags = (test_bit(i, hvm_info->vcpu_online)
+        lapic->flags = (test_bit(i, config->hvminfo->vcpu_online)
                         ? ACPI_LOCAL_APIC_ENABLED : 0);
         lapic++;
     }
@@ -136,7 +136,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_info 
*info)
     madt->header.length = (unsigned char *)lapic - (unsigned char *)madt;
     set_checksum(madt, offsetof(struct acpi_header, checksum),
                  madt->header.length);
-    info->madt_csum_addr = (uint32_t)&madt->header.checksum;
+    config->ainfo.madt_csum_addr = (uint32_t)&madt->header.checksum;
 
     return madt;
 }
@@ -179,7 +179,7 @@ static struct acpi_20_waet *construct_waet(void)
     return waet;
 }
 
-static struct acpi_20_srat *construct_srat(void)
+static struct acpi_20_srat *construct_srat(struct acpi_config *config)
 {
     struct acpi_20_srat *srat;
     struct acpi_20_srat_processor *processor;
@@ -188,8 +188,8 @@ static struct acpi_20_srat *construct_srat(void)
     void *p;
     unsigned int i;
 
-    size = sizeof(*srat) + sizeof(*processor) * hvm_info->nr_vcpus +
-           sizeof(*memory) * nr_vmemranges;
+    size = sizeof(*srat) + sizeof(*processor) * config->hvminfo->nr_vcpus +
+           sizeof(*memory) * config->numa.nr_vmemranges;
 
     p = mem_alloc(size, 16);
     if ( !p )
@@ -206,25 +206,26 @@ static struct acpi_20_srat *construct_srat(void)
     srat->table_revision      = ACPI_SRAT_TABLE_REVISION;
 
     processor = (struct acpi_20_srat_processor *)(srat + 1);
-    for ( i = 0; i < hvm_info->nr_vcpus; i++ )
+    for ( i = 0; i < config->hvminfo->nr_vcpus; i++ )
     {
         processor->type     = ACPI_PROCESSOR_AFFINITY;
         processor->length   = sizeof(*processor);
-        processor->domain   = vcpu_to_vnode[i];
+        processor->domain   = config->numa.vcpu_to_vnode[i];
         processor->apic_id  = LAPIC_ID(i);
         processor->flags    = ACPI_LOCAL_APIC_AFFIN_ENABLED;
         processor++;
     }
 
     memory = (struct acpi_20_srat_memory *)processor;
-    for ( i = 0; i < nr_vmemranges; i++ )
+    for ( i = 0; i < config->numa.nr_vmemranges; i++ )
     {
         memory->type          = ACPI_MEMORY_AFFINITY;
         memory->length        = sizeof(*memory);
-        memory->domain        = vmemrange[i].nid;
+        memory->domain        = config->numa.vmemrange[i].nid;
         memory->flags         = ACPI_MEM_AFFIN_ENABLED;
-        memory->base_address  = vmemrange[i].start;
-        memory->mem_length    = vmemrange[i].end - vmemrange[i].start;
+        memory->base_address  = config->numa.vmemrange[i].start;
+        memory->mem_length    = config->numa.vmemrange[i].end -
+            config->numa.vmemrange[i].start;
         memory++;
     }
 
@@ -236,12 +237,12 @@ static struct acpi_20_srat *construct_srat(void)
     return srat;
 }
 
-static struct acpi_20_slit *construct_slit(void)
+static struct acpi_20_slit *construct_slit(struct acpi_config *config)
 {
     struct acpi_20_slit *slit;
     unsigned int i, num, size;
 
-    num = nr_vnodes * nr_vnodes;
+    num = config->numa.nr_vnodes * config->numa.nr_vnodes;
     size = sizeof(*slit) + num * sizeof(uint8_t);
 
     slit = mem_alloc(size, 16);
@@ -258,9 +259,9 @@ static struct acpi_20_slit *construct_slit(void)
     slit->header.creator_revision = ACPI_CREATOR_REVISION;
 
     for ( i = 0; i < num; i++ )
-        slit->entry[i] = vdistance[i];
+        slit->entry[i] = config->numa.vdistance[i];
 
-    slit->localities = nr_vnodes;
+    slit->localities = config->numa.nr_vnodes;
 
     slit->header.length = size;
     set_checksum(slit, offsetof(struct acpi_header, checksum), size);
@@ -320,9 +321,9 @@ static int construct_secondary_tables(unsigned long 
*table_ptrs,
     void *lasa;
 
     /* MADT. */
-    if ( (hvm_info->nr_vcpus > 1) || hvm_info->apic_mode )
+    if ( (config->hvminfo->nr_vcpus > 1) || config->hvminfo->apic_mode )
     {
-        madt = construct_madt(&config->ainfo);
+        madt = construct_madt(config);
         if (!madt) return -1;
         table_ptrs[nr_tables++] = (unsigned long)madt;
     }
@@ -404,10 +405,10 @@ static int construct_secondary_tables(unsigned long 
*table_ptrs,
     }
 
     /* SRAT and SLIT */
-    if ( nr_vnodes > 0 )
+    if ( config->numa.nr_vnodes > 0 )
     {
-        struct acpi_20_srat *srat = construct_srat();
-        struct acpi_20_slit *slit = construct_slit();
+        struct acpi_20_srat *srat = construct_srat(config);
+        struct acpi_20_slit *slit = construct_slit(config);
 
         if ( srat )
             table_ptrs[nr_tables++] = (unsigned long)srat;
@@ -483,7 +484,7 @@ void acpi_build_tables(struct acpi_config *config)
      * The latter is required for Windows 2000, which experiences a BSOD of
      * KMODE_EXCEPTION_NOT_HANDLED if it sees more than 15 processor objects.
      */
-    if ( hvm_info->nr_vcpus <= 15 && config->dsdt_15cpu)
+    if ( config->hvminfo->nr_vcpus <= 15 && config->dsdt_15cpu)
     {
         dsdt = mem_alloc(config->dsdt_15cpu_len, 16);
         if (!dsdt) goto oom;
diff --git a/tools/firmware/hvmloader/acpi/libacpi.h 
b/tools/firmware/hvmloader/acpi/libacpi.h
index 05e6c69..9d28ba7 100644
--- a/tools/firmware/hvmloader/acpi/libacpi.h
+++ b/tools/firmware/hvmloader/acpi/libacpi.h
@@ -28,6 +28,8 @@
 #ifndef __LIBACPI_H__
 #define __LIBACPI_H__
 
+#include <xen/memory.h>
+
 /* Flags indicating which tables to build */
 #define ACPI_BUILD_SSDT_PM        (1<<0)
 #define ACPI_BUILD_SSDT_S3        (1<<1)
@@ -51,6 +53,14 @@ struct acpi_info {
     uint64_t pci_hi_min, pci_hi_len; /* 24, 32 - PCI I/O hole boundaries */
 };
 
+struct acpi_numa {
+    uint32_t nr_vmemranges;
+    uint32_t nr_vnodes;
+    unsigned int *vcpu_to_vnode;
+    unsigned int *vdistance;
+    xen_vmemrange_t *vmemrange;
+};
+
 struct acpi_config {
     const unsigned char *dsdt_anycpu;
     unsigned int dsdt_anycpu_len;
@@ -66,6 +76,9 @@ struct acpi_config {
         uint32_t pt_length;
     } pt;
 
+    struct acpi_numa numa;
+    struct hvm_info_table *hvminfo;
+
     /* May have some fields updated by acpi_build_table() */
     struct acpi_info ainfo;
     /*
diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c
index 1864d7a..020cf1d 100644
--- a/tools/firmware/hvmloader/util.c
+++ b/tools/firmware/hvmloader/util.c
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "hypercall.h"
 #include "ctype.h"
+#include "vnuma.h"
 #include "acpi/acpi2_0.h"
 #include "acpi/libacpi.h"
 #include <stdint.h>
@@ -913,6 +914,14 @@ void hvmloader_acpi_build_tables(struct acpi_config 
*config,
     if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1)  )
         config->table_flags |= ACPI_BUILD_SSDT_S4;
 
+    config->numa.nr_vmemranges = nr_vmemranges;
+    config->numa.nr_vnodes = nr_vnodes;
+    config->numa.vcpu_to_vnode = vcpu_to_vnode;
+    config->numa.vdistance = vdistance;
+    config->numa.vmemrange = vmemrange;
+
+    config->hvminfo = hvm_info;
+
     config->rsdp = physical;
     config->ainfop = ACPI_INFO_PHYSICAL_ADDRESS;
 
-- 
1.7.1


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.