From acb06b5ca2ea9f30a7b14c34674b930f0e8a1a60 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Tue, 16 Jan 2018 14:15:34 +0100 Subject: [PATCH 02/21] hw/acpi: Move acpi_set_pci_info to pcihp RH-Author: Marcel Apfelbaum Message-id: <20180116141534.100478-1-marcel@redhat.com> Patchwork-id: 78628 O-Subject: [RHEL-7.5 qemu-kvm-rhev PATCH V2] hw/acpi: Move acpi_set_pci_info to pcihp Bugzilla: 1507693 RH-Acked-by: Igor Mammedov RH-Acked-by: Michael S. Tsirkin RH-Acked-by: Laszlo Ersek From: Anthony PERARD RHEL Note: rhel6 machine types don't generate their ACPI payload (pcmc->has_acpi_build = false), SeaBIOS does it for them (m->default_machine_opts = "firmware=bios.bin"). In turn, before the patch, these machine types never call acpi_setup() -> acpi_set_pci_info(), and never set BSEL. After the patch, BSEL is set in all i440fx-based machine types, via piix4_reset() -> acpi_pcihp_reset() -> acpi_set_pci_info(). HW part of ACPI PCI hotplug in QEMU depends on ACPI_PCIHP_PROP_BSEL being set on a PCI bus that supports ACPI hotplug. It should work regardless of the source of ACPI tables (QEMU generator/legacy SeaBIOS/Xen). So move ACPI_PCIHP_PROP_BSEL initialization into HW ACPI implementation part from QEMU's ACPI table generator. To do PCI passthrough with Xen, the property ACPI_PCIHP_PROP_BSEL needs to be set, but this was done only when ACPI tables are built which is not needed for a Xen guest. The need for the property starts with commit "pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice" (f0c9d64a68b776374ec4732424a3e27753ce37b6). Adding find_i440fx into stubs so that mips-softmmu target can be built. Reported-by: Sander Eikelenboom Signed-off-by: Anthony PERARD Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit ab938ae43f8a3a71a3525566edf586081b7a7452) Signed-off-by: Marcel Apfelbaum Conflicts: stubs/Makefile.objs (some stubs were added before it) Signed-off-by: Marcel Apfelbaum --- V1 -> V2: Added the RHEL Note (Laszlo) hw/acpi/pcihp.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 32 -------------------------------- stubs/Makefile.objs | 1 + stubs/pci-host-piix.c | 6 ++++++ 4 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 stubs/pci-host-piix.c Signed-off-by: Miroslav Rezanina --- hw/acpi/pcihp.c | 38 ++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 32 -------------------------------- stubs/Makefile.objs | 1 + stubs/pci-host-piix.c | 6 ++++++ 4 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 stubs/pci-host-piix.c diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index c420a38..9ad5edc 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -75,6 +75,43 @@ static int acpi_pcihp_get_bsel(PCIBus *bus) } } +/* Assign BSEL property to all buses. In the future, this can be changed + * to only assign to buses that support hotplug. + */ +static void *acpi_set_bsel(PCIBus *bus, void *opaque) +{ + unsigned *bsel_alloc = opaque; + unsigned *bus_bsel; + + if (qbus_is_hotpluggable(BUS(bus))) { + bus_bsel = g_malloc(sizeof *bus_bsel); + + *bus_bsel = (*bsel_alloc)++; + object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, + bus_bsel, &error_abort); + } + + return bsel_alloc; +} + +static void acpi_set_pci_info(void) +{ + static bool bsel_is_set; + PCIBus *bus; + unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT; + + if (bsel_is_set) { + return; + } + bsel_is_set = true; + + bus = find_i440fx(); /* TODO: Q35 support */ + if (bus) { + /* Scan all PCI buses. Set property to enable acpi based hotplug. */ + pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc); + } +} + static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque) { AcpiPciHpFind *find = opaque; @@ -177,6 +214,7 @@ static void acpi_pcihp_update(AcpiPciHpState *s) void acpi_pcihp_reset(AcpiPciHpState *s) { + acpi_set_pci_info(); acpi_pcihp_update(s); } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index a61560f..8117321 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -495,36 +495,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCMachineState *pcms) table_data->len - madt_start, 1, NULL, NULL); } -/* Assign BSEL property to all buses. In the future, this can be changed - * to only assign to buses that support hotplug. - */ -static void *acpi_set_bsel(PCIBus *bus, void *opaque) -{ - unsigned *bsel_alloc = opaque; - unsigned *bus_bsel; - - if (qbus_is_hotpluggable(BUS(bus))) { - bus_bsel = g_malloc(sizeof *bus_bsel); - - *bus_bsel = (*bsel_alloc)++; - object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, - bus_bsel, &error_abort); - } - - return bsel_alloc; -} - -static void acpi_set_pci_info(void) -{ - PCIBus *bus = find_i440fx(); /* TODO: Q35 support */ - unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT; - - if (bus) { - /* Scan all PCI buses. Set property to enable acpi based hotplug. */ - pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc); - } -} - static void build_append_pcihp_notify_entry(Aml *method, int slot) { Aml *if_ctx; @@ -2890,8 +2860,6 @@ void acpi_setup(void) build_state = g_malloc0(sizeof *build_state); - acpi_set_pci_info(); - acpi_build_tables_init(&tables); acpi_build(&tables, MACHINE(pcms)); diff --git a/stubs/Makefile.objs b/stubs/Makefile.objs index 7e9f94d..e3b9e6b 100644 --- a/stubs/Makefile.objs +++ b/stubs/Makefile.objs @@ -42,3 +42,4 @@ stub-obj-y += xen-common.o stub-obj-y += xen-hvm.o stub-obj-y += shadow-bios.o stub-obj-y += ide-isa.o +stub-obj-y += pci-host-piix.o diff --git a/stubs/pci-host-piix.c b/stubs/pci-host-piix.c new file mode 100644 index 0000000..6ed81b1 --- /dev/null +++ b/stubs/pci-host-piix.c @@ -0,0 +1,6 @@ +#include "qemu/osdep.h" +#include "hw/i386/pc.h" +PCIBus *find_i440fx(void) +{ + return NULL; +} -- 1.8.3.1