[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v3 02/19] acpi/hvmloader: Collect processor and NUMA info in hvmloader
No need for ACPI code to rely on hvm_info variable. Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> --- Changes in v3: * Constified acpi_numa's pointers * Constified acpi_config call parameter where possible tools/firmware/hvmloader/acpi/build.c | 51 +++++++++++++++++---------------- tools/firmware/hvmloader/acpi/libacpi.h | 13 +++++++++ tools/firmware/hvmloader/util.c | 9 ++++++ 3 files changed, 49 insertions(+), 24 deletions(-) diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index de56f1f..5f5c5f0 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -70,18 +70,20 @@ 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(const struct acpi_config *config, + struct acpi_info *info) { struct acpi_20_madt *madt; struct acpi_20_madt_intsrcovr *intsrcovr; struct acpi_20_madt_ioapic *io_apic; struct acpi_20_madt_lapic *lapic; + struct hvm_info_table *hvminfo = config->hvminfo; int i, sz; 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) * hvminfo->nr_vcpus; madt = mem_alloc(sz, 16); if (!madt) return NULL; @@ -134,9 +136,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->nr_cpus = hvminfo->nr_vcpus; info->madt_lapic0_addr = (uint32_t)lapic; - for ( i = 0; i < hvm_info->nr_vcpus; i++ ) + for ( i = 0; i < hvminfo->nr_vcpus; i++ ) { memset(lapic, 0, sizeof(*lapic)); lapic->type = ACPI_PROCESSOR_LOCAL_APIC; @@ -144,7 +146,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, hvminfo->vcpu_online) ? ACPI_LOCAL_APIC_ENABLED : 0); lapic++; } @@ -195,7 +197,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(const struct acpi_config *config) { struct acpi_20_srat *srat; struct acpi_20_srat_processor *processor; @@ -204,8 +206,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 ) @@ -222,25 +224,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++; } @@ -252,12 +255,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(const 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); @@ -274,9 +277,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); @@ -335,9 +338,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(info); + madt = construct_madt(config, info); if (!madt) return -1; table_ptrs[nr_tables++] = (unsigned long)madt; } @@ -419,10 +422,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; @@ -515,7 +518,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 22fd5f6..78c3a1c 100644 --- a/tools/firmware/hvmloader/acpi/libacpi.h +++ b/tools/firmware/hvmloader/acpi/libacpi.h @@ -20,6 +20,8 @@ #ifndef __LIBACPI_H__ #define __LIBACPI_H__ +#include <xen/memory.h> + #define ACPI_HAS_COM1 (1<<0) #define ACPI_HAS_COM2 (1<<1) #define ACPI_HAS_LPT1 (1<<2) @@ -29,6 +31,14 @@ #define ACPI_HAS_SSDT_S4 (1<<6) +struct acpi_numa { + uint32_t nr_vmemranges; + uint32_t nr_vnodes; + const unsigned int *vcpu_to_vnode; + const unsigned int *vdistance; + const struct xen_vmemrange *vmemrange; +}; + struct acpi_config { const unsigned char *dsdt_anycpu; unsigned int dsdt_anycpu_len; @@ -49,6 +59,9 @@ struct acpi_config { uint32_t length; } pt; + struct acpi_numa numa; + struct hvm_info_table *hvminfo; + /* * Address where acpi_info should be placed. * This must match the OperationRegion(BIOS, SystemMemory, ....) diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index b2d3421..f37b16e 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> @@ -918,6 +919,14 @@ void hvmloader_acpi_build_tables(struct acpi_config *config, if ( !strncmp(xenstore_read("platform/acpi_s4", "1"), "1", 1) ) config->table_flags |= ACPI_HAS_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->infop = ACPI_INFO_PHYSICAL_ADDRESS; -- 1.8.3.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |