With this, we can eliminate struct PcGuestInfo completely. Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> --- hw/i386/acpi-build.c | 25 +++++++++++-------------- hw/i386/pc.c | 23 ++++++++++------------- include/hw/i386/pc.h | 15 +++++---------- 3 files changed, 26 insertions(+), 37 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index cdbe5b9..3c7af74 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -368,7 +368,6 @@ static void build_madt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, PCMachineState *pcms) { - PcGuestInfo *guest_info = &pcms->acpi_guest_info; int madt_start = table_data->len; AcpiMultipleApicTable *madt; @@ -381,7 +380,7 @@ build_madt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, madt->local_apic_address = cpu_to_le32(APIC_DEFAULT_ADDRESS); madt->flags = cpu_to_le32(1); - for (i = 0; i < guest_info->apic_id_limit; i++) { + for (i = 0; i < pcms->apic_id_limit; i++) { AcpiMadtProcessorApic *apic = acpi_data_push(table_data, sizeof *apic); apic->type = ACPI_APIC_PROCESSOR; apic->length = sizeof(*apic); @@ -929,11 +928,11 @@ static Aml *build_crs(PCIHostState *host, static void build_ssdt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, AcpiPmInfo *pm, AcpiMiscInfo *misc, - PcPciInfo *pci, PcGuestInfo *guest_info) + PcPciInfo *pci, PCMachineState *pcms) { - MachineState *machine = MACHINE(qdev_get_machine()); + MachineState *machine = MACHINE(pcms); uint32_t nr_mem = machine->ram_slots; - unsigned acpi_cpus = guest_info->apic_id_limit; + unsigned acpi_cpus = pcms->apic_id_limit; Aml *ssdt, *sb_scope, *scope, *pkg, *dev, *method, *crs, *field, *ifctx; PCIBus *bus = NULL; GPtrArray *io_ranges = g_ptr_array_new_with_free_func(crs_range_free); @@ -1456,7 +1455,6 @@ acpi_build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, static void build_srat(GArray *table_data, GArray *linker, PCMachineState *pcms) { - PcGuestInfo *guest_info = &pcms->acpi_guest_info; AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorAffinity *core; AcpiSratMemoryAffinity *numamem; @@ -1475,12 +1473,12 @@ build_srat(GArray *table_data, GArray *linker, PCMachineState *pcms) srat->reserved1 = cpu_to_le32(1); core = (void *)(srat + 1); - for (i = 0; i < guest_info->apic_id_limit; ++i) { + for (i = 0; i < pcms->apic_id_limit; ++i) { core = acpi_data_push(table_data, sizeof *core); core->type = ACPI_SRAT_PROCESSOR; core->length = sizeof(*core); core->local_apic_id = i; - curnode = guest_info->node_cpu[i]; + curnode = pcms->node_cpu[i]; core->proximity_lo = curnode; memset(core->proximity_hi, 0, 3); core->local_sapic_eid = 0; @@ -1497,9 +1495,9 @@ build_srat(GArray *table_data, GArray *linker, PCMachineState *pcms) numamem = acpi_data_push(table_data, sizeof *numamem); acpi_build_srat_memory(numamem, 0, 640*1024, 0, MEM_AFFINITY_ENABLED); next_base = 1024 * 1024; - for (i = 1; i < guest_info->numa_nodes + 1; ++i) { + for (i = 1; i < pcms->numa_nodes + 1; ++i) { mem_base = next_base; - mem_len = guest_info->node_mem[i - 1]; + mem_len = pcms->node_mem[i - 1]; if (i == 1) { mem_len -= 1024 * 1024; } @@ -1523,7 +1521,7 @@ build_srat(GArray *table_data, GArray *linker, PCMachineState *pcms) MEM_AFFINITY_ENABLED); } slots = (table_data->len - numa_start) / sizeof *numamem; - for (; slots < guest_info->numa_nodes + 2; slots++) { + for (; slots < pcms->numa_nodes + 2; slots++) { numamem = acpi_data_push(table_data, sizeof *numamem); acpi_build_srat_memory(numamem, 0, 0, 0, MEM_AFFINITY_NOFLAGS); } @@ -1686,7 +1684,6 @@ static bool acpi_has_iommu(void) static void acpi_build(PCMachineState *pcms, AcpiBuildTables *tables) { - PcGuestInfo *guest_info = &pcms->acpi_guest_info; PCMachineClass *pcmc = PC_MACHINE_GET_CLASS(pcms); GArray *table_offsets; unsigned facs, ssdt, dsdt, rsdt; @@ -1737,7 +1734,7 @@ void acpi_build(PCMachineState *pcms, AcpiBuildTables *tables) ssdt = tables_blob->len; acpi_add_table(table_offsets, tables_blob); build_ssdt(tables_blob, tables->linker, &cpu, &pm, &misc, &pci, - guest_info); + pcms); aml_len += tables_blob->len - ssdt; acpi_add_table(table_offsets, tables_blob); @@ -1756,7 +1753,7 @@ void acpi_build(PCMachineState *pcms, AcpiBuildTables *tables) build_tpm2(tables_blob, tables->linker); } } - if (guest_info->numa_nodes) { + if (pcms->numa_nodes) { acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, pcms); } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index f399d14..bcd4351 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1182,29 +1182,28 @@ void pc_machine_done(Notifier *notifier, void *data) acpi_setup(pcms); } -PcGuestInfo *pc_guest_info_init(PCMachineState *pcms) +void pc_guest_info_init(PCMachineState *pcms) { - PcGuestInfo *guest_info = &pcms->acpi_guest_info; int i, j; - guest_info->apic_id_limit = pc_apic_id_limit(max_cpus); + pcms->apic_id_limit = pc_apic_id_limit(max_cpus); pcms->apic_xrupt_override = kvm_allows_irq0_override(); - guest_info->numa_nodes = nb_numa_nodes; - guest_info->node_mem = g_malloc0(guest_info->numa_nodes * - sizeof *guest_info->node_mem); + pcms->numa_nodes = nb_numa_nodes; + pcms->node_mem = g_malloc0(pcms->numa_nodes * + sizeof *pcms->node_mem); for (i = 0; i < nb_numa_nodes; i++) { - guest_info->node_mem[i] = numa_info[i].node_mem; + pcms->node_mem[i] = numa_info[i].node_mem; } - guest_info->node_cpu = g_malloc0(guest_info->apic_id_limit * - sizeof *guest_info->node_cpu); + pcms->node_cpu = g_malloc0(pcms->apic_id_limit * + sizeof *pcms->node_cpu); for (i = 0; i < max_cpus; i++) { unsigned int apic_id = x86_cpu_apic_id_from_index(i); - assert(apic_id < guest_info->apic_id_limit); + assert(apic_id < pcms->apic_id_limit); for (j = 0; j < nb_numa_nodes; j++) { if (test_bit(i, numa_info[j].node_cpu)) { - guest_info->node_cpu[apic_id] = j; + pcms->node_cpu[apic_id] = j; break; } } @@ -1212,7 +1211,6 @@ PcGuestInfo *pc_guest_info_init(PCMachineState *pcms) pcms->machine_done.notify = pc_machine_done; qemu_add_machine_init_done_notifier(&pcms->machine_done); - return guest_info; } /* setup pci memory address space mapping into system address space */ @@ -1277,7 +1275,6 @@ FWCfgState *pc_memory_init(PCMachineState *pcms, MemoryRegion *rom_memory, MemoryRegion **ram_memory) { - PcGuestInfo *guest_info = &pcms->acpi_guest_info; int linux_boot, i; MemoryRegion *ram, *option_rom_mr; MemoryRegion *ram_below_4g, *ram_above_4g; diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 5ded182..6ff4721 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -20,14 +20,6 @@ #define HPET_INTCAP "hpet-intcap" -/* Machine info for ACPI build: */ -struct PcGuestInfo { - unsigned apic_id_limit; - uint64_t numa_nodes; - uint64_t *node_mem; - uint64_t *node_cpu; -}; - /** * PCMachineState: * @acpi_dev: link to ACPI PM device that performs ACPI hotplug handling @@ -47,10 +39,13 @@ struct PCMachineState { OnOffAuto smm; ram_addr_t below_4g_mem_size, above_4g_mem_size; PCIBus *bus; - PcGuestInfo acpi_guest_info; Notifier machine_done; FWCfgState *fw_cfg; bool apic_xrupt_override; + unsigned apic_id_limit; + uint64_t numa_nodes; + uint64_t *node_mem; + uint64_t *node_cpu; }; #define PC_MACHINE_ACPI_DEVICE_PROP "acpi-device" @@ -187,7 +182,7 @@ void pc_cpus_init(PCMachineState *pcms); void pc_hot_add_cpu(const int64_t id, Error **errp); void pc_acpi_init(const char *default_dsdt); -PcGuestInfo *pc_guest_info_init(PCMachineState *pcms); +void pc_guest_info_init(PCMachineState *pcms); #define PCI_HOST_PROP_PCI_HOLE_START "pci-hole-start" #define PCI_HOST_PROP_PCI_HOLE_END "pci-hole-end" -- 2.1.0