APCI PCI Hotplug support on ARM
cover APCI PCI Hotplug support on ARM
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from hw/i386/acpi-build.c to a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.
On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/
Eric Auger (24):
hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo hw/acpi/ged: Fix wrong identation
hw/i386/acpi-build: Fix build_append_notfication_callback typo hw/i386/acpi-build: Make aml_pci_device_dsm() static hw/arm/virt: Introduce machine state acpi pcihp flags and props hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to
acpi_dsdt_add_pci_osc
hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine
downto gpex
hw/i386/acpi-build: Turn build_q35_osc_method into a generic method hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug hw/i386/acpi-build: Move build_append_notification_callback to pcihp hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp hw/i386/acpi-build: Introduce and use acpi_get_pci_host hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug hw/acpi/ged: Prepare the device to react to PCI hotplug events hw/acpi/ged: Call pcihp plug callbacks in hotplug handler
implementation
hw/acpi/ged: Support migration of AcpiPciHpState hw/core/sysbus: Introduce sysbus_mmio_map_name() helper hw/arm/virt: Let virt support pci hotplug/unplug GED event hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks hw/arm/virt: Use ACPI PCI hotplug by default
hw/i386/acpi-build.h | 4 - include/hw/acpi/aml-build.h | 2 + include/hw/acpi/generic_event_device.h | 5 + include/hw/acpi/pci.h | 4 +- include/hw/acpi/pcihp.h | 14 + include/hw/arm/virt.h | 4 + include/hw/pci-host/gpex.h | 1 + include/hw/sysbus.h | 1 + hw/acpi/aml-build.c | 50 +++ hw/acpi/generic_event_device.c | 64 +++- hw/acpi/pci.c | 20 ++ hw/acpi/pcihp.c | 428 +++++++++++++++++++++- hw/arm/virt-acpi-build.c | 26 ++ hw/arm/virt.c | 100 +++++- hw/core/sysbus.c | 11 + hw/i386/acpi-build.c | 475 +------------------------ hw/pci-host/gpex-acpi.c | 75 +--- hw/pci/pcie_port.c | 4 +- hw/arm/Kconfig | 2 + 19 files changed, 748 insertions(+), 542 deletions(-)
Signature · 1 line
2.49.0
RFC 1/24 hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
--- hw/pci/pcie_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/pci/pcie_port.c +2 -2
@@ -188,7 +188,7 @@ int pcie_count_ds_ports(PCIBus *bus)return dsp_count; } -static bool pcie_slot_is_hotpluggbale_bus (HotplugHandler *plug_handler, +static bool pcie_slot_is_hotpluggable_bus (HotplugHandler *plug_handler,BusState *bus) {PCIESlot *s =PCIE_SLOT (bus->parent);
@@ -221,7 +221,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data) hc->plug = pcie_cap_slot_plug_cb; hc->unplug = pcie_cap_slot_unplug_cb; hc->unplug_request = pcie_cap_slot_unplug_request_cb; - hc->is_hotpluggable_bus = pcie_slot_is_hotpluggbale_bus; + hc->is_hotpluggable_bus = pcie_slot_is_hotpluggable_bus; }static const TypeInfo pcie_slot_type_info = {
Signature · 1 line
2.49.0
Re: [RFC 01/24] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
Hi Eric,
Quoted 19 lines · Eric Auger
Signed-off-by Eric Auger <[email protected]>--- hw/pci/pcie_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)hw/pci/pcie_port.c +1
-1@@ -188,7 +188,7 @@ int pcie_count_ds_ports(PCIBus *bus)return dsp_count; } -static bool pcie_slot_is_hotpluggbale_bus (HotplugHandler *plug_handler, +static bool pcie_slot_is_hotpluggable_bus (HotplugHandler *plug_handler,BusState *bus) {PCIESlot *s =PCIE_SLOT (bus->parent);
hw/pci/pcie_port.c static void pcie_slot_class_init(ObjectClass *oc, void *data) · line 227
Quoted 8 lines
hw/pci/pcie_port.c +1
-1@@ -221,7 +221,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data) hc->plug = pcie_cap_slot_plug_cb; hc->unplug = pcie_cap_slot_unplug_cb; hc->unplug_request = pcie_cap_slot_unplug_request_cb; - hc->is_hotpluggable_bus = pcie_slot_is_hotpluggbale_bus; + hc->is_hotpluggable_bus = pcie_slot_is_hotpluggable_bus; }static const TypeInfo pcie_slot_type_info = {
Cheers,
Gustavo
RFC 2/24 hw/acpi/ged: Fix wrong identation
In reply to Eric Auger--- hw/acpi/generic_event_device.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
hw/acpi/generic_event_device.c +5 -5
@@ -458,11 +458,11 @@ static void acpi_ged_initfn(Object *obj)* container for memory hotplug IO and expose it as GED sysbus * MMIO so that boards can map it separately. */ -memory_region_init (&s->container_memhp,OBJECT (dev),"memhp container" , -MEMORY_HOTPLUG_IO_LEN ); -sysbus_init_mmio (sbd, &s->container_memhp); -acpi_memory_hotplug_init (&s->container_memhp,OBJECT (dev), - &s->memhp_state,0 ); +memory_region_init (&s->container_memhp,OBJECT (dev),"memhp container" , +MEMORY_HOTPLUG_IO_LEN ); +sysbus_init_mmio (sbd, &s->container_memhp); +acpi_memory_hotplug_init (&s->container_memhp,OBJECT (dev), + &s->memhp_state,0 );memory_region_init_io (&ged_st->regs, obj, &ged_regs_ops, ged_st,TYPE_ACPI_GED "-regs" ,ACPI_GED_REG_COUNT );
Signature · 1 line
2.49.0
Re: [RFC 02/24] hw/acpi/ged: Fix wrong identation
Hi Eric,
Quoted 16 lines · Eric Auger
Signed-off-by Eric Auger <[email protected]>--- hw/acpi/generic_event_device.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)hw/acpi/generic_event_device.c +0
-3@@ -458,11 +458,11 @@ static void acpi_ged_initfn(Object *obj)* container for memory hotplug IO and expose it as GED sysbus * MMIO so that boards can map it separately. */ -memory_region_init (&s->container_memhp,OBJECT (dev),"memhp container" , -MEMORY_HOTPLUG_IO_LEN ); -sysbus_init_mmio (sbd, &s->container_memhp);
hw/acpi/generic_event_device.c static void acpi_ged_initfn(Object *obj) · line 468
Quoted 10 lines
hw/acpi/generic_event_device.c +5
-2-acpi_memory_hotplug_init (&s->container_memhp,OBJECT (dev), - &s->memhp_state,0 ); +memory_region_init (&s->container_memhp,OBJECT (dev),"memhp container" , +MEMORY_HOTPLUG_IO_LEN ); +sysbus_init_mmio (sbd, &s->container_memhp); +acpi_memory_hotplug_init (&s->container_memhp,OBJECT (dev), + &s->memhp_state,0 );memory_region_init_io (&ged_st->regs, obj, &ged_regs_ops, ged_st,TYPE_ACPI_GED "-regs" ,ACPI_GED_REG_COUNT );
Cheers,
Gustavo
RFC 3/24 hw/i386/acpi-build: Fix build_append_notfication_callback typo
In reply to Eric AugerRename build_append_notfication_callback intobuild_append_notification_callback
--- hw/i386/acpi-build.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/i386/acpi-build.c +4 -4
@@ -589,8 +589,8 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus) } } -static bool build_append_notfication_callback (Aml *parent_scope, -const PCIBus *bus) +static bool build_append_notification_callback (Aml *parent_scope, +const PCIBus *bus) {Aml *method;PCIBus *sec;
@@ -604,7 +604,7 @@ static bool build_append_notfication_callback(Aml *parent_scope,continue ; } nr_notifiers = nr_notifiers + -build_append_notfication_callback (br_scope, sec); +build_append_notification_callback (br_scope, sec);/* * add new child scope to parent * and keep track of bus that have PCNT,
@@ -1773,7 +1773,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,PCIBus *b =PCI_HOST_BRIDGE (pci_host)->bus; scope =aml_scope ("\\_SB.PCI0" ); - has_pcnt =build_append_notfication_callback (scope, b); + has_pcnt =build_append_notification_callback (scope, b);if (has_pcnt) {aml_append (dsdt, scope); }
Signature · 1 line
2.49.0
Re: [RFC 03/24] hw/i386/acpi-build: Fix build_append_notfication_callback typo
Hi Eric,
Quoted 33 lines · Eric Auger
Rename
build_append_notfication_callbackintobuild_append_notification_callbackSigned-off-by Eric Auger <[email protected]>--- hw/i386/acpi-build.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)hw/i386/acpi-build.c +3
-3@@ -589,8 +589,8 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus) } } -static bool build_append_notfication_callback (Aml *parent_scope, -const PCIBus *bus) +static bool build_append_notification_callback (Aml *parent_scope, +const PCIBus *bus) {Aml *method;PCIBus *sec;@@ -604,7 +604,7 @@ static bool build_append_notfication_callback(Aml *parent_scope,continue ; } nr_notifiers = nr_notifiers + -build_append_notfication_callback (br_scope, sec); +build_append_notification_callback (br_scope, sec);/* * add new child scope to parent * and keep track of bus that have PCNT,
hw/i386/acpi-build.c build_dsdt(GArray *table_data, BIOSLinker *linker, · line 1779
Quoted 8 lines
hw/i386/acpi-build.c +1
-1@@ -1773,7 +1773,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,PCIBus *b =PCI_HOST_BRIDGE (pci_host)->bus; scope =aml_scope ("\\_SB.PCI0" ); - has_pcnt =build_append_notfication_callback (scope, b); + has_pcnt =build_append_notification_callback (scope, b);if (has_pcnt) {aml_append (dsdt, scope); }
Cheers,
Gustavo
RFC 4/24 hw/i386/acpi-build: Make aml_pci_device_dsm() static
In reply to Eric AugerNo need to export aml_pci_device_dsm() as it is only used in hw/i386/acpi-build.c.
--- include/hw/acpi/pci.h | 1 - hw/i386/acpi-build.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-)
include/hw/acpi/pci.h +0 -1
@@ -36,7 +36,6 @@ typedef struct AcpiMcfgInfo {void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info,const char *oem_id,const char *oem_table_id); -Aml *aml_pci_device_dsm (void );void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus);void build_pci_bridge_aml (AcpiDevAmlIf *adev,Aml *scope);
hw/i386/acpi-build.c +1 -1
@@ -338,7 +338,7 @@ build_facs(GArray *table_data)g_array_append_vals (table_data, reserved,40 );/* Reserved */ } -Aml *aml_pci_device_dsm (void ) +static Aml *aml_pci_device_dsm (void ) {Aml *method;
Signature · 1 line
2.49.0
RFC 5/24 hw/arm/virt: Introduce machine state acpi pcihp flags and props
In reply to Eric Augeracpi_pcihp VirtMachineClass state flag will allow to opt in for acpi pci hotplug. This is guarded by a class no_acpi_pcihp flag to manage compats (<= 10.0 machine types will not support ACPI PCI hotplug).
Machine state acpi_pcihp flag msu be set before the creation of the GED device which will use it.
Currently the ACPI PCI HP is turned off by default. This will change later on for 10.1 machine type.
We also introduce properties to allow disabling it.
--- include/hw/arm/virt.h | 2 ++ hw/arm/virt.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
include/hw/arm/virt.h +2 -0
@@ -135,6 +135,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {
@@ -156,6 +157,7 @@ struct VirtMachineState {bool mte;bool dtb_randomness;bool second_ns_uart_present; +bool acpi_pcihp;OnOffAuto acpi;VirtGICType gic_version;VirtIOMMUType iommu;
hw/arm/virt.c +27 -0
@@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine)create_pcie (vms);if (has_ged && aarch64 && firmware_loaded &&virt_is_acpi_enabled (vms)) { + vms->acpi_pcihp &= !vmc->no_acpi_pcihp; vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }
@@ -2610,6 +2612,20 @@ static void virt_set_its(Object *obj, bool value, Error **errp) vms->its = value; } +static bool virt_get_acpi_pcihp (Object *obj,Error **errp) +{ +VirtMachineState *vms =VIRT_MACHINE (obj); + +return vms->acpi_pcihp; +} + +static void virt_set_acpi_pcihp (Object *obj,bool value,Error **errp) +{ +VirtMachineState *vms =VIRT_MACHINE (obj); + + vms->acpi_pcihp = value; +} +static bool virt_get_dtb_randomness (Object *obj,Error **errp) {VirtMachineState *vms =VIRT_MACHINE (obj);
@@ -3327,6 +3343,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)"in ACPI table header." "The string may be up to 8 bytes in size"); +object_class_property_add_bool (oc,"acpi-pcihp" , + virt_get_acpi_pcihp, virt_set_acpi_pcihp); +object_class_property_set_description (oc,"acpi-pcihp" , +"Force acpi pci hotplug" ); }static void virt_instance_init (Object *obj)
@@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj) } } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;
@@ -3415,8 +3438,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)static void virt_machine_10_0_options (MachineClass *mc) { +VirtMachineClass *vmc =VIRT_MACHINE_CLASS (OBJECT_CLASS (mc)); +virt_machine_10_1_options (mc);compat_props_add (mc->compat_props, hw_compat_10_0, hw_compat_10_0_len); +/* 10.0 and earlier do not support ACPI PCI hotplug */ + vmc->no_acpi_pcihp = true; }DEFINE_VIRT_MACHINE (10 ,0 )
Signature · 1 line
2.49.0
Re: [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Eric,
Quoted 6 lines · Eric Auger
acpi_pcihpVirtMachineClass state flag will allow to opt in for acpi pci hotplug. This is guarded by a classno_acpi_pcihpflag to manage compats (<= 10.0 machine types will not support ACPI PCI hotplug).Machine state
acpi_pcihpflag msu be set before the creation
nit: ^--- must be set
Quoted 70 lines
of the GED device which will use it.
Currently the ACPI PCI HP is turned off by default. This will change later on for 10.1 machine type.
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>--- include/hw/arm/virt.h | 2 ++ hw/arm/virt.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)include/hw/arm/virt.h +2
-0@@ -135,6 +135,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -156,6 +157,7 @@ struct VirtMachineState {bool mte;bool dtb_randomness;bool second_ns_uart_present; +bool acpi_pcihp;OnOffAuto acpi;VirtGICType gic_version;VirtIOMMUType iommu;hw/arm/virt.c +16
-0@@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine)create_pcie (vms);if (has_ged && aarch64 && firmware_loaded &&virt_is_acpi_enabled (vms)) { + vms->acpi_pcihp &= !vmc->no_acpi_pcihp; vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2610,6 +2612,20 @@ static void virt_set_its(Object *obj, bool value, Error **errp) vms->its = value; } +static bool virt_get_acpi_pcihp (Object *obj,Error **errp) +{ +VirtMachineState *vms =VIRT_MACHINE (obj); + +return vms->acpi_pcihp; +} + +static void virt_set_acpi_pcihp (Object *obj,bool value,Error **errp) +{ +VirtMachineState *vms =VIRT_MACHINE (obj); + + vms->acpi_pcihp = value; +} +static bool virt_get_dtb_randomness (Object *obj,Error **errp) {VirtMachineState *vms =VIRT_MACHINE (obj);
hw/arm/virt.c static void virt_machine_class_init(ObjectClass *oc, void *data) · line 3349
Quoted 7 lines
hw/arm/virt.c +4
-0@@ -3327,6 +3343,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)"in ACPI table header." "The string may be up to 8 bytes in size"); +object_class_property_add_bool (oc,"acpi-pcihp" , + virt_get_acpi_pcihp, virt_set_acpi_pcihp); +object_class_property_set_description (oc,"acpi-pcihp" , +"Force acpi pci hotplug" );
How about "Force ACPI PCI hotplug"?
Quoted 16 lines
hw/arm/virt.c +3
-0}static void virt_instance_init (Object *obj)@@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj) } } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3415,8 +3438,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)static void virt_machine_10_0_options (MachineClass *mc)
hw/arm/virt.c DEFINE_VIRT_MACHINE_AS_LATEST(10, 1) · line 3449
Quoted 10 lines
hw/arm/virt.c +4
-0{ +VirtMachineClass *vmc =VIRT_MACHINE_CLASS (OBJECT_CLASS (mc)); +virt_machine_10_1_options (mc);compat_props_add (mc->compat_props, hw_compat_10_0, hw_compat_10_0_len); +/* 10.0 and earlier do not support ACPI PCI hotplug */ + vmc->no_acpi_pcihp = true; }DEFINE_VIRT_MACHINE (10 ,0 )
Otherwise,
Cheers,
Gustavo
Re: [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Gustavo,
Quoted 83 lines · Gustavo Romero
Hi Eric,
Quoted 6 lines · Eric Auger
acpi_pcihpVirtMachineClass state flag will allow to opt in for acpi pci hotplug. This is guarded by a classno_acpi_pcihpflag to manage compats (<= 10.0 machine types will not support ACPI PCI hotplug).Machine state
acpi_pcihpflag msu be set before the creationnit: ^--- must be set
Quoted 71 lines
of the GED device which will use it.
Currently the ACPI PCI HP is turned off by default. This will change later on for 10.1 machine type.
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>---
include/hw/arm/virt.h| 2 ++
hw/arm/virt.c | 27 +++++++++++++++++++++++++++2 files changed, 29 insertions(+)include/hw/arm/virt.h +2
-0@@ -135,6 +135,7 @@ struct VirtMachineClass { bool no_tcg_lpa2; bool no_ns_el2_virt_timer_irq; bool no_nested_smmu; + bool no_acpi_pcihp; }; struct VirtMachineState {@@ -156,6 +157,7 @@ struct VirtMachineState { bool mte; bool dtb_randomness; bool second_ns_uart_present; + bool acpi_pcihp; OnOffAuto acpi; VirtGICType gic_version; VirtIOMMUType iommu;hw/arm/virt.c +0
-0@@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine) create_pcie(vms);if (
has_ged&& aarch64 &&firmware_loaded&&virt_is_acpi_enabled(vms)) {
+vms->acpi_pcihp&= !vmc->no_acpi_pcihp;vms->acpi_dev=create_acpi_ged(vms);
} else {
+vms->acpi_pcihp= false;create_gpio_devices(vms, VIRT_GPIO, sysmem);
}
@@ -2610,6 +2612,20 @@ static voidvirt_set_its(Object *obj, bool value, Error **errp)
vms->its= value;
}
+static boolvirt_get_acpi_pcihp(Object *obj, Error **errp)hw/arm/virt.c +13
-0+{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->acpi_pcihp; +} + +static void virt_set_acpi_pcihp (Object *obj,bool value,Error **errp) +{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + vms->acpi_pcihp = value; +} +static bool
virt_get_dtb_randomness(Object *obj, Error **errp){
VirtMachineState *vms =VIRT_MACHINE(obj);hw/arm/virt.c +0
-0@@ -3327,6 +3343,10 @@ static voidvirt_machine_class_init (ObjectClass *oc, void *data)"in ACPI table header." "The string may be up to
Quoted 8 lines
Quoted 6 lines
8 bytes in size");
+ object_class_property_add_bool(oc, "acpi-pcihp",
+virt_get_acpi_pcihp,virt_set_acpi_pcihp);
+ object_class_property_set_description(oc, "acpi-pcihp", + "Force acpi pci hotplug");How about "Force ACPI PCI hotplug"?
Sure.
Thanks!
Eric
Quoted 34 lines
Quoted 17 lines
}
static voidvirt_instance_init(Object *obj)hw/arm/virt.c +0
-0@@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj) } }+ /* default disallows ACPI PCI hotplug */
+vms->acpi_pcihp= false;
+
/* Default disallows iommu instantiation */vms->iommu=VIRT_IOMMU_NONE;
@@ -3415,8 +3438,12 @@DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)static voidvirt_machine_10_0_options(MachineClass *mc){
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); +Quoted 8 lines
virt_machine_10_1_options(mc);compat_props_add(mc->compat_props, hw_compat_10_0, hw_compat_10_0_len);
+ /* 10.0 and earlier do not support ACPI PCI hotplug */ +vmc->no_acpi_pcihp= true;
}
DEFINE_VIRT_MACHINE(10, 0)Otherwise,
Reviewed-by Gustavo Romero <[email protected]>Cheers,
Gustavo
RFC 6/24 hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
In reply to Eric AugerWe plan to reuse build_x86_acpi_pci_hotplug() implementation for ARM so let's move the code to generic pcihp.
Associated static aml_pci_pdsm() helper is also moved along. build_x86_acpi_pci_hotplug is renamed into build_acpi_pci_hotplug().
No code change intended.
--- hw/i386/acpi-build.h | 4 - include/hw/acpi/pcihp.h | 6 ++ hw/acpi/pcihp.c | 174 +++++++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 150 +--------------------------------- 4 files changed, 181 insertions(+), 153 deletions(-)
hw/i386/acpi-build.h +0 -4
@@ -5,10 +5,6 @@extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; -/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */ -#define ACPI_PCIHP_SEJ_BASE 0x8 -#define ACPI_PCIHP_BNMR_BASE 0x10 -void acpi_setup (void );Object *acpi_get_i386_pci_host (void );
include/hw/acpi/pcihp.h +6 -0
@@ -33,6 +33,10 @@#define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"#define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len" +/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */ +#define ACPI_PCIHP_SEJ_BASE 0x8 +#define ACPI_PCIHP_BNMR_BASE 0x10 + typedef struct AcpiPciHpPciStatus { uint32_t up; uint32_t down;
@@ -69,6 +73,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp); +void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr); +/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);
hw/acpi/pcihp.c +173 -1
186 lines not on this page · raw message
hw/i386/acpi-build.c +2 -148
174 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
Hi Eric,
Quoted 36 lines · Eric Auger
We plan to reuse
build_x86_acpi_pci_hotplug()implementation for ARM so let's move the code to generic pcihp.Associated static
aml_pci_pdsm()helper is also moved along.build_x86_acpi_pci_hotplugis renamed intobuild_acpi_pci_hotplug().No code change intended.
Signed-off-by Eric Auger <[email protected]>--- hw/i386/acpi-build.h | 4 - include/hw/acpi/pcihp.h | 6 ++ hw/acpi/pcihp.c | 174 +++++++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 150 +--------------------------------- 4 files changed, 181 insertions(+), 153 deletions(-)hw/i386/acpi-build.h +0
-4@@ -5,10 +5,6 @@extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; -/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */ -#define ACPI_PCIHP_SEJ_BASE 0x8 -#define ACPI_PCIHP_BNMR_BASE 0x10 -void acpi_setup (void );Object *acpi_get_i386_pci_host (void );include/hw/acpi/pcihp.h +0
-0
include/hw/acpi/pcihp.h line 36
Quoted 4 lines
include/hw/acpi/pcihp.h +1
-0@@ -33,6 +33,10 @@#define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"#define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len" +/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */
This reference needs to be updated to point to acpi_pci_hotplug.rst.
Otherwise,
Cheers,
Gustavo
Quoted 389 lines
include/hw/acpi/pcihp.h +5
-0+#define ACPI_PCIHP_SEJ_BASE 0x8 +#define ACPI_PCIHP_BNMR_BASE 0x10 + typedef struct AcpiPciHpPciStatus { uint32_t up; uint32_t down;@@ -69,6 +73,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp); +void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr); +/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);hw/acpi/pcihp.c +173
-1@@ -26,7 +26,7 @@#include "qemu/osdep.h" #include "hw/acpi/pcihp.h" - +#include "hw/acpi/aml-build.h" #include "hw/pci-host/i440fx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" @@ -513,6 +513,178 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus, OBJ_PROP_FLAG_READ); } +static void build_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar) +{ +Aml *UUID , *ifctx1; +uint8_t byte_list[1 ] = {0 };/* nothing supported yet */ + +aml_append (ctx,aml_store (aml_buffer (1 , byte_list), retvar)); +/* +* PCI Firmware Specification 3.1 +* 4.6. _DSM Definitions for PCI +*/ +UUID =aml_touuid ("E5C937D0-3553-4D7A-9117-EA4D19C3434D" ); + ifctx1 =aml_if (aml_lnot (aml_equal (aml_arg (0 ),UUID ))); + { +/* call is for unsupported UUID, bail out */ +aml_append (ifctx1,aml_return (retvar)); + } +aml_append (ctx, ifctx1); + + ifctx1 =aml_if (aml_lless (aml_arg (1 ),aml_int (2 ))); + { +/* call is for unsupported REV, bail out */ +aml_append (ifctx1,aml_return (retvar)); + } +aml_append (ctx, ifctx1); +} + +static Aml *aml_pci_pdsm (void ) +{ +Aml *method, *ifctx, *ifctx1; +Aml *ret =aml_local (0 ); +Aml *caps =aml_local (1 ); +Aml *acpi_index =aml_local (2 ); +Aml *zero =aml_int (0 ); +Aml *one =aml_int (1 ); +Aml *not_supp =aml_int (0xFFFFFFFF ); +Aml *func =aml_arg (2 ); +Aml *params =aml_arg (4 ); +Aml *bnum =aml_derefof (aml_index (params,aml_int (0 ))); +Aml *sunum =aml_derefof (aml_index (params,aml_int (1 ))); + + method =aml_method ("PDSM" ,5 ,AML_SERIALIZED ); + +/* get supported functions */ + ifctx =aml_if (aml_equal (func, zero)); + { +build_append_pci_dsm_func0_common (ifctx, ret); + +aml_append (ifctx,aml_store (zero, caps)); +aml_append (ifctx, +aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); +/* +* advertise function 7 if device has acpi-index +* acpi_index values: +* 0: not present (default value) +* FFFFFFFF: not supported (old QEMU without PIDX reg) +* other: device's acpi-index +*/ + ifctx1 =aml_if (aml_lnot ( +aml_or (aml_equal (acpi_index, zero), +aml_equal (acpi_index, not_supp),NULL ) + )); + { +/* have supported functions */ +aml_append (ifctx1,aml_or (caps, one, caps)); +/* support for function 7 */ +aml_append (ifctx1, +aml_or (caps,aml_shiftleft (one,aml_int (7 )), caps)); + } +aml_append (ifctx, ifctx1); + +aml_append (ifctx,aml_store (caps,aml_index (ret, zero))); +aml_append (ifctx,aml_return (ret)); + } +aml_append (method, ifctx); + +/* handle specific functions requests */ +/* +* PCI Firmware Specification 3.1 +* 4.6.7. _DSM for Naming a PCI or PCI Express Device Under +* Operating Systems +*/ + ifctx =aml_if (aml_equal (func,aml_int (7 ))); + { +Aml *pkg =aml_package (2 ); + +aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); +aml_append (ifctx,aml_store (pkg, ret)); +/* +* Windows calls func=7 without checking if it's available, +* as workaround Microsoft has suggested to return invalid for func7 +* Package, so return 2 elements package but only initialize elements +* when acpi_index is supported and leave them uninitialized, which +* leads elements to being Uninitialized ObjectType and should trip +* Windows into discarding result as an unexpected and prevent setting +* bogus 'PCI Label' on the device. +*/ + ifctx1 =aml_if (aml_lnot (aml_lor ( +aml_equal (acpi_index, zero),aml_equal (acpi_index, not_supp) + ))); + { +aml_append (ifctx1,aml_store (acpi_index,aml_index (ret, zero))); +/* +* optional, if not impl. should return null string +*/ +aml_append (ifctx1,aml_store (aml_string ("%s" ,"" ), +aml_index (ret, one))); + } +aml_append (ifctx, ifctx1); + +aml_append (ifctx,aml_return (ret)); + } + +aml_append (method, ifctx); +return method; +} + +void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr) +{ +Aml *scope; +Aml *field; +Aml *method; + + scope =aml_scope ("_SB.PCI0" ); + +aml_append (scope, +aml_operation_region ("PCST" ,AML_SYSTEM_IO ,aml_int (pcihp_addr),0x08 )); + field =aml_field ("PCST" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("PCIU" ,32 )); +aml_append (field,aml_named_field ("PCID" ,32 )); +aml_append (scope, field); + +aml_append (scope, +aml_operation_region ("SEJ" ,AML_SYSTEM_IO , +aml_int (pcihp_addr +ACPI_PCIHP_SEJ_BASE ),0x04 )); + field =aml_field ("SEJ" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("B0EJ" ,32 )); +aml_append (scope, field); + +aml_append (scope, +aml_operation_region ("BNMR" ,AML_SYSTEM_IO , +aml_int (pcihp_addr +ACPI_PCIHP_BNMR_BASE ),0x08 )); + field =aml_field ("BNMR" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); +aml_append (field,aml_named_field ("BNUM" ,32 )); +aml_append (field,aml_named_field ("PIDX" ,32 )); +aml_append (scope, field); + +aml_append (scope,aml_mutex ("BLCK" ,0 )); + + method =aml_method ("PCEJ" ,2 ,AML_NOTSERIALIZED ); +aml_append (method,aml_acquire (aml_name ("BLCK" ),0xFFFF )); +aml_append (method,aml_store (aml_arg (0 ),aml_name ("BNUM" ))); +aml_append (method, +aml_store (aml_shiftleft (aml_int (1 ),aml_arg (1 )),aml_name ("B0EJ" ))); +aml_append (method,aml_release (aml_name ("BLCK" ))); +aml_append (method,aml_return (aml_int (0 ))); +aml_append (scope, method); + + method =aml_method ("AIDX" ,2 ,AML_NOTSERIALIZED ); +aml_append (method,aml_acquire (aml_name ("BLCK" ),0xFFFF )); +aml_append (method,aml_store (aml_arg (0 ),aml_name ("BNUM" ))); +aml_append (method, +aml_store (aml_shiftleft (aml_int (1 ),aml_arg (1 )),aml_name ("PIDX" ))); +aml_append (method,aml_store (aml_name ("PIDX" ),aml_local (0 ))); +aml_append (method,aml_release (aml_name ("BLCK" ))); +aml_append (method,aml_return (aml_local (0 ))); +aml_append (scope, method); + +aml_append (scope,aml_pci_pdsm ()); + +aml_append (table, scope); +} +const VMStateDescription vmstate_acpi_pcihp_pci_status = { .name ="acpi_pcihp_pci_status" , .version_id =1 ,hw/i386/acpi-build.c +2
-148@@ -647,96 +647,6 @@ static bool build_append_notification_callback(Aml *parent_scope,return !!nr_notifiers; } -static Aml *aml_pci_pdsm (void ) -{ -Aml *method, *ifctx, *ifctx1; -Aml *ret =aml_local (0 ); -Aml *caps =aml_local (1 ); -Aml *acpi_index =aml_local (2 ); -Aml *zero =aml_int (0 ); -Aml *one =aml_int (1 ); -Aml *not_supp =aml_int (0xFFFFFFFF ); -Aml *func =aml_arg (2 ); -Aml *params =aml_arg (4 ); -Aml *bnum =aml_derefof (aml_index (params,aml_int (0 ))); -Aml *sunum =aml_derefof (aml_index (params,aml_int (1 ))); - - method =aml_method ("PDSM" ,5 ,AML_SERIALIZED ); - -/* get supported functions */ - ifctx =aml_if (aml_equal (func, zero)); - { -build_append_pci_dsm_func0_common (ifctx, ret); - -aml_append (ifctx,aml_store (zero, caps)); -aml_append (ifctx, -aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); -/* -* advertise function 7 if device has acpi-index -* acpi_index values: -* 0: not present (default value) -* FFFFFFFF: not supported (old QEMU without PIDX reg) -* other: device's acpi-index -*/ - ifctx1 =aml_if (aml_lnot ( -aml_or (aml_equal (acpi_index, zero), -aml_equal (acpi_index, not_supp),NULL ) - )); - { -/* have supported functions */ -aml_append (ifctx1,aml_or (caps, one, caps)); -/* support for function 7 */ -aml_append (ifctx1, -aml_or (caps,aml_shiftleft (one,aml_int (7 )), caps)); - } -aml_append (ifctx, ifctx1); - -aml_append (ifctx,aml_store (caps,aml_index (ret, zero))); -aml_append (ifctx,aml_return (ret)); - } -aml_append (method, ifctx); - -/* handle specific functions requests */ -/* -* PCI Firmware Specification 3.1 -* 4.6.7. _DSM for Naming a PCI or PCI Express Device Under -* Operating Systems -*/ - ifctx =aml_if (aml_equal (func,aml_int (7 ))); - { -Aml *pkg =aml_package (2 ); - -aml_append (ifctx,aml_store (aml_call2 ("AIDX" , bnum, sunum), acpi_index)); -aml_append (ifctx,aml_store (pkg, ret)); -/* -* Windows calls func=7 without checking if it's available, -* as workaround Microsoft has suggested to return invalid for func7 -* Package, so return 2 elements package but only initialize elements -* when acpi_index is supported and leave them uninitialized, which -* leads elements to being Uninitialized ObjectType and should trip -* Windows into discarding result as an unexpected and prevent setting -* bogus 'PCI Label' on the device. -*/ - ifctx1 =aml_if (aml_lnot (aml_lor ( -aml_equal (acpi_index, zero),aml_equal (acpi_index, not_supp) - ))); - { -aml_append (ifctx1,aml_store (acpi_index,aml_index (ret, zero))); -/* -* optional, if not impl. should return null string -*/ -aml_append (ifctx1,aml_store (aml_string ("%s" ,"" ), -aml_index (ret, one))); - } -aml_append (ifctx, ifctx1); - -aml_append (ifctx,aml_return (ret)); - } - -aml_append (method, ifctx); -return method; -} -/* * build_prt - Define interrupt routing rules * @@ -1227,62 +1137,6 @@ static Aml *build_q35_dram_controller(const AcpiMcfgInfo *mcfg)return dev; } -static void build_x86_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr) -{ -Aml *scope; -Aml *field; -Aml *method; - - scope =aml_scope ("_SB.PCI0" ); - -aml_append (scope, -aml_operation_region ("PCST" ,AML_SYSTEM_IO ,aml_int (pcihp_addr),0x08 )); - field =aml_field ("PCST" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_named_field ("PCIU" ,32 )); -aml_append (field,aml_named_field ("PCID" ,32 )); -aml_append (scope, field); - -aml_append (scope, -aml_operation_region ("SEJ" ,AML_SYSTEM_IO , -aml_int (pcihp_addr +ACPI_PCIHP_SEJ_BASE ),0x04 )); - field =aml_field ("SEJ" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_named_field ("B0EJ" ,32 )); -aml_append (scope, field); - -aml_append (scope, -aml_operation_region ("BNMR" ,AML_SYSTEM_IO , -aml_int (pcihp_addr +ACPI_PCIHP_BNMR_BASE ),0x08 )); - field =aml_field ("BNMR" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS ); -aml_append (field,aml_named_field ("BNUM" ,32 )); -aml_append (field,aml_named_field ("PIDX" ,32 )); -aml_append (scope, field); - -aml_append (scope,aml_mutex ("BLCK" ,0 )); - - method =aml_method ("PCEJ" ,2 ,AML_NOTSERIALIZED ); -aml_append (method,aml_acquire (aml_name ("BLCK" ),0xFFFF )); -aml_append (method,aml_store (aml_arg (0 ),aml_name ("BNUM" ))); -aml_append (method, -aml_store (aml_shiftleft (aml_int (1 ),aml_arg (1 )),aml_name ("B0EJ" ))); -aml_append (method,aml_release (aml_name ("BLCK" ))); -aml_append (method,aml_return (aml_int (0 ))); -aml_append (scope, method); - - method =aml_method ("AIDX" ,2 ,AML_NOTSERIALIZED ); -aml_append (method,aml_acquire (aml_name ("BLCK" ),0xFFFF )); -aml_append (method,aml_store (aml_arg (0 ),aml_name ("BNUM" ))); -aml_append (method, -aml_store (aml_shiftleft (aml_int (1 ),aml_arg (1 )),aml_name ("PIDX" ))); -aml_append (method,aml_store (aml_name ("PIDX" ),aml_local (0 ))); -aml_append (method,aml_release (aml_name ("BLCK" ))); -aml_append (method,aml_return (aml_local (0 ))); -aml_append (scope, method); - -aml_append (scope,aml_pci_pdsm ()); - -aml_append (table, scope); -} -static Aml *build_q35_osc_method (bool enable_native_pcie_hotplug) {Aml *if_ctx;@@ -1394,7 +1248,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dsdt, sb_scope);if (pm->pcihp_bridge_en || pm->pcihp_root_en) { -build_x86_acpi_pci_hotplug (dsdt, pm->pcihp_io_base); +build_acpi_pci_hotplug (dsdt, pm->pcihp_io_base); }build_piix4_pci0_int (dsdt); }else if (q35) {@@ -1438,7 +1292,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dsdt, sb_scope);if (pm->pcihp_bridge_en) { -build_x86_acpi_pci_hotplug (dsdt, pm->pcihp_io_base); +build_acpi_pci_hotplug (dsdt, pm->pcihp_io_base); }build_q35_pci0_int (dsdt); }
Re: [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
Quoted 35 lines · Gustavo Romero
Hi Eric,
Quoted 32 lines · Eric Auger
We plan to reuse
build_x86_acpi_pci_hotplug()implementation for ARM so let's move the code to generic pcihp.Associated static
aml_pci_pdsm()helper is also moved along.build_x86_acpi_pci_hotplugis renamed intobuild_acpi_pci_hotplug().No code change intended.
Signed-off-by Eric Auger <[email protected]>---
hw/i386/acpi-build.h | 4 -
include/hw/acpi/pcihp.h| 6 ++
hw/acpi/pcihp.c | 174 +++++++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 150 +---------------------------------4 files changed, 181 insertions(+), 153 deletions(-)hw/i386/acpi-build.h +0
-0@@ -5,10 +5,6 @@ extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;-/* PCI Hot-plug registers bases. See
docs/spec/acpi_pci_hotplug.txt*/hw/i386/acpi-build.h +0
-3-#define ACPI_PCIHP_SEJ_BASE 0x8 -#define ACPI_PCIHP_BNMR_BASE 0x10 -void
acpi_setup(void);
Object*acpi_get_i386_pci_host(void);
diff --gita/include/hw/acpi/pcihp.hb/include/hw/acpi/pcihp.hindexac21a95913..2da0bc45c9100644
---a/include/hw/acpi/pcihp.h
Quoted 8 lines
Quoted 6 lines
+++
b/include/hw/acpi/pcihp.hhw/i386/acpi-build.h +0
-0@@ -33,6 +33,10 @@ #define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base" #define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len"+/* PCI Hot-plug registers bases. See
docs/spec/acpi_pci_hotplug.txt*/This reference needs to be updated to point to
acpi_pci_hotplug.rst.
fixed here and above in the file
Thanks!
Eric
Quoted 429 lines
Otherwise,
Reviewed-by Gustavo Romero <[email protected]>Cheers,
GustavoQuoted 419 lines
hw/i386/acpi-build.h +3
-0+#define ACPI_PCIHP_SEJ_BASE 0x8 +#define ACPI_PCIHP_BNMR_BASE 0x10 +typedef struct AcpiPciHpPciStatus {
uint32_tup;
uint32_tdown;hw/i386/acpi-build.h +1
-0@@ -69,6 +73,8 @@ voidacpi_pcihp_device_unplug_request_cb (HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp); +void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr); + /* Called on reset */void
acpi_pcihp_reset(AcpiPciHpState *s);
diff --gita/hw/acpi/pcihp.cb/hw/acpi/pcihp.c
index5f79c9016b..35d8c0bfd2100644hw/acpi/pcihp.c +90
-1@@ -26,7 +26,7 @@ #include "qemu/osdep.h" #include "hw/acpi/pcihp.h" - +#include "hw/acpi/aml-build.h" #include "hw/pci-host/i440fx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h"@@ -513,6 +513,178 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus, OBJ_PROP_FLAG_READ); } +static void build_append_pci_dsm_func0_common(Aml *ctx, Aml *retvar) +{ + Aml *UUID, *ifctx1; + uint8_t byte_list[1] = { 0 }; /* nothing supported yet */ + + aml_append(ctx, aml_store(aml_buffer(1, byte_list), retvar)); + /* + * PCI Firmware Specification 3.1 + * 4.6. _DSM Definitions for PCI + */ + UUID = aml_touuid("E5C937D0-3553-4D7A-9117-EA4D19C3434D"); + ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(0), UUID))); + { + /* call is for unsupported UUID, bail out */ + aml_append(ifctx1, aml_return(retvar)); + } + aml_append(ctx, ifctx1); + + ifctx1 = aml_if(aml_lless(aml_arg(1), aml_int(2))); + { + /* call is for unsupported REV, bail out */ + aml_append(ifctx1, aml_return(retvar)); + } + aml_append(ctx, ifctx1); +} + +static Aml *aml_pci_pdsm (void ) +{ + Aml *method, *ifctx, *ifctx1; + Aml *ret = aml_local(0); + Aml *caps = aml_local(1); + Aml *acpi_index = aml_local(2); + Aml *zero = aml_int(0); + Aml *one = aml_int(1); + Aml *not_supp = aml_int(0xFFFFFFFF); + Aml *func = aml_arg(2); + Aml *params = aml_arg(4); + Aml *bnum = aml_derefof(aml_index(params, aml_int(0))); + Aml *sunum = aml_derefof(aml_index(params, aml_int(1))); + + method = aml_method("PDSM", 5, AML_SERIALIZED); + + /* get supported functions */ + ifctx = aml_if(aml_equal(func, zero)); + { + build_append_pci_dsm_func0_common(ifctx, ret); + + aml_append(ifctx, aml_store(zero, caps)); + aml_append(ifctx, + aml_store(aml_call2("AIDX", bnum, sunum), acpi_index)); + /* + * advertise function 7 if device has acpi-index + * acpi_index values: + * 0: not present (default value) + * FFFFFFFF: not supported (old QEMU without PIDX reg) + * other: device's acpi-index + */ + ifctx1 = aml_if(aml_lnot( + aml_or(aml_equal(acpi_index, zero), + aml_equal(acpi_index, not_supp), NULL) + )); + { + /* have supported functions */ + aml_append(ifctx1, aml_or(caps, one, caps)); + /* support for function 7 */ + aml_append(ifctx1, + aml_or(caps, aml_shiftleft(one, aml_int(7)), caps)); + } + aml_append(ifctx, ifctx1); + + aml_append(ifctx, aml_store(caps, aml_index(ret, zero))); + aml_append(ifctx, aml_return(ret)); + } + aml_append(method, ifctx); + + /* handle specific functions requests */ + /* + * PCI Firmware Specification 3.1 + * 4.6.7. _DSM for Naming a PCI or PCI Express Device Under + * Operating Systems + */ + ifctx = aml_if(aml_equal(func, aml_int(7))); + { + Aml *pkg = aml_package(2); + + aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum), acpi_index)); + aml_append(ifctx, aml_store(pkg, ret)); + /* +* Windows calls func=7 without checking if it's available, +* as workaround Microsoft has suggested to return invalid for func7
+ * Package, so return 2 elements package but only initialize elements
+ * whenacpi_indexis supported and leave them uninitialized, which
+ * leads elements to being Uninitialized ObjectType and should trip
+ * Windows into discarding result as an unexpected and prevent setting
+ * bogus 'PCI Label' on the device.
+ */
+ ifctx1 = aml_if(aml_lnot(aml_lor(
+aml_equal(acpi_index, zero),aml_equal(acpi_index, not_supp)
+ )));
+ {
+aml_append(ifctx1, aml_store(acpi_index, aml_index(ret, zero)));
+ /*
+ * optional, if not impl. should return null string + */
+ aml_append(ifctx1, aml_store(aml_string("%s", ""), +aml_index(ret, one))); + }
+aml_append(ifctx, ifctx1);hw/acpi/pcihp.c +18
-0+ + aml_append(ifctx, aml_return(ret)); + } + + aml_append(method, ifctx); + return method; +} + +void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr) +{ + Aml *scope; + Aml *field; + Aml *method; + + scope = aml_scope("_SB.PCI0"); + + aml_append(scope, + aml_operation_region("PCST", AML_SYSTEM_IO,
aml_int(pcihp_addr),0x08));
+ field =aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
+aml_append(field, aml_named_field("PCIU", 32)); +aml_append(field, aml_named_field("PCID", 32)); +aml_append(scope, field);
+
+ aml_append(scope,
+ aml_operation_region("SEJ",AML_SYSTEM_IO, +aml_int(pcihp_addr + ACPI_PCIHP_SEJ_BASE),0x04));
+ field =aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
+aml_append(field, aml_named_field("B0EJ", 32)); +aml_append(scope, field);
+
+ aml_append(scope,
+ aml_operation_region("BNMR",AML_SYSTEM_IO, +aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE),0x08));
+ field =aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
+aml_append(field, aml_named_field("BNUM", 32)); +aml_append(field, aml_named_field("PIDX", 32)); +aml_append(scope, field);hw/acpi/pcihp.c +8
-0+ + aml_append(scope, aml_mutex("BLCK", 0)); + + method = aml_method("PCEJ", 2, AML_NOTSERIALIZED); + aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF)); + aml_append(method, aml_store(aml_arg(0), aml_name("BNUM"))); + aml_append(method, + aml_store(aml_shiftleft(aml_int(1), aml_arg(1)),
aml_name("B0EJ")));
+aml_append(method, aml_release(aml_name("BLCK"))); +aml_append(method, aml_return(aml_int(0)));
+aml_append(scope, method);
+
+ method =aml_method("AIDX", 2, AML_NOTSERIALIZED); +aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF)); +aml_append(method, aml_store(aml_arg(0), aml_name("BNUM"))); + aml_append(method,
+aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("PIDX")));
+aml_append(method, aml_store(aml_name("PIDX"), aml_local(0))); +aml_append(method, aml_release(aml_name("BLCK"))); +aml_append(method, aml_return(aml_local(0)));
+aml_append(scope, method);hw/acpi/pcihp.c +6
-0+ + aml_append(scope, aml_pci_pdsm()); + + aml_append(table, scope); +} +const VMStateDescription
vmstate_acpi_pcihp_pci_status= { .name = "acpi_pcihp_pci_status",
.version_id = 1,hw/i386/acpi-build.c +0
-63@@ -647,96 +647,6 @@ static boolbuild_append_notification_callback (Aml *parent_scope, return !!nr_notifiers; } -static Aml *aml_pci_pdsm(void) -{ - Aml *method, *ifctx, *ifctx1; - Aml *ret = aml_local(0); - Aml *caps = aml_local(1); - Aml *acpi_index = aml_local(2); - Aml *zero = aml_int(0); - Aml *one = aml_int(1); - Aml *not_supp = aml_int(0xFFFFFFFF); - Aml *func = aml_arg(2); - Aml *params = aml_arg(4); - Aml *bnum = aml_derefof(aml_index(params, aml_int(0))); - Aml *sunum = aml_derefof(aml_index(params, aml_int(1))); - - method = aml_method("PDSM", 5, AML_SERIALIZED); - - /* get supported functions */ - ifctx = aml_if(aml_equal(func, zero)); - { - build_append_pci_dsm_func0_common(ifctx, ret); - - aml_append(ifctx, aml_store(zero, caps)); - aml_append(ifctx, - aml_store(aml_call2("AIDX", bnum, sunum), acpi_index)); - /* - * advertise function 7 if device has acpi-index - * acpi_index values: - * 0: not present (default value) - * FFFFFFFF: not supported (old QEMU without PIDX reg) - * other: device's acpi-index - */ - ifctx1 = aml_if(aml_lnot( - aml_or(aml_equal(acpi_index, zero), - aml_equal(acpi_index, not_supp), NULL) - )); - { - /* have supported functions */ - aml_append(ifctx1, aml_or(caps, one, caps)); - /* support for function 7 */ - aml_append(ifctx1, - aml_or(caps, aml_shiftleft(one, aml_int(7)), caps)); - } - aml_append(ifctx, ifctx1); - - aml_append(ifctx, aml_store(caps, aml_index(ret, zero))); - aml_append(ifctx, aml_return(ret)); - } - aml_append(method, ifctx); - - /* handle specific functions requests */ - /* - * PCI Firmware Specification 3.1 - * 4.6.7. _DSM for Naming a PCI or PCI Express Device Under - * Operating Systems - */ - ifctx = aml_if(aml_equal(func, aml_int(7))); - { - Aml *pkg = aml_package(2); - - aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum), acpi_index)); - aml_append(ifctx, aml_store(pkg, ret)); - /* -* Windows calls func=7 without checking if it's available, -* as workaround Microsoft has suggested to return invalid for func7
- * Package, so return 2 elements package but only initialize elements
- * whenacpi_indexis supported and leave them uninitialized, which
- * leads elements to being Uninitialized ObjectType and should trip
- * Windows into discarding result as an unexpected and prevent setting
- * bogus 'PCI Label' on the device.
- */
- ifctx1 = aml_if(aml_lnot(aml_lor(
-aml_equal(acpi_index, zero),aml_equal(acpi_index, not_supp)
- )));
- {
-aml_append(ifctx1, aml_store(acpi_index, aml_index(ret, zero)));
- /*
- * optional, if not impl. should return null string - */
- aml_append(ifctx1, aml_store(aml_string("%s", ""), -aml_index(ret, one))); - }
-aml_append(ifctx, ifctx1);hw/i386/acpi-build.c +0
-8- - aml_append(ifctx, aml_return(ret)); - } - - aml_append(method, ifctx); - return method; -} -/*
*build_prt- Define interrupt routing rules
*hw/i386/acpi-build.c +0
-0@@ -1227,62 +1137,6 @@ static Aml *build_q35_dram_controller(const AcpiMcfgInfo *mcfg) return dev; }-static void
build_x86_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr)hw/i386/acpi-build.c +0
-9-{ - Aml *scope; - Aml *field; - Aml *method; - - scope = aml_scope("_SB.PCI0"); - - aml_append(scope, - aml_operation_region("PCST", AML_SYSTEM_IO,
aml_int(pcihp_addr),0x08));
- field =aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
-aml_append(field, aml_named_field("PCIU", 32)); -aml_append(field, aml_named_field("PCID", 32)); -aml_append(scope, field);
-
- aml_append(scope,
- aml_operation_region("SEJ",AML_SYSTEM_IO, -aml_int(pcihp_addr + ACPI_PCIHP_SEJ_BASE),0x04));
- field =aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
-aml_append(field, aml_named_field("B0EJ", 32)); -aml_append(scope, field);
-
- aml_append(scope,
- aml_operation_region("BNMR",AML_SYSTEM_IO, -aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE),0x08));
- field =aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
-aml_append(field, aml_named_field("BNUM", 32)); -aml_append(field, aml_named_field("PIDX", 32)); -aml_append(scope, field);hw/i386/acpi-build.c +0
-8- - aml_append(scope, aml_mutex("BLCK", 0)); - - method = aml_method("PCEJ", 2, AML_NOTSERIALIZED); - aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF)); - aml_append(method, aml_store(aml_arg(0), aml_name("BNUM"))); - aml_append(method, - aml_store(aml_shiftleft(aml_int(1), aml_arg(1)),
aml_name("B0EJ")));
-aml_append(method, aml_release(aml_name("BLCK"))); -aml_append(method, aml_return(aml_int(0)));
-aml_append(scope, method);
-
- method =aml_method("AIDX", 2, AML_NOTSERIALIZED); -aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF)); -aml_append(method, aml_store(aml_arg(0), aml_name("BNUM"))); - aml_append(method,
-aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("PIDX")));
-aml_append(method, aml_store(aml_name("PIDX"), aml_local(0))); -aml_append(method, aml_release(aml_name("BLCK"))); -aml_append(method, aml_return(aml_local(0)));
-aml_append(scope, method);hw/i386/acpi-build.c +0
-6- - aml_append(scope, aml_pci_pdsm()); - - aml_append(table, scope); -} -static Aml *build_q35_osc_method(bool
enable_native_pcie_hotplug) {
Aml*if_ctx;hw/i386/acpi-build.c +2
-2@@ -1394,7 +1248,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, aml_append(dsdt, sb_scope); if (pm->pcihp_bridge_en || pm->pcihp_root_en) { - build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base); + build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base); } build_piix4_pci0_int(dsdt); } else if (q35) {@@ -1438,7 +1292,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, aml_append(dsdt, sb_scope); if (pm->pcihp_bridge_en) { - build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base); + build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base); } build_q35_pci0_int(dsdt); }
RFC 7/24 hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
In reply to Eric AugerAdd a new argument to acpi_dsdt_add_pci_osc to be able to disable native pci hotplug.
--- hw/pci-host/gpex-acpi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
hw/pci-host/gpex-acpi.c +6 -5
@@ -50,7 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static void acpi_dsdt_add_pci_osc (Aml *dev) +static void acpi_dsdt_add_pci_osc (Aml *dev,bool enable_native_pcie_hotplug) {Aml *method, *UUID , *ifctx, *ifctx1, *elsectx, *buf;
@@ -80,8 +80,9 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)* Allow OS control for all 5 features: * PCIeHotplug SHPCHotplug PME AER PCIeCapability. */ -aml_append (ifctx,aml_and (aml_name ("CTRL" ),aml_int (0x1F ), -aml_name ("CTRL" ))); +aml_append (ifctx,aml_and (aml_name ("CTRL" ), +aml_int (0x1E | (enable_native_pcie_hotplug ?0x1 :0x0 )), +aml_name ("CTRL" ))); ifctx1 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (0x1 )))); aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08),
@@ -192,7 +193,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev); }else { -acpi_dsdt_add_pci_osc (dev); +acpi_dsdt_add_pci_osc (dev, true); }aml_append (scope, dev);
@@ -267,7 +268,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) }aml_append (dev,aml_name_decl ("_CRS" , rbuf)); -acpi_dsdt_add_pci_osc (dev); +acpi_dsdt_add_pci_osc (dev, true);Aml *dev_res0 =aml_device ("%s" ,"RES0" );aml_append (dev_res0,aml_name_decl ("_HID" ,aml_string ("PNP0C02" )));
Signature · 1 line
2.49.0
Re: [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
Hi Eric,
Quoted 22 lines · Eric Auger
Add a new argument to
acpi_dsdt_add_pci_oscto be able to disable native pci hotplug.Signed-off-by Eric Auger <[email protected]>--- hw/pci-host/gpex-acpi.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)hw/pci-host/gpex-acpi.c +1
-1@@ -50,7 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static void acpi_dsdt_add_pci_osc (Aml *dev) +static void acpi_dsdt_add_pci_osc (Aml *dev,bool enable_native_pcie_hotplug) {Aml *method, *UUID , *ifctx, *ifctx1, *elsectx, *buf;
hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_pci_osc(Aml *dev) · line 81
Quoted 2 lines
hw/pci-host/gpex-acpi.c +0
-0@@ -80,8 +80,9 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)* Allow OS control for all 5 features: * PCIeHotplug SHPCHotplug PME AER PCIeCapability.
This comment is no longer true for PCIeHotplug, which now can be controlled by the platform, and so needs to be updated, although it's going to go away in the series.
Otherwise:
Cheers,
Gustavo
Quoted 27 lines
hw/pci-host/gpex-acpi.c +5
-4*/ -aml_append (ifctx,aml_and (aml_name ("CTRL" ),aml_int (0x1F ), -aml_name ("CTRL" ))); +aml_append (ifctx,aml_and (aml_name ("CTRL" ), +aml_int (0x1E | (enable_native_pcie_hotplug ?0x1 :0x0 )), +aml_name ("CTRL" ))); ifctx1 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (0x1 )))); aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08),@@ -192,7 +193,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev); }else { -acpi_dsdt_add_pci_osc (dev); +acpi_dsdt_add_pci_osc (dev, true); }aml_append (scope, dev);@@ -267,7 +268,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) }aml_append (dev,aml_name_decl ("_CRS" , rbuf)); -acpi_dsdt_add_pci_osc (dev); +acpi_dsdt_add_pci_osc (dev, true);Aml *dev_res0 =aml_device ("%s" ,"RES0" );aml_append (dev_res0,aml_name_decl ("_HID" ,aml_string ("PNP0C02" )));
Re: [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
Quoted 23 lines · Gustavo Romero
Hi Eric,
Quoted 20 lines · Eric Auger
Add a new argument to
acpi_dsdt_add_pci_oscto be able to disable native pci hotplug.Signed-off-by Eric Auger <[email protected]>---
hw/pci-host/gpex-acpi.c| 11 ++++++-----1 file changed, 6 insertions(+), 5 deletions(-)hw/pci-host/gpex-acpi.c +1
-0@@ -50,7 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static void acpi_dsdt_add_pci_osc(Aml *dev) +static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) {
Quoted 8 lines
Quoted 4 lines
Aml *method, *UUID, *ifctx, *ifctx1, *elsectx, *buf; @@ -80,8 +80,9 @@ static void
acpi_dsdt_add_pci_osc(Aml *dev)
* Allow OS control for all 5 features:
* PCIeHotplug SHPCHotplug PME AER PCIeCapability.This comment is no longer true for PCIeHotplug, which now can be controlled by the platform, and so needs to be updated, although it's going to go away in the series.
Sure, replaced by
+ * Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, + * and PCIeHotplug depending on enable_native_pcie_hotplug
Quoted 4 lines
Otherwise:Reviewed-by Gustavo Romero <[email protected]>
thanks!
Eric
Quoted 33 lines
Cheers,
GustavoQuoted 27 lines
*/
- aml_append(ifctx, aml_and(aml_name("CTRL"),aml_int(0x1F), -aml_name("CTRL")));
+ aml_append(ifctx, aml_and(aml_name("CTRL"),
+ aml_int(0x1E | (enable_native_pcie_hotplug?0x1:0x0)),
+aml_name("CTRL")));
ifctx1 =aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1)))); aml_append(ifctx1, aml_or(aml_name("CDW1"),aml_int(0x08),hw/pci-host/gpex-acpi.c +2
-1@@ -192,7 +193,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) if (is_cxl) { build_cxl_osc_method(dev); } else { - acpi_dsdt_add_pci_osc(dev); + acpi_dsdt_add_pci_osc(dev, true); } aml_append(scope, dev);@@ -267,7 +268,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) } aml_append(dev, aml_name_decl("_CRS", rbuf)); - acpi_dsdt_add_pci_osc(dev); + acpi_dsdt_add_pci_osc(dev, true); Aml *dev_res0 = aml_device("%s", "RES0"); aml_append(dev_res0, aml_name_decl("_HID",
aml_string("PNP0C02")));
RFC 8/24 hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
In reply to Eric Augeracpi_dsdt_add_pci_osc() name is confusing as it gives the impression it appends the _OSC method but in fact it also appends the _DSM method for the host bridge. Let's split the function into two separate ones and let them return the method Aml pointer instead. This matches the way it is done on x86 (build_q35_osc_method). In a subsequent patch we will replace the gpex method by the q35 implementation that will become shared between ARM and x86.
acpi_dsdt_add_host_bridge_methods is a new top helper that generates both the _OSC and _DSM methods.
--- hw/pci-host/gpex-acpi.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)
hw/pci-host/gpex-acpi.c +21 -10
@@ -50,13 +50,10 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static void acpi_dsdt_add_pci_osc (Aml *dev,bool enable_native_pcie_hotplug) +static Aml *build_host_bridge_osc (bool enable_native_pcie_hotplug) { -Aml *method, *UUID , *ifctx, *ifctx1, *elsectx, *buf; +Aml *method, *UUID , *ifctx, *ifctx1, *elsectx; -/* Declare an _OSC (OS Control Handoff) method */ -aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 ))); -aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED );aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" ));
@@ -103,9 +100,13 @@ static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) aml_name("CDW1")));aml_append (elsectx,aml_return (aml_arg (3 )));aml_append (method, elsectx); -aml_append (dev, method); +return method; +} - method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED ); +static Aml *build_host_bridge_dsm (void ) +{ +Aml *method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED ); +Aml *UUID , *ifctx, *ifctx1, *buf;/* PCI Firmware Specification 3.0 * 4.6.1. _DSM for PCI Express Slot Information
@@ -124,7 +125,17 @@ static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) byte_list[0 ] =0 ; buf =aml_buffer (1 , byte_list);aml_append (method,aml_return (buf)); -aml_append (dev, method); +return method; +} + +static void acpi_dsdt_add_host_bridge_methods (Aml *dev, +bool enable_native_pcie_hotplug) +{ +aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); +/* Declare an _OSC (OS Control Handoff) method */ +aml_append (dev,build_host_bridge_osc (enable_native_pcie_hotplug)); +aml_append (dev,build_host_bridge_dsm ()); }void acpi_dsdt_add_gpex (Aml *scope,struct GPEXConfig *cfg)
@@ -193,7 +204,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev); }else { -acpi_dsdt_add_pci_osc (dev, true); +acpi_dsdt_add_host_bridge_methods (dev, true); }aml_append (scope, dev);
@@ -268,7 +279,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) }aml_append (dev,aml_name_decl ("_CRS" , rbuf)); -acpi_dsdt_add_pci_osc (dev, true); +acpi_dsdt_add_host_bridge_methods (dev, true);Aml *dev_res0 =aml_device ("%s" ,"RES0" );aml_append (dev_res0,aml_name_decl ("_HID" ,aml_string ("PNP0C02" )));
Signature · 1 line
2.49.0
Re: [RFC 08/24] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
Hi Eric,
Quoted 81 lines · Eric Auger
acpi_dsdt_add_pci_osc()name is confusing as it gives the impression it appends the_OSCmethod but in fact it also appends the_DSMmethod for the host bridge. Let's split the function into two separate ones and let them return the method Aml pointer instead. This matches the way it is done on x86 (build_q35_osc_method). In a subsequent patch we will replace the gpex method by the q35 implementation that will become shared between ARM and x86.
acpi_dsdt_add_host_bridge_methodsis a new top helper that generates both the_OSCand_DSMmethods.Signed-off-by Eric Auger <[email protected]>--- hw/pci-host/gpex-acpi.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)hw/pci-host/gpex-acpi.c +20
-9@@ -50,13 +50,10 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static void acpi_dsdt_add_pci_osc (Aml *dev,bool enable_native_pcie_hotplug) +static Aml *build_host_bridge_osc (bool enable_native_pcie_hotplug) { -Aml *method, *UUID , *ifctx, *ifctx1, *elsectx, *buf; +Aml *method, *UUID , *ifctx, *ifctx1, *elsectx; -/* Declare an _OSC (OS Control Handoff) method */ -aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 ))); -aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED );aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" ));@@ -103,9 +100,13 @@ static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) aml_name("CDW1")));aml_append (elsectx,aml_return (aml_arg (3 )));aml_append (method, elsectx); -aml_append (dev, method); +return method; +} - method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED ); +static Aml *build_host_bridge_dsm (void ) +{ +Aml *method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED ); +Aml *UUID , *ifctx, *ifctx1, *buf;/* PCI Firmware Specification 3.0 * 4.6.1. _DSM for PCI Express Slot Information @@ -124,7 +125,17 @@ static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) byte_list[0 ] =0 ; buf =aml_buffer (1 , byte_list);aml_append (method,aml_return (buf)); -aml_append (dev, method); +return method; +} + +static void acpi_dsdt_add_host_bridge_methods (Aml *dev, +bool enable_native_pcie_hotplug) +{ +aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 ))); +aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 ))); +/* Declare an _OSC (OS Control Handoff) method */ +aml_append (dev,build_host_bridge_osc (enable_native_pcie_hotplug)); +aml_append (dev,build_host_bridge_dsm ()); }void acpi_dsdt_add_gpex (Aml *scope,struct GPEXConfig *cfg)@@ -193,7 +204,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev); }else { -acpi_dsdt_add_pci_osc (dev, true); +acpi_dsdt_add_host_bridge_methods (dev, true); }aml_append (scope, dev);
hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 285
Quoted 8 lines
hw/pci-host/gpex-acpi.c +1
-1@@ -268,7 +279,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) }aml_append (dev,aml_name_decl ("_CRS" , rbuf)); -acpi_dsdt_add_pci_osc (dev, true); +acpi_dsdt_add_host_bridge_methods (dev, true);Aml *dev_res0 =aml_device ("%s" ,"RES0" );aml_append (dev_res0,aml_name_decl ("_HID" ,aml_string ("PNP0C02" )));
Cheers,
Gustavo
RFC 9/24 hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
In reply to Eric AugerPropagate the type of pci hotplug mode downto the gpex acpi code. In case machine acpi_pcihp is unset we configure pci native hotplug on pci0. For expander bridges we keep legacy pci native hotplug, as done on x86 q35.
--- include/hw/pci-host/gpex.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/pci-host/gpex-acpi.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)
include/hw/pci-host/gpex.h +1 -0
@@ -45,6 +45,7 @@ struct GPEXConfig {MemMapEntry pio;int irq;PCIBus *bus; +bool pci_native_hotplug; };typedef struct GPEXIrq GPEXIrq ;
hw/arm/virt-acpi-build.c +1 -0
@@ -129,6 +129,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, .ecam = memmap[ecam_id], .irq = irq, .bus = vms->bus, + .pci_native_hotplug = !vms->acpi_pcihp, };if (vms->highmem_mmio) {
hw/pci-host/gpex-acpi.c +2 -1
@@ -204,6 +204,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev); }else { +/* pxb bridges do not have ACPI PCI Hot-plug enabled */ acpi_dsdt_add_host_bridge_methods (dev, true); }
@@ -279,7 +280,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) }aml_append (dev,aml_name_decl ("_CRS" , rbuf)); -acpi_dsdt_add_host_bridge_methods (dev, true); +acpi_dsdt_add_host_bridge_methods (dev, cfg->pci_native_hotplug);Aml *dev_res0 =aml_device ("%s" ,"RES0" );aml_append (dev_res0,aml_name_decl ("_HID" ,aml_string ("PNP0C02" )));
Signature · 1 line
2.49.0
Re: [RFC 09/24] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
Hi Eric,
Quoted 49 lines · Eric Auger
Propagate the type of pci hotplug mode downto the gpex acpi code. In case machine
acpi_pcihpis unset we configure pci native hotplug on pci0. For expander bridges we keep legacy pci native hotplug, as done on x86 q35.Signed-off-by Eric Auger <[email protected]>--- include/hw/pci-host/gpex.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/pci-host/gpex-acpi.c | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-)include/hw/pci-host/gpex.h +1
-0@@ -45,6 +45,7 @@ struct GPEXConfig {MemMapEntry pio;int irq;PCIBus *bus; +bool pci_native_hotplug; };typedef struct GPEXIrq GPEXIrq ;hw/arm/virt-acpi-build.c +1
-0@@ -129,6 +129,7 @@ static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap, .ecam = memmap[ecam_id], .irq = irq, .bus = vms->bus, + .pci_native_hotplug = !vms->acpi_pcihp, };if (vms->highmem_mmio) {hw/pci-host/gpex-acpi.c +1
-0@@ -204,6 +204,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev); }else { +/* pxb bridges do not have ACPI PCI Hot-plug enabled */ acpi_dsdt_add_host_bridge_methods (dev, true); }
hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 286
Quoted 8 lines
hw/pci-host/gpex-acpi.c +1
-1@@ -279,7 +280,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) }aml_append (dev,aml_name_decl ("_CRS" , rbuf)); -acpi_dsdt_add_host_bridge_methods (dev, true); +acpi_dsdt_add_host_bridge_methods (dev, cfg->pci_native_hotplug);Aml *dev_res0 =aml_device ("%s" ,"RES0" );aml_append (dev_res0,aml_name_decl ("_HID" ,aml_string ("PNP0C02" )));
Cheers,
Gustavo
RFC 10/24 hw/i386/acpi-build: Turn build_q35_osc_method into a generic method
In reply to Eric AugerGPEX acpi_dsdt_add_pci_osc() does basically the same as build_q35_osc_method().
Rename build_q35_osc_method() into build_pci_host_bridge_osc_method() and move it into hw/acpi/aml-build.c. In a subsequent patch we will use this later in place of acpi_dsdt_add_pci_osc().
--- include/hw/acpi/aml-build.h | 2 ++ hw/acpi/aml-build.c | 50 ++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 54 ++----------------------------------- 3 files changed, 54 insertions(+), 52 deletions(-)
include/hw/acpi/aml-build.h +2 -0
@@ -508,4 +508,6 @@ void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,void build_spcr (GArray *table_data,BIOSLinker *linker,const AcpiSpcrData *f,const uint8_t rev,const char *oem_id,const char *oem_table_id,const char *name); + +Aml *build_pci_host_bridge_osc_method (bool enable_native_pcie_hotplug);#endif
hw/acpi/aml-build.c +50 -0
53 lines not on this page · raw message
hw/i386/acpi-build.c +2 -52
72 lines not on this page · raw message
Signature · 1 line
2.49.0
RFC 11/24 hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
In reply to Eric Augergpex build_host_bridge_osc() and x86 originated build_pci_host_bridge_osc_method() are mostly identical.
In GPEX, SUPP is set to CDW2 but is not further used. CTRL is same as Local0.
So let gpex code reuse build_pci_host_bridge_osc_method() and remove build_host_bridge_osc().
---
The DSDT diff is given below:
dsdt.dsl_after_osc_change renamed from dsdt.dsl_before +9 -10
@@ -5,13 +5,13 @@ * * Disassembling to symbolic ASL+ operators * - * Disassembly of dsdt.dat, Mon Apr 7 05:33:06 2025 + * Disassembly of dsdt.dat, Mon Apr 7 05:37:20 2025 * * Original Table Header: * Signature "DSDT" - * Length 0x00001A4F (6735) + * Length 0x00001A35 (6709) * Revision 0x02 - * Checksum 0xBF + * Checksum 0xDD * OEM ID "BOCHS " * OEM Table ID "BXPC " * OEM Revision 0x00000001 (1)
@@ -1849,27 +1849,26 @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPC ", 0x00000001) { CreateDWordField (Arg3, 0x04, CDW2) CreateDWordField (Arg3, 0x08, CDW3) - SUPP = CDW2 /* \_SB_.PCI0._OSC.CDW2 */ - CTRL = CDW3 /* \_SB_.PCI0._OSC.CDW3 */ - CTRL &= 0x1F + Local0 = CDW3 /* \_SB_.PCI0._OSC.CDW3 */ + Local0 &= 0x1F If ((Arg1 != One)) { CDW1 |= 0x08 } - If ((CDW3 != CTRL)) + If ((CDW3 != Local0)) { CDW1 |= 0x10 } - CDW3 = CTRL /* \_SB_.PCI0.CTRL */ - Return (Arg3) + CDW3 = Local0 } Else { CDW1 |= 0x04 - Return (Arg3) } + + Return (Arg3) } Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method
--- hw/pci-host/gpex-acpi.c | 60 +++-------------------------------------- 1 file changed, 4 insertions(+), 56 deletions(-)
hw/pci-host/gpex-acpi.c +4 -56
72 lines not on this page · raw message
Signature · 1 line
2.49.0
RFC 12/24 hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
In reply to Eric AugerExtract the code that reserves resources for ACPI PCI hotplug into a new helper named build_append_pcihp_resources() and move it to pcihp.c. We will reuse it on ARM.
--- include/hw/acpi/pcihp.h | 2 ++ hw/acpi/pcihp.c | 20 ++++++++++++++++++++ hw/i386/acpi-build.c | 15 ++------------- 3 files changed, 24 insertions(+), 13 deletions(-)
include/hw/acpi/pcihp.h +2 -0
@@ -74,6 +74,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, Error **errp);void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr); +void build_append_pcihp_resources (Aml *table, +uint64_t io_addr,uint64_t io_len);/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);
hw/acpi/pcihp.c +20 -0
@@ -685,6 +685,26 @@ void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr)aml_append (table, scope); } +/* Reserve PCIHP resources */ +void build_append_pcihp_resources (Aml *scope/* \\_SB.PCI0 */ , +uint64_t io_addr,uint64_t io_len) +{ +Aml *dev, *crs; + + dev =aml_device ("PHPR" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" ))); +aml_append (dev, +aml_name_decl ("_UID" ,aml_string ("PCI Hotplug resources" ))); +/* device present, functioning, decoding, not shown in UI */ +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xB ))); + crs =aml_resource_template (); +aml_append (crs, +aml_io (AML_DECODE16 , io_addr, io_addr,1 , io_len) + ); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); +} +const VMStateDescription vmstate_acpi_pcihp_pci_status = { .name ="acpi_pcihp_pci_status" , .version_id =1 ,
hw/i386/acpi-build.c +2 -13
@@ -1458,19 +1458,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,/* reserve PCIHP resources */ if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) { - dev =aml_device ("PHPR" ); -aml_append (dev,aml_name_decl ("_HID" ,aml_string ("PNP0A06" ))); -aml_append (dev, -aml_name_decl ("_UID" ,aml_string ("PCI Hotplug resources" ))); -/* device present, functioning, decoding, not shown in UI */ -aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xB ))); - crs =aml_resource_template (); -aml_append (crs, -aml_io (AML_DECODE16 , pm->pcihp_io_base, pm->pcihp_io_base,1 , - pm->pcihp_io_len) - ); -aml_append (dev,aml_name_decl ("_CRS" , crs)); -aml_append (scope, dev); +build_append_pcihp_resources (scope, + pm->pcihp_io_base, pm->pcihp_io_len); }aml_append (dsdt, scope);
Signature · 1 line
2.49.0
RFC 13/24 hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
In reply to Eric AugerOn ARM we will put the operation regions in AML_SYSTEM_MEMORY. So let's allow this configuration.
--- include/hw/acpi/pcihp.h | 3 ++- hw/acpi/pcihp.c | 8 ++++---- hw/i386/acpi-build.c | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-)
include/hw/acpi/pcihp.h +2 -1
@@ -28,6 +28,7 @@#define HW_ACPI_PCIHP_H #include "hw/acpi/acpi.h" +#include "hw/acpi/aml-build.h" #include "hw/hotplug.h" #define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"
@@ -73,7 +74,7 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev, AcpiPciHpState *s, DeviceState *dev, Error **errp); -void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr); +void build_acpi_pci_hotplug (Aml *table,AmlRegionSpace rs,uint64_t pcihp_addr);void build_append_pcihp_resources (Aml *table,uint64_t io_addr,uint64_t io_len);
hw/acpi/pcihp.c +4 -4
@@ -629,7 +629,7 @@ static Aml *aml_pci_pdsm(void)return method; } -void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr) +void build_acpi_pci_hotplug (Aml *table,AmlRegionSpace rs,uint64_t pcihp_addr) {Aml *scope;Aml *field;
@@ -638,21 +638,21 @@ void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr) scope =aml_scope ("_SB.PCI0" );aml_append (scope, -aml_operation_region ("PCST" ,AML_SYSTEM_IO ,aml_int (pcihp_addr),0x08 )); +aml_operation_region ("PCST" , rs,aml_int (pcihp_addr),0x08 )); field =aml_field ("PCST" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_named_field ("PCIU" ,32 ));aml_append (field,aml_named_field ("PCID" ,32 ));aml_append (scope, field);aml_append (scope, -aml_operation_region ("SEJ" ,AML_SYSTEM_IO , +aml_operation_region ("SEJ" , rs,aml_int (pcihp_addr +ACPI_PCIHP_SEJ_BASE ),0x04 )); field =aml_field ("SEJ" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_named_field ("B0EJ" ,32 ));aml_append (scope, field);aml_append (scope, -aml_operation_region ("BNMR" ,AML_SYSTEM_IO , +aml_operation_region ("BNMR" , rs,aml_int (pcihp_addr +ACPI_PCIHP_BNMR_BASE ),0x08 )); field =aml_field ("BNMR" ,AML_DWORD_ACC ,AML_NOLOCK ,AML_WRITE_AS_ZEROS );aml_append (field,aml_named_field ("BNUM" ,32 ));
hw/i386/acpi-build.c +2 -2
@@ -1198,7 +1198,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dsdt, sb_scope);if (pm->pcihp_bridge_en || pm->pcihp_root_en) { -build_acpi_pci_hotplug (dsdt, pm->pcihp_io_base); +build_acpi_pci_hotplug (dsdt,AML_SYSTEM_IO , pm->pcihp_io_base); }build_piix4_pci0_int (dsdt); }else if (q35) {
@@ -1242,7 +1242,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dsdt, sb_scope);if (pm->pcihp_bridge_en) { -build_acpi_pci_hotplug (dsdt, pm->pcihp_io_base); +build_acpi_pci_hotplug (dsdt,AML_SYSTEM_IO , pm->pcihp_io_base); }build_q35_pci0_int (dsdt); }
Signature · 1 line
2.49.0
RFC 14/24 hw/i386/acpi-build: Move build_append_notification_callback to pcihp
In reply to Eric AugerWe plan to reuse build_append_notification_callback() on ARM so let's move it to pcihp.c.
No functional change intended.
--- include/hw/acpi/pcihp.h | 1 + hw/acpi/pcihp.c | 58 +++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 58 ----------------------------------------- 3 files changed, 59 insertions(+), 58 deletions(-)
include/hw/acpi/pcihp.h +1 -0
@@ -77,6 +77,7 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,void build_acpi_pci_hotplug (Aml *table,AmlRegionSpace rs,uint64_t pcihp_addr);void build_append_pcihp_resources (Aml *table,uint64_t io_addr,uint64_t io_len); +bool build_append_notification_callback (Aml *parent_scope,const PCIBus *bus);/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);
hw/acpi/pcihp.c +58 -0
70 lines not on this page · raw message
hw/i386/acpi-build.c +0 -58
64 lines not on this page · raw message
Signature · 1 line
2.49.0
RFC 15/24 hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp
In reply to Eric AugerWe intend to reuse build_append_pci_bus_devices and build_append_pcihp_slots on ARM. So Let's move them to hw/acpi/pcihp.c as well as small static helpers they use.
No functional change intended.
--- include/hw/acpi/pci.h | 1 - include/hw/acpi/pcihp.h | 2 + hw/acpi/pcihp.c | 173 ++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 172 --------------------------------------- 4 files changed, 175 insertions(+), 173 deletions(-)
include/hw/acpi/pci.h +0 -1
@@ -37,7 +37,6 @@ typedef struct AcpiMcfgInfo {void build_mcfg (GArray *table_data,BIOSLinker *linker,AcpiMcfgInfo *info,const char *oem_id,const char *oem_table_id); -void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus);void build_pci_bridge_aml (AcpiDevAmlIf *adev,Aml *scope);void build_srat_generic_affinity_structures (GArray *table_data);
include/hw/acpi/pcihp.h +2 -0
@@ -79,6 +79,8 @@ void build_append_pcihp_resources(Aml *table, uint64_t io_addr, uint64_t io_len);bool build_append_notification_callback (Aml *parent_scope,const PCIBus *bus); +void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus); +/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);
hw/acpi/pcihp.c +173 -0
185 lines not on this page · raw message
hw/i386/acpi-build.c +0 -172
184 lines not on this page · raw message
Signature · 1 line
2.49.0
RFC 16/24 hw/i386/acpi-build: Introduce and use acpi_get_pci_host
In reply to Eric Augerpcihp acpi_set_pci_info() generic code currently uses acpi_get_i386_pci_host() to retrieve the pci host bridge.
Let's rename acpi_get_i386_pci_host into acpi_get_pci_host and move it in pci generic code.
The helper is augmented with the support of ARM GPEX.
--- include/hw/acpi/pci.h | 2 ++ hw/acpi/pci.c | 20 ++++++++++++++++++++ hw/acpi/pcihp.c | 3 ++- hw/i386/acpi-build.c | 24 ++++-------------------- 4 files changed, 28 insertions(+), 21 deletions(-)
include/hw/acpi/pci.h +2 -0
@@ -41,4 +41,6 @@ void build_pci_bridge_aml(AcpiDevAmlIf *adev, Aml *scope);void build_srat_generic_affinity_structures (GArray *table_data); +Object *acpi_get_pci_host (void ); +#endif
hw/acpi/pci.c +20 -0
@@ -26,6 +26,7 @@#include "qemu/osdep.h" #include "qemu/error-report.h" #include "qom/object_interfaces.h" +#include "qom/object.h" #include "qapi/error.h" #include "hw/boards.h" #include "hw/acpi/aml-build.h"
@@ -33,6 +34,9 @@#include "hw/pci/pci_bridge.h" #include "hw/pci/pci_device.h" #include "hw/pci/pcie_host.h" +#include "hw/pci-host/i440fx.h" +#include "hw/pci-host/q35.h" +#include "hw/pci-host/gpex.h" /* * PCI Firmware Specification, Revision 3.0
@@ -301,3 +305,19 @@ void build_srat_generic_affinity_structures(GArray *table_data)object_child_foreach_recursive (object_get_root (), build_acpi_generic_port, table_data); } + +Object *acpi_get_pci_host (void ) +{ +Object *host; + + host =object_resolve_type_unambiguous (TYPE_I440FX_PCI_HOST_BRIDGE ,NULL ); +if (host) { +return host; + } + host =object_resolve_type_unambiguous (TYPE_Q35_HOST_DEVICE ,NULL ); +if (host) { +return host; + } + host =object_resolve_type_unambiguous (TYPE_GPEX_HOST ,NULL ); +return host; +}
hw/acpi/pcihp.c +2 -1
@@ -36,6 +36,7 @@#include "hw/pci-bridge/xio3130_downstream.h" #include "hw/i386/acpi-build.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/pci.h" #include "hw/pci/pci_bus.h" #include "migration/vmstate.h" #include "qapi/error.h"
@@ -102,7 +103,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaque)static void acpi_set_pci_info (bool has_bridge_hotplug) {static bool bsel_is_set; -Object *host =acpi_get_i386_pci_host (); +Object *host =acpi_get_pci_host ();PCIBus *bus;BSELInfo info = { .bsel_alloc =ACPI_PCIHP_BSEL_DEFAULT , .has_bridge_hotplug = has_bridge_hotplug };
hw/i386/acpi-build.c +4 -20
@@ -269,27 +269,11 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)#endif } -/* -* Because of the PXB hosts we cannot simply query TYPE_PCI_HOST_BRIDGE. -* On i386 arch we only have two pci hosts, so we can look only for them. -*/ -Object *acpi_get_i386_pci_host (void ) -{ -PCIHostState *host; - - host =PCI_HOST_BRIDGE (object_resolve_path ("/machine/i440fx" ,NULL )); -if (!host) { - host =PCI_HOST_BRIDGE (object_resolve_path ("/machine/q35" ,NULL )); - } - -return OBJECT (host); -} -static void acpi_get_pci_holes (Range *hole,Range *hole64) {Object *pci_host; - pci_host =acpi_get_i386_pci_host (); + pci_host =acpi_get_pci_host ();if (!pci_host) {return ;
@@ -1271,7 +1255,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, sb_scope =aml_scope ("\\_SB" ); { -Object *pci_host =acpi_get_i386_pci_host (); +Object *pci_host =acpi_get_pci_host ();if (pci_host) {PCIBus *pbus =PCI_HOST_BRIDGE (pci_host)->bus;
@@ -1332,7 +1316,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,if (pm->pcihp_bridge_en || pm->pcihp_root_en) {bool has_pcnt; -Object *pci_host =acpi_get_i386_pci_host (); +Object *pci_host =acpi_get_pci_host ();PCIBus *b =PCI_HOST_BRIDGE (pci_host)->bus; scope =aml_scope ("\\_SB.PCI0" );
@@ -1972,7 +1956,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)Object *pci_host;QObject *o; - pci_host =acpi_get_i386_pci_host (); + pci_host =acpi_get_pci_host ();if (!pci_host) {return false; }
Signature · 1 line
2.49.0
RFC 17/24 hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug
In reply to Eric AugerGenerate additional DSDT description for ACPI PCI hotplug support.
--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 24 ++++++++++++++++++++++++ hw/arm/virt.c | 1 + hw/arm/Kconfig | 2 ++ 4 files changed, 28 insertions(+)
include/hw/arm/virt.h +1 -0
@@ -79,6 +79,7 @@ enum {VIRT_ACPI_GED ,VIRT_NVDIMM_ACPI ,VIRT_PVTIME , +VIRT_ACPI_PCIHP , VIRT_LOWMEMMAP_LAST, };
hw/arm/virt-acpi-build.c +24 -0
@@ -34,6 +34,7 @@#include "hw/core/cpu.h" #include "hw/acpi/acpi-defs.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/pcihp.h" #include "hw/nvram/fw_cfg_acpi.h" #include "hw/acpi/bios-linker-loader.h" #include "hw/acpi/aml-build.h"
@@ -840,6 +841,29 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) (irqmap[VIRT_MMIO ] +ARM_SPI_BASE ), 0, NUM_VIRTIO_TRANSPORTS);acpi_dsdt_add_pci (scope, memmap, irqmap[VIRT_PCIE ] +ARM_SPI_BASE , vms); + +aml_append (dsdt, scope); + +if (vms->acpi_pcihp) { +Aml *pci0_scope =aml_scope ("\\_SB.PCI0" ); + +build_acpi_pci_hotplug (dsdt,AML_SYSTEM_MEMORY , + memmap[VIRT_ACPI_PCIHP ].base); +build_append_pcihp_resources (pci0_scope, + memmap[VIRT_ACPI_PCIHP ].base, + memmap[VIRT_ACPI_PCIHP ].size); + +/* Scan all PCI buses. Generate tables to support hotplug. */ +build_append_pci_bus_devices (pci0_scope, vms->bus); +if (object_property_find (OBJECT (vms->bus),ACPI_PCIHP_PROP_BSEL )) { +build_append_pcihp_slots (pci0_scope, vms->bus); + } +build_append_notification_callback (pci0_scope, vms->bus); +aml_append (dsdt, pci0_scope); + } + + scope =aml_scope ("\\_SB" ); +if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(vms->acpi_dev),
hw/arm/virt.c +1 -0
@@ -183,6 +183,7 @@ static const MemMapEntry base_memmap[] = { [VIRT_NVDIMM_ACPI] = { 0x09090000, NVDIMM_ACPI_IO_LEN}, [VIRT_PVTIME] = { 0x090a0000, 0x00010000 }, [VIRT_SECURE_GPIO] = { 0x090b0000, 0x00001000 }, + [VIRT_ACPI_PCIHP] = { 0x090c0000, 0x00001000 }, [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 },
hw/arm/Kconfig +2 -0
@@ -34,6 +34,8 @@ config ARM_VIRT select ACPI_HW_REDUCED select ACPI_APEI select ACPI_VIOT + select ACPI_PCIHP + select ACPI_PCI_BRIDGE select VIRTIO_MEM_SUPPORTED select ACPI_CXL select ACPI_HMAT
Signature · 1 line
2.49.0
RFC 18/24 hw/acpi/ged: Prepare the device to react to PCI hotplug events
In reply to Eric AugerQEMU will notify the OS about PCI hotplug/hotunplug events through GED interrupts. Let the GED device handle a new PCI hotplug event. On its occurence it calls the \\_SB.PCI0.PCNT method with the BLCK mutex held.
The GED device uses a dedicated MMIO region that will be mapped by the machine code.
At this point the GED still does not support PCI device hotplug in its TYPE_HOTPLUG_HANDLER implementation. This will come in a subsequent patch
--- include/hw/acpi/generic_event_device.h | 5 +++++ include/hw/acpi/pcihp.h | 2 ++ hw/acpi/generic_event_device.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+)
include/hw/acpi/generic_event_device.h +5 -0
@@ -63,6 +63,7 @@#include "hw/acpi/memory_hotplug.h" #include "hw/acpi/ghes.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/pcihp.h" #include "qom/object.h" #define ACPI_POWER_BUTTON_DEVICE "PWRB"
@@ -101,6 +102,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)#define ACPI_GED_PWR_DOWN_EVT 0x2#define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4#define ACPI_GED_CPU_HOTPLUG_EVT 0x8 +#define ACPI_GED_PCI_HOTPLUG_EVT 0x10 typedef struct GEDState { MemoryRegion evt;
@@ -114,6 +116,9 @@ struct AcpiGedState {MemoryRegion container_memhp;CPUHotplugState cpuhp_state;MemoryRegion container_cpuhp; +AcpiPciHpState pcihp_state; +MemoryRegion container_pcihp; +GEDState ged_state;uint32_t ged_event_bitmap;qemu_irq irq;
include/hw/acpi/pcihp.h +2 -0
@@ -38,6 +38,8 @@#define ACPI_PCIHP_SEJ_BASE 0x8#define ACPI_PCIHP_BNMR_BASE 0x10 +#define ACPI_PCI_HOTPLUG_REG_LEN 0x14 + typedef struct AcpiPciHpPciStatus { uint32_t up; uint32_t down;
hw/acpi/generic_event_device.c +14 -0
@@ -26,6 +26,7 @@ static const uint32_t ged_supported_events[] = {ACPI_GED_PWR_DOWN_EVT ,ACPI_GED_NVDIMM_HOTPLUG_EVT ,ACPI_GED_CPU_HOTPLUG_EVT , + ACPI_GED_PCI_HOTPLUG_EVT, };/*
@@ -121,6 +122,12 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,aml_notify (aml_name ("\\_SB.NVDR" ), aml_int(0x80)));break ; +case ACPI_GED_PCI_HOTPLUG_EVT : +aml_append (if_ctx, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (if_ctx,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (if_ctx,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +break ;default :/* * Please make sure all the events in ged_supported_events[]
@@ -299,6 +306,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) sel =ACPI_GED_NVDIMM_HOTPLUG_EVT ; }else if (ev &ACPI_CPU_HOTPLUG_STATUS ) { sel =ACPI_GED_CPU_HOTPLUG_EVT ; + }else if (ev &ACPI_PCI_HOTPLUG_STATUS ) { + sel =ACPI_GED_PCI_HOTPLUG_EVT ; }else {/* Unknown event. Return without generating interrupt. */ warn_report ("GED: Unsupported event %d. No irq injected" , ev);
@@ -428,6 +437,11 @@ static void acpi_ged_realize(DeviceState *dev, Error **errp)cpu_hotplug_hw_init (&s->container_cpuhp,OBJECT (dev), &s->cpuhp_state,0 );break ; +case ACPI_GED_PCI_HOTPLUG_EVT : +memory_region_init (&s->container_pcihp,OBJECT (dev), +"pcihp container" , +ACPI_PCI_HOTPLUG_REG_LEN ); +sysbus_init_mmio (sbd, &s->container_pcihp); } ged_events--; }
Signature · 1 line
2.49.0
Re: [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events
Hi Eric,
Quoted 3 lines · Eric Auger
QEMU will notify the OS about PCI hotplug/hotunplug events through GED interrupts. Let the GED device handle a new PCI hotplug event. On its occurence it calls the \\_SB.PCI0.PCNT method with the BLCK
nit: occurrence -^
Quoted 8 lines
mutex held.
The GED device uses a dedicated MMIO region that will be mapped by the machine code.
At this point the GED still does not support PCI device hotplug in its
TYPE_HOTPLUG_HANDLERimplementation. This will come in a subsequent patch
nit: period missing ^
Quoted 42 lines
Signed-off-by Eric Auger <[email protected]>--- include/hw/acpi/generic_event_device.h | 5 +++++ include/hw/acpi/pcihp.h | 2 ++ hw/acpi/generic_event_device.c | 14 ++++++++++++++ 3 files changed, 21 insertions(+)include/hw/acpi/generic_event_device.h +5
-0@@ -63,6 +63,7 @@#include "hw/acpi/memory_hotplug.h" #include "hw/acpi/ghes.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/pcihp.h" #include "qom/object.h" #define ACPI_POWER_BUTTON_DEVICE "PWRB"@@ -101,6 +102,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)#define ACPI_GED_PWR_DOWN_EVT 0x2#define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4#define ACPI_GED_CPU_HOTPLUG_EVT 0x8 +#define ACPI_GED_PCI_HOTPLUG_EVT 0x10 typedef struct GEDState { MemoryRegion evt;@@ -114,6 +116,9 @@ struct AcpiGedState {MemoryRegion container_memhp;CPUHotplugState cpuhp_state;MemoryRegion container_cpuhp; +AcpiPciHpState pcihp_state; +MemoryRegion container_pcihp; +GEDState ged_state;uint32_t ged_event_bitmap;qemu_irq irq;include/hw/acpi/pcihp.h +0
-0
include/hw/acpi/pcihp.h line 41
Quoted 4 lines
include/hw/acpi/pcihp.h +1
-0@@ -38,6 +38,8 @@#define ACPI_PCIHP_SEJ_BASE 0x8#define ACPI_PCIHP_BNMR_BASE 0x10 +#define ACPI_PCI_HOTPLUG_REG_LEN 0x14
This is wrong, no? It should be 0x18, i.e. 24 bytes or 6 registers of 4 bytes.
I think it's better to move the defines in pcihp.c into pcihp.h and use them to define ACPI_PCI_HOTPLUG_REG_LEN so the values are consistent, like:
hw/acpi/pcihp.c +0 -8
@@ -44,14 +44,6 @@#include "qobject/qnum.h" #include "trace.h" -#define ACPI_PCIHP_SIZE 0x0018 -#define PCI_UP_BASE 0x0000 -#define PCI_DOWN_BASE 0x0004 -#define PCI_EJ_BASE 0x0008 -#define PCI_RMV_BASE 0x000c -#define PCI_SEL_BASE 0x0010 -#define PCI_AIDX_BASE 0x0014 - typedef struct AcpiPciHpFind { int bsel; PCIBus *bus;
include/hw/acpi/pcihp.h +9 -1
@@ -38,7 +38,15 @@#define ACPI_PCIHP_SEJ_BASE 0x8#define ACPI_PCIHP_BNMR_BASE 0x10 -#define ACPI_PCI_HOTPLUG_REG_LEN 0x14 +#define ACPI_PCIHP_SIZE 0x0018 +#define PCI_UP_BASE 0x0000 +#define PCI_DOWN_BASE 0x0004 +#define PCI_EJ_BASE 0x0008 +#define PCI_RMV_BASE 0x000c +#define PCI_SEL_BASE 0x0010 +#define PCI_AIDX_BASE 0x0014 + +#define ACPI_PCI_HOTPLUG_REG_LEN ACPI_PCIHP_SIZE typedef struct AcpiPciHpPciStatus { uint32_t up;
or even use only one of them (ACPI_PCI_HOTPLUG_REG_LEN, ACPI_PCIHP_SIZE, or another new name that would fit better in both contexts).
Cheers,
Gustavo
Quoted 50 lines
include/hw/acpi/pcihp.h +1
-0+ typedef struct AcpiPciHpPciStatus { uint32_t up; uint32_t down;hw/acpi/generic_event_device.c +14
-0@@ -26,6 +26,7 @@ static const uint32_t ged_supported_events[] = {ACPI_GED_PWR_DOWN_EVT ,ACPI_GED_NVDIMM_HOTPLUG_EVT ,ACPI_GED_CPU_HOTPLUG_EVT , + ACPI_GED_PCI_HOTPLUG_EVT, };/* @@ -121,6 +122,12 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,aml_notify (aml_name ("\\_SB.NVDR" ), aml_int(0x80)));break ; +case ACPI_GED_PCI_HOTPLUG_EVT : +aml_append (if_ctx, +aml_acquire (aml_name ("\\_SB.PCI0.BLCK" ),0xFFFF )); +aml_append (if_ctx,aml_call0 ("\\_SB.PCI0.PCNT" )); +aml_append (if_ctx,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); +break ;default :/* * Please make sure all the events in ged_supported_events[] @@ -299,6 +306,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) sel =ACPI_GED_NVDIMM_HOTPLUG_EVT ; }else if (ev &ACPI_CPU_HOTPLUG_STATUS ) { sel =ACPI_GED_CPU_HOTPLUG_EVT ; + }else if (ev &ACPI_PCI_HOTPLUG_STATUS ) { + sel =ACPI_GED_PCI_HOTPLUG_EVT ; }else {/* Unknown event. Return without generating interrupt. */ warn_report ("GED: Unsupported event %d. No irq injected" , ev);@@ -428,6 +437,11 @@ static void acpi_ged_realize(DeviceState *dev, Error **errp)cpu_hotplug_hw_init (&s->container_cpuhp,OBJECT (dev), &s->cpuhp_state,0 );break ; +case ACPI_GED_PCI_HOTPLUG_EVT : +memory_region_init (&s->container_pcihp,OBJECT (dev), +"pcihp container" , +ACPI_PCI_HOTPLUG_REG_LEN ); +sysbus_init_mmio (sbd, &s->container_pcihp); } ged_events--; }
Re: [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events
Hi Gustavo,
Quoted 61 lines · Gustavo Romero
Hi Eric,
Quoted 3 lines · Eric Auger
QEMU will notify the OS about PCI hotplug/hotunplug events through GED interrupts. Let the GED device handle a new PCI hotplug event. On its occurence it calls the \\_SB.PCI0.PCNT method with the BLCK
nit: occurrence -^
Quoted 8 lines
mutex held.
The GED device uses a dedicated MMIO region that will be mapped by the machine code.
At this point the GED still does not support PCI device hotplug in its
TYPE_HOTPLUG_HANDLERimplementation. This will come in a subsequent patchnit: period missing ^
Quoted 39 lines
Signed-off-by Eric Auger <[email protected]>---
include/hw/acpi/generic_event_device.h| 5 +++++ include/hw/acpi/pcihp.h | 2 ++ hw/acpi/generic_event_device.c | 14 ++++++++++++++3 files changed, 21 insertions(+)include/hw/acpi/generic_event_device.h +5
-0@@ -63,6 +63,7 @@ #include "hw/acpi/memory_hotplug.h" #include "hw/acpi/ghes.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/pcihp.h" #include "qom/object.h" #define ACPI_POWER_BUTTON_DEVICE "PWRB"@@ -101,6 +102,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED) #define ACPI_GED_PWR_DOWN_EVT 0x2 #define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4 #define ACPI_GED_CPU_HOTPLUG_EVT 0x8 +#define ACPI_GED_PCI_HOTPLUG_EVT 0x10 typedef struct GEDState { MemoryRegion evt;@@ -114,6 +116,9 @@ struct AcpiGedState { MemoryRegion container_memhp; CPUHotplugState cpuhp_state; MemoryRegion container_cpuhp; + AcpiPciHpState pcihp_state; + MemoryRegion container_pcihp; + GEDState ged_state; uint32_t ged_event_bitmap; qemu_irq irq;include/hw/acpi/pcihp.h +0
-1--- a/include/hw/acpi/pcihp.h
Quoted 8 lines
Quoted 5 lines
+++
b/include/hw/acpi/pcihp.hinclude/hw/acpi/pcihp.h +0
-0@@ -38,6 +38,8 @@ #define ACPI_PCIHP_SEJ_BASE 0x8 #define ACPI_PCIHP_BNMR_BASE 0x10+#define
ACPI_PCI_HOTPLUG_REG_LEN0x14This is wrong, no? It should be
0x18, i.e. 24 bytes or 6 registers of 4 bytes.
yes this is wrong. you are totally right. I am about to send a new version where this is fixed, sorry. I noticed that when testing the acpi index modality which did not work with the RFC series.
Now I am using ACPI_PCIHP_SIZE.
Cheers
Eric
Quoted 112 lines
I think it's better to move the defines in
pcihp.cintopcihp.hand use them to defineACPI_PCI_HOTPLUG_REG_LENso the values are consistent, like:hw/acpi/pcihp.c +0
-0@@ -44,14 +44,6 @@ #include "qobject/qnum.h" #include "trace.h"hw/acpi/pcihp.c +0
-8-#define ACPI_PCIHP_SIZE 0x0018 -#define PCI_UP_BASE 0x0000 -#define PCI_DOWN_BASE 0x0004 -#define PCI_EJ_BASE 0x0008 -#define PCI_RMV_BASE 0x000c -#define PCI_SEL_BASE 0x0010 -#define PCI_AIDX_BASE 0x0014 -typedef struct AcpiPciHpFind {
int bsel;
PCIBus *bus;include/hw/acpi/pcihp.h +0
-0@@ -38,7 +38,15 @@ #define ACPI_PCIHP_SEJ_BASE 0x8 #define ACPI_PCIHP_BNMR_BASE 0x10include/hw/acpi/pcihp.h +9
-1-#define ACPI_PCI_HOTPLUG_REG_LEN 0x14 +#define ACPI_PCIHP_SIZE 0x0018 +#define PCI_UP_BASE 0x0000 +#define PCI_DOWN_BASE 0x0004 +#define PCI_EJ_BASE 0x0008 +#define PCI_RMV_BASE 0x000c +#define PCI_SEL_BASE 0x0010 +#define PCI_AIDX_BASE 0x0014 + +#define ACPI_PCI_HOTPLUG_REG_LEN ACPI_PCIHP_SIZE
typedef struct AcpiPciHpPciStatus {
uint32_tup;or even use only one of them (
ACPI_PCI_HOTPLUG_REG_LEN,ACPI_PCIHP_SIZE, or
another new name that would fit better in both contexts).Cheers,
GustavoQuoted 56 lines
+
typedef struct AcpiPciHpPciStatus {
uint32_tup;
uint32_tdown;hw/acpi/generic_event_device.c +7
-0@@ -26,6 +26,7 @@ static const uint32_t ged_supported_events[] = { ACPI_GED_PWR_DOWN_EVT, ACPI_GED_NVDIMM_HOTPLUG_EVT, ACPI_GED_CPU_HOTPLUG_EVT, + ACPI_GED_PCI_HOTPLUG_EVT, }; /*@@ -121,6 +122,12 @@ void build_ged_aml(Aml *table, const char *name,HotplugHandler *hotplug_dev, aml_notify(aml_name("\\_SB.NVDR"), aml_int(0x80))); break; + case ACPI_GED_PCI_HOTPLUG_EVT: + aml_append(if_ctx, + aml_acquire(aml_name("\\_SB.PCI0.BLCK"),0xFFFF )); + aml_append(if_ctx, aml_call0("\\_SB.PCI0.PCNT")); + aml_append(if_ctx,aml_release (aml_name ("\\_SB.PCI0.BLCK" ))); + break;default:
/*
* Please make sure all the events in ged_supported_events[]hw/acpi/generic_event_device.c +2
-0@@ -299,6 +306,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev) sel = ACPI_GED_NVDIMM_HOTPLUG_EVT; } else if (ev & ACPI_CPU_HOTPLUG_STATUS) { sel = ACPI_GED_CPU_HOTPLUG_EVT; + } else if (ev & ACPI_PCI_HOTPLUG_STATUS) { + sel = ACPI_GED_PCI_HOTPLUG_EVT; } else { /* Unknown event. Return without generating interrupt. */warn_report("GED: Unsupported event %d. No irq injected", ev);
hw/acpi/generic_event_device.c +5
-0@@ -428,6 +437,11 @@ static void acpi_ged_realize(DeviceState *dev, Error **errp) cpu_hotplug_hw_init(&s->container_cpuhp, OBJECT(dev), &s->cpuhp_state, 0); break; + case ACPI_GED_PCI_HOTPLUG_EVT: + memory_region_init(&s->container_pcihp, OBJECT(dev), + "pcihp container", + ACPI_PCI_HOTPLUG_REG_LEN); + sysbus_init_mmio(sbd, &s->container_pcihp); } ged_events--;}
RFC 19/24 hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation
In reply to Eric AugerAdd PCI device related code in the TYPE_HOTPLUG_HANDLER implementation.
For a PCI device hotplug/hotunplug event, the code routes to acpi_pcihp_device callbacks (pre_plug_cb, plug_cb, unplug_request_cb, unplug_cb).
--- hw/acpi/generic_event_device.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
hw/acpi/generic_event_device.c +20 -0
@@ -16,6 +16,7 @@#include "hw/irq.h" #include "hw/mem/pc-dimm.h" #include "hw/mem/nvdimm.h" +#include "hw/pci/pci_device.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" #include "qemu/error-report.h"
@@ -234,6 +235,17 @@ static const MemoryRegionOps ged_regs_ops = { }, }; +static void acpi_ged_device_pre_plug_cb (HotplugHandler *hotplug_dev, +DeviceState *dev,Error **errp) +{ +if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_pre_plug_cb (hotplug_dev, dev, errp); + }else { +error_setg (errp,"virt: device pre plug request for unsupported device" +" type: %s" ,object_get_typename (OBJECT (dev))); + } +} +static void acpi_ged_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {
@@ -247,6 +259,8 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev, } }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) {acpi_cpu_plug_cb (hotplug_dev, &s->cpuhp_state, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_plug_cb (hotplug_dev, &s->pcihp_state, dev, errp); }else {error_setg (errp,"virt: device plug request for unsupported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -263,6 +277,9 @@ static void acpi_ged_unplug_request_cb(HotplugHandler *hotplug_dev,acpi_memory_unplug_request_cb (hotplug_dev, &s->memhp_state, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) {acpi_cpu_unplug_request_cb (hotplug_dev, &s->cpuhp_state, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_unplug_request_cb (hotplug_dev, &s->pcihp_state, + dev, errp); }else {error_setg (errp,"acpi: device unplug request for unsupported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -278,6 +295,8 @@ static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev,acpi_memory_unplug_cb (&s->memhp_state, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_CPU )) {acpi_cpu_unplug_cb (&s->cpuhp_state, dev, errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +acpi_pcihp_device_unplug_cb (hotplug_dev, &s->pcihp_state, dev, errp); }else {error_setg (errp,"acpi: device unplug for unsupported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -494,6 +513,7 @@ static void acpi_ged_class_init(ObjectClass *class, void *data) dc->vmsd = &vmstate_acpi_ged; dc->realize = acpi_ged_realize; + hc->pre_plug = acpi_ged_device_pre_plug_cb; hc->plug = acpi_ged_device_plug_cb; hc->unplug_request = acpi_ged_unplug_request_cb; hc->unplug = acpi_ged_unplug_cb;
Signature · 1 line
2.49.0
RFC 20/24 hw/acpi/ged: Support migration of AcpiPciHpState
In reply to Eric AugerAdd a subsection to migrate the AcpiPciHpState state.
--- hw/acpi/generic_event_device.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
hw/acpi/generic_event_device.c +20 -0
@@ -414,6 +414,25 @@ static const VMStateDescription vmstate_ghes_state = { } }; +static bool pcihp_needed (void *opaque) +{ +AcpiGedState *s = opaque; +return s->pcihp_state.use_acpi_hotplug_bridge; +} + +static const VMStateDescription vmstate_pcihp_state = { + .name ="acpi-ged/pcihp" , + .version_id =1 , + .minimum_version_id =1 , + .needed = pcihp_needed, + .fields = (const VMStateField []) { +VMSTATE_PCI_HOTPLUG (pcihp_state, + AcpiGedState, +NULL ,NULL ), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_acpi_ged = { .name ="acpi-ged" , .version_id =1 ,
@@ -426,6 +445,7 @@ static const VMStateDescription vmstate_acpi_ged = { &vmstate_memhp_state, &vmstate_cpuhp_state, &vmstate_ghes_state, + &vmstate_pcihp_state, NULL } };
Signature · 1 line
2.49.0
RFC 21/24 hw/core/sysbus: Introduce sysbus_mmio_map_name() helper
In reply to Eric AugerSome sysbus devices have conditionnal mmio regions. This happens for instance with the hw/acpi/ged device. In that case it becomes difficult to predict which index a specific MMIO region corresponds to when one needs to mmio map the region. Introduce a new helper that takes the name of the region instead of its index. If the region is not found this returns -1. Otherwise it maps the corresponding index and returns this latter.
--- include/hw/sysbus.h | 1 + hw/core/sysbus.c | 11 +++++++++++ 2 files changed, 12 insertions(+)
include/hw/sysbus.h +1 -0
@@ -82,6 +82,7 @@ void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);bool sysbus_is_irq_connected (SysBusDevice *dev,int n);qemu_irq sysbus_get_connected_irq (SysBusDevice *dev,int n);void sysbus_mmio_map (SysBusDevice *dev,int n,hwaddr addr); +int sysbus_mmio_map_name (SysBusDevice *dev,const char *name,hwaddr addr);void sysbus_mmio_map_overlap (SysBusDevice *dev,int n,hwaddr addr,int priority);
hw/core/sysbus.c +11 -0
@@ -151,6 +151,17 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr)sysbus_mmio_map_common (dev, n, addr, false,0 ); } +int sysbus_mmio_map_name (SysBusDevice *dev,const char *name,hwaddr addr) +{ +for (int i =0 ; i < dev->num_mmio; i++) { +if (!strcmp (dev->mmio[i].memory->name, name)) { +sysbus_mmio_map (dev, i, addr); +return i; + } + } +return -1 ; +} +void sysbus_mmio_map_overlap (SysBusDevice *dev,int n,hwaddr addr,int priority) {
Signature · 1 line
2.49.0
RFC 22/24 hw/arm/virt: Let virt support pci hotplug/unplug GED event
In reply to Eric AugerSet up the IO registers used to communicate between QEMU and ACPI.
Move the create_pcie() call after the creation of the acpi ged device since pcie coldplug will soon require the acpi pcihp resources allocated and reset during the ged initialization.
--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 35 ++++++++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 5 deletions(-)
include/hw/arm/virt.h +1 -0
@@ -35,6 +35,7 @@#include "hw/boards.h" #include "hw/arm/boot.h" #include "hw/arm/bsa.h" +#include "hw/acpi/pcihp.h" #include "hw/block/flash.h" #include "system/kvm.h" #include "hw/intc/arm_gicv3_common.h"
hw/arm/virt-acpi-build.c +1 -0
@@ -44,6 +44,7 @@#include "hw/acpi/generic_event_device.h" #include "hw/acpi/tpm.h" #include "hw/acpi/hmat.h" +#include "hw/acpi/pcihp.h" #include "hw/pci/pcie_host.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bus.h"
hw/arm/virt.c +30 -5
@@ -687,6 +687,8 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms) {DeviceState *dev;MachineState *ms =MACHINE (vms); +SysBusDevice *sbdev; +int irq = vms->irqmap[VIRT_ACPI_GED ];uint32_t event =ACPI_GED_PWR_DOWN_EVT ;
@@ -698,12 +700,28 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms) event |=ACPI_GED_NVDIMM_HOTPLUG_EVT ; } +if (vms->acpi_pcihp) { + event |=ACPI_GED_PCI_HOTPLUG_EVT ; + } + dev =qdev_new (TYPE_ACPI_GED );qdev_prop_set_uint32 (dev,"ged-event" , event); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); + sbdev =SYS_BUS_DEVICE (dev); +sysbus_realize_and_unref (sbdev, &error_fatal); -sysbus_mmio_map (SYS_BUS_DEVICE (dev),0 , vms->memmap[VIRT_ACPI_GED ].base); -sysbus_mmio_map (SYS_BUS_DEVICE (dev),1 , vms->memmap[VIRT_PCDIMM_ACPI ].base); +sysbus_mmio_map (sbdev,0 , vms->memmap[VIRT_ACPI_GED ].base); +sysbus_mmio_map (sbdev,1 , vms->memmap[VIRT_PCDIMM_ACPI ].base); +if (vms->acpi_pcihp) { +AcpiGedState *acpi_ged_state =ACPI_GED (dev); +int i; + + i =sysbus_mmio_map_name (sbdev,"pcihp container" , + vms->memmap[VIRT_ACPI_PCIHP ].base); +assert (i >=0 ); +acpi_pcihp_init (OBJECT (dev), &acpi_ged_state->pcihp_state, + vms->bus,sysbus_mmio_get_region (sbdev, i),0 ); + acpi_ged_state->pcihp_state.use_acpi_hotplug_bridge = true; + }sysbus_connect_irq (SYS_BUS_DEVICE (dev),0 ,qdev_get_gpio_in (vms->gic, irq));return dev;
@@ -1765,6 +1783,13 @@ void virt_machine_done(Notifier *notifier, void *data)pci_bus_add_fw_cfg_extra_pci_roots (vms->fw_cfg, vms->bus, &error_abort); + +if (vms->acpi_pcihp) { +AcpiGedState *acpi_ged_state =ACPI_GED (vms->acpi_dev); + +acpi_pcihp_reset (&acpi_ged_state->pcihp_state); + } +virt_acpi_setup (vms);virt_build_smbios (vms); }
@@ -2412,8 +2437,6 @@ static void machvirt_init(MachineState *machine)create_rtc (vms); -create_pcie (vms); -if (has_ged && aarch64 && firmware_loaded &&virt_is_acpi_enabled (vms)) { vms->acpi_pcihp &= !vmc->no_acpi_pcihp; vms->acpi_dev =create_acpi_ged (vms);
@@ -2422,6 +2445,8 @@ static void machvirt_init(MachineState *machine)create_gpio_devices (vms,VIRT_GPIO , sysmem); } +create_pcie (vms); +if (vms->secure && !vmc->no_secure_gpio) {create_gpio_devices (vms,VIRT_SECURE_GPIO , secure_sysmem); }
Signature · 1 line
2.49.0
RFC 23/24 hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks
In reply to Eric Auger--- hw/arm/virt.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
hw/arm/virt.c +36 -1
@@ -87,6 +87,7 @@#include "hw/virtio/virtio-iommu.h" #include "hw/char/pl011.h" #include "qemu/guest-random.h" +#include "hw/acpi/pcihp.h" static GlobalProperty arm_virt_compat[] = { {TYPE_VIRTIO_IOMMU_PCI ,"aw-bits" ,"48" },
@@ -2983,6 +2984,11 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,qlist_append_str (reserved_regions, resv_prop_str);qdev_prop_set_array (dev,"reserved-regions" , reserved_regions);g_free (resv_prop_str); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +if (vms->acpi_pcihp) { +acpi_pcihp_device_pre_plug_cb (HOTPLUG_HANDLER (vms->acpi_dev), + dev, errp); + } } }
@@ -3012,6 +3018,14 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, vms->iommu =VIRT_IOMMU_VIRTIO ; vms->virtio_iommu_bdf =pci_get_bdf (pdev);create_virtio_iommu_dt_bindings (vms); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +AcpiGedState *acpi_ged_state =ACPI_GED (vms->acpi_dev); +AcpiPciHpState *acpi_pci_hotplug = &acpi_ged_state->pcihp_state; + +if (vms->acpi_pcihp) { +acpi_pcihp_device_plug_cb (HOTPLUG_HANDLER (vms->acpi_dev), + acpi_pci_hotplug, dev, errp); + } } }
@@ -3061,6 +3075,15 @@ static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev, }else if (object_dynamic_cast (OBJECT (dev),TYPE_VIRTIO_MD_PCI )) {virtio_md_pci_unplug_request (VIRTIO_MD_PCI (dev),MACHINE (hotplug_dev), errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +VirtMachineState *vms =VIRT_MACHINE (hotplug_dev); +AcpiGedState *acpi_ged_state =ACPI_GED (vms->acpi_dev); +AcpiPciHpState *acpi_pci_hotplug = &acpi_ged_state->pcihp_state; + +if (vms->acpi_pcihp) { +acpi_pcihp_device_unplug_request_cb (HOTPLUG_HANDLER (vms->acpi_dev), + acpi_pci_hotplug, dev, errp); + } }else {error_setg (errp,"device unplug request for unsupported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -3074,6 +3097,15 @@ static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev,virt_dimm_unplug (hotplug_dev, dev, errp); }else if (object_dynamic_cast (OBJECT (dev),TYPE_VIRTIO_MD_PCI )) {virtio_md_pci_unplug (VIRTIO_MD_PCI (dev),MACHINE (hotplug_dev), errp); + }else if (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE )) { +VirtMachineState *vms =VIRT_MACHINE (hotplug_dev); +AcpiGedState *acpi_ged_state =ACPI_GED (vms->acpi_dev); +AcpiPciHpState *acpi_pci_hotplug = &acpi_ged_state->pcihp_state; + +if (vms->acpi_pcihp) { +acpi_pcihp_device_unplug_cb (HOTPLUG_HANDLER (vms->acpi_dev), + acpi_pci_hotplug, dev, errp); + } }else {error_setg (errp,"virt: device unplug for unsupported device" " type: %s" ,object_get_typename (OBJECT (dev)));
@@ -3084,11 +3116,14 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, DeviceState *dev) {MachineClass *mc =MACHINE_GET_CLASS (machine); +VirtMachineState *vms =VIRT_MACHINE (machine);if (device_is_dynamic_sysbus (mc, dev) ||object_dynamic_cast (OBJECT (dev),TYPE_PC_DIMM ) ||object_dynamic_cast (OBJECT (dev),TYPE_VIRTIO_MD_PCI ) || -object_dynamic_cast (OBJECT (dev),TYPE_VIRTIO_IOMMU_PCI )) { +object_dynamic_cast (OBJECT (dev),TYPE_VIRTIO_IOMMU_PCI ) || + (object_dynamic_cast (OBJECT (dev),TYPE_PCI_DEVICE ) && + vms->acpi_pcihp)) {return HOTPLUG_HANDLER (machine); }return NULL ;
Signature · 1 line
2.49.0
RFC 24/24 hw/arm/virt: Use ACPI PCI hotplug by default
In reply to Eric AugerNow all the enablers are there for ACPI PCI hotplug support, let's use it by default for 10.1 virt machine onwards.
--- hw/arm/virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/arm/virt.c +2 -2
@@ -3446,8 +3446,8 @@ static void virt_instance_init(Object *obj) } } -/* default disallows ACPI PCI hotplug */ - vms->acpi_pcihp = false; +/* default allows ACPI PCI hotplug */ + vms->acpi_pcihp = true;/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;
Signature · 1 line
2.49.0
Hi Eric,
Quoted 22 lines · Eric Auger
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from
hw/i386/acpi-build.cto a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Quoted 7 lines
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/
I've just started to review your series and went to a quick smoke test by hotplugging a net adapter and got the following kernel internal error:
(qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
(qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000
[ 64.165895] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff] [ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref] [ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref] [ 64.167153] pci 0000:01:00.0: enabling Extended Tags [ 64.179972] Internal error: synchronous external abort: 0000000096000050 [#1] SMP [ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi virtio_net scsi_mod net_failover failover virtio_blk scsi_common crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio [ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1 [ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024 [ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn [ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300 [ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334 [ 64.186490] sp : ffff80000a6bb3b0 [ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27: 0000000000000000 [ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24: 0000000000000001 [ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21: ffff0000c206cb00 [ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000 [ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 [ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12: 4d7a3553e5c937d0 [ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 : ffff800008735b34 [ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 : 00000000000000f8 [ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 : 00000000090c0018 [ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 : 0000000000000001 [ 64.190734] Call trace: [ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300 [ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334 [ 64.192042] acpi_ex_access_region+0xe4/0x2e0 [ 64.192287] acpi_ex_field_datum_io+0x88/0x200 [ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120 [ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0 [ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190 [ 64.193298] acpi_ex_store_object_to_node+0x150/0x240 [ 64.193527] acpi_ex_store+0x144/0x300 [ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580 [ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0 [ 64.194227] acpi_ps_parse_loop+0x100/0x6a0 [ 64.194477] acpi_ps_parse_aml+0x94/0x3b0 [ 64.194674] acpi_ps_execute_method+0x128/0x25c [ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0 [ 64.195148] acpi_evaluate_object+0x138/0x2d0 [ 64.195380] acpi_evaluate_dsm+0xb8/0x134 [ 64.195613] acpi_check_dsm+0x34/0xdc [ 64.195822] smbios_attr_is_visible+0x5c/0xb0 [ 64.196089] internal_create_group+0xd0/0x3d0 [ 64.196335] internal_create_groups+0x58/0xe0 [ 64.196584] sysfs_create_groups+0x20/0x30 [ 64.196813] device_add_groups+0x18/0x2c [ 64.197039] bus_add_device+0x48/0x160 [ 64.197260] device_add+0x3a4/0x85c [ 64.197463] pci_device_add+0x308/0x660 [ 64.197680] pci_scan_single_device+0xe4/0x114 [ 64.197941] pci_scan_slot+0x70/0x1fc [ 64.198155] acpiphp_rescan_slot+0x90/0xa4 [ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300 [ 64.198584] acpi_device_hotplug+0x138/0x4c0 [ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c [ 64.199045] process_one_work+0x1f4/0x460 [ 64.199277] worker_thread+0x188/0x4e0 [ 64.199492] kthread+0xe0/0xe4 [ 64.199671] ret_from_fork+0x10/0x20 [ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040) [ 64.200820] ---[ end trace 0000000000000000 ]---
(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fd
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
It seems Linux acpi crashed when ingesting the _DSM method but I could not figure out what exactly in it could cause it.
Cheers,
Gustavo
Quoted 51 lines
Eric Auger (24):
hw/pci/pcie_port: Fixpcie_slot_is_hotpluggbale_bustypo hw/acpi/ged: Fix wrong identation
hw/i386/acpi-build: Fixbuild_append_notfication_callbacktypo hw/i386/acpi-build: Makeaml_pci_device_dsm()static hw/arm/virt: Introduce machine state acpi pcihp flags and props hw/acpi: Rename and movebuild_x86_acpi_pci_hotplugto pcihp hw/pci-host/gpex-acpi: Addnative_pci_hotplugarg to
acpi_dsdt_add_pci_osc
hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine
downto gpex
hw/i386/acpi-build: Turnbuild_q35_osc_methodinto a generic method hw/pci-host/gpex-acpi: Usebuild_pci_host_bridge_osc_methodhw/i386/acpi-build: Introducebuild_append_pcihp_resources()helper hw/acpi/pcihp: Add an AmlRegionSpace arg tobuild_acpi_pci_hotplughw/i386/acpi-build: Movebuild_append_notification_callbackto pcihp hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp hw/i386/acpi-build: Introduce and useacpi_get_pci_hosthw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug hw/acpi/ged: Prepare the device to react to PCI hotplug events hw/acpi/ged: Call pcihp plug callbacks in hotplug handler
implementation
hw/acpi/ged: Support migration of AcpiPciHpState hw/core/sysbus: Introducesysbus_mmio_map_name()helper hw/arm/virt: Let virt support pci hotplug/unplug GED event hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks hw/arm/virt: Use ACPI PCI hotplug by defaulthw/i386/acpi-build.h | 4 - include/hw/acpi/aml-build.h | 2 + include/hw/acpi/generic_event_device.h | 5 + include/hw/acpi/pci.h | 4 +- include/hw/acpi/pcihp.h | 14 + include/hw/arm/virt.h | 4 + include/hw/pci-host/gpex.h | 1 + include/hw/sysbus.h | 1 + hw/acpi/aml-build.c | 50 +++ hw/acpi/generic_event_device.c | 64 +++- hw/acpi/pci.c | 20 ++ hw/acpi/pcihp.c | 428 +++++++++++++++++++++- hw/arm/virt-acpi-build.c | 26 ++ hw/arm/virt.c | 100 +++++- hw/core/sysbus.c | 11 + hw/i386/acpi-build.c | 475 +------------------------ hw/pci-host/gpex-acpi.c | 75 +--- hw/pci/pcie_port.c | 4 +- hw/arm/Kconfig | 2 + 19 files changed, 748 insertions(+), 542 deletions(-)
Hi Gustavo,
Quoted 141 lines · Gustavo Romero
Hi Eric,
Quoted 22 lines · Eric Auger
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from
hw/i386/acpi-build.cto a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Quoted 7 lines
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/I've just started to review your series and went to a quick smoke test by hotplugging a net adapter and got the following kernel internal error:
(qemu)
device_addvirtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class0x020000
[ 64.165895] pci 0000:01:00.0: reg0x14: [mem 0x00000000-0x00000fff] [ 64.166259] pci 0000:01:00.0: reg0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 64.166658] pci 0000:01:00.0: reg0x30: [mem 0x00000000-0x0003ffff pref]
[ 64.167153] pci 0000:01:00.0: enabling Extended Tags
[ 64.179972] Internal error: synchronous external abort:
0000000096000050 [#1] SMP
[ 64.180719] Modules linked in:aes_ce_blkaes_ce_cipherpolyval_cepolyval_genericghash_cegf128mulsha2_cebinfmt_miscsha256_arm64sha1_cenls_asciinls_cp437vfat fat evdev cfg80211 rfkill loop fuseefi_pstoredrmdm_moddax configfs efivarfsqemu_fw_cfgip_tablesx_tablesautofs4 ext4 crc16 mbcache jbd2crc32c_genericvirtio_scsivirtio_netscsi_modnet_failoverfailovervirtio_blkscsi_commoncrct10dif_cecrct10dif_commonvirtio_pcivirtio_pci_legacy_devvirtio_pci_modern_devvirtio_mmio
[ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1
[ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 64.184759] Workqueue:kacpi_hotplugacpi_hotplug_work_fn[ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 64.185737] pc :acpi_ex_system_memory_space_handler+0x290/0x300[ 64.186175] lr :acpi_ev_address_space_dispatch+0x124/0x334[ 64.186490] sp :ffff80000a6bb3b0
[ 64.186663] x29:ffff80000a6bb3b0x28:ffff0003fcbb08b8x27:
0000000000000000
[ 64.187126] x26:ffff0003fcbb0288x25:ffff80000a6bb568x24:
0000000000000001
[ 64.187499] x23:ffff80000a6bb568x22: 0000000000000004 x21:ffff0000c206cb00
[ 64.187885] x20:00000000090c0014x19: 0000000000000020 x18:
0000000000000000
[ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
0000000000000000
[ 64.188640] x14: 0000000000000000 x13:4d43c3194dea1791x12:4d7a3553e5c937d0
[ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :ffff800008735b34
[ 64.189383] x8 : 0000000000000001 x7 :ffff80000873c850x6 :00000000000000f8
[ 64.189778] x5 :ffff0000c206cb00x4 : 0000000000000000 x3 :00000000090c0018
[ 64.190163] x2 :ffff80000a9af014x1 :00000000090c0018x0 :
0000000000000001
[ 64.190734] Call trace:
[ 64.191086]acpi_ex_system_memory_space_handler+0x290/0x300[ 64.191696]acpi_ev_address_space_dispatch+0x124/0x334[ 64.192042]acpi_ex_access_region+0xe4/0x2e0
[ 64.192287]acpi_ex_field_datum_io+0x88/0x200
[ 64.192509]acpi_ex_write_with_update_rule+0xd4/0x120
[ 64.192793]acpi_ex_insert_into_field+0x210/0x2b0
[ 64.193048]acpi_ex_write_data_to_field+0xa0/0x190
[ 64.193298]acpi_ex_store_object_to_node+0x150/0x240
[ 64.193527]acpi_ex_store+0x144/0x300
[ 64.193726]acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 64.193971]acpi_ds_exec_end_op+0x24c/0x4b0
[ 64.194227]acpi_ps_parse_loop+0x100/0x6a0
[ 64.194477]acpi_ps_parse_aml+0x94/0x3b0
[ 64.194674]acpi_ps_execute_method+0x128/0x25c
[ 64.194922]acpi_ns_evaluate+0x1f0/0x2d0
[ 64.195148]acpi_evaluate_object+0x138/0x2d0
[ 64.195380]acpi_evaluate_dsm+0xb8/0x134
[ 64.195613]acpi_check_dsm+0x34/0xdc
[ 64.195822]smbios_attr_is_visible+0x5c/0xb0
[ 64.196089]internal_create_group+0xd0/0x3d0
[ 64.196335]internal_create_groups+0x58/0xe0
[ 64.196584]sysfs_create_groups+0x20/0x30
[ 64.196813]device_add_groups+0x18/0x2c
[ 64.197039]bus_add_device+0x48/0x160
[ 64.197260]device_add+0x3a4/0x85c
[ 64.197463]pci_device_add+0x308/0x660
[ 64.197680]pci_scan_single_device+0xe4/0x114
[ 64.197941]pci_scan_slot+0x70/0x1fc
[ 64.198155]acpiphp_rescan_slot+0x90/0xa4
[ 64.198366]acpiphp_hotplug_notify+0x2a8/0x300
[ 64.198584]acpi_device_hotplug+0x138/0x4c0
[ 64.198819]acpi_hotplug_work_fn+0x2c/0x4c
[ 64.199045]process_one_work+0x1f4/0x460
[ 64.199277]worker_thread+0x188/0x4e0
[ 64.199492]kthread+0xe0/0xe4
[ 64.199671]ret_from_fork+0x10/0x20
[ 64.200114] Code:f90002e05280000017ffff97f94002e0(b9000040) [ 64.200820] ---[ end trace 0000000000000000 ]---(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fd
Quoted 6 lines
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
It seems Linux acpi crashed when ingesting the
_DSMmethod but I could not
figure out what exactly in it could cause it.
Thank you for reporting this issue.
On my end I tested with rhel guest and recent EDK2 while hotplugging/hot-unplugging VFIO devices.
I will try to reproduce
Eric
Quoted 57 lines
Cheers,
GustavoQuoted 51 lines
Eric Auger (24):
hw/pci/pcie_port: Fixpcie_slot_is_hotpluggbale_bustypo hw/acpi/ged: Fix wrong identation
hw/i386/acpi-build: Fixbuild_append_notfication_callbacktypo hw/i386/acpi-build: Makeaml_pci_device_dsm()static hw/arm/virt: Introduce machine state acpi pcihp flags and props hw/acpi: Rename and movebuild_x86_acpi_pci_hotplugto pcihp hw/pci-host/gpex-acpi: Addnative_pci_hotplugarg toacpi_dsdt_add_pci_osc
hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
hw/i386/acpi-build: Turnbuild_q35_osc_methodinto a generic method hw/pci-host/gpex-acpi: Usebuild_pci_host_bridge_osc_methodhw/i386/acpi-build: Introducebuild_append_pcihp_resources()helper hw/acpi/pcihp: Add an AmlRegionSpace arg tobuild_acpi_pci_hotplughw/i386/acpi-build: Movebuild_append_notification_callbackto pcihp hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp hw/i386/acpi-build: Introduce and useacpi_get_pci_hosthw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug hw/acpi/ged: Prepare the device to react to PCI hotplug events hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation
hw/acpi/ged: Support migration of AcpiPciHpState hw/core/sysbus: Introducesysbus_mmio_map_name()helper hw/arm/virt: Let virt support pci hotplug/unplug GED event hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks hw/arm/virt: Use ACPI PCI hotplug by defaulthw/i386/acpi-build.h | 4 - include/hw/acpi/aml-build.h | 2 +
include/hw/acpi/generic_event_device.h| 5 + include/hw/acpi/pci.h | 4 +- include/hw/acpi/pcihp.h | 14 + include/hw/arm/virt.h | 4 + include/hw/pci-host/gpex.h | 1 + include/hw/sysbus.h | 1 + hw/acpi/aml-build.c | 50 +++ hw/acpi/generic_event_device.c | 64 +++- hw/acpi/pci.c | 20 ++ hw/acpi/pcihp.c | 428 +++++++++++++++++++++- hw/arm/virt-acpi-build.c | 26 ++ hw/arm/virt.c | 100 +++++- hw/core/sysbus.c | 11 + hw/i386/acpi-build.c | 475 +------------------------ hw/pci-host/gpex-acpi.c | 75 +--- hw/pci/pcie_port.c | 4 +- hw/arm/Kconfig | 2 +19 files changed, 748 insertions(+), 542 deletions(-)
Hi Gustavo,
Quoted 141 lines · Gustavo Romero
Hi Eric,
Quoted 22 lines · Eric Auger
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from
hw/i386/acpi-build.cto a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Quoted 7 lines
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/I've just started to review your series and went to a quick smoke test by hotplugging a net adapter and got the following kernel internal error:
(qemu)
device_addvirtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class0x020000
[ 64.165895] pci 0000:01:00.0: reg0x14: [mem 0x00000000-0x00000fff] [ 64.166259] pci 0000:01:00.0: reg0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 64.166658] pci 0000:01:00.0: reg0x30: [mem 0x00000000-0x0003ffff pref]
[ 64.167153] pci 0000:01:00.0: enabling Extended Tags
[ 64.179972] Internal error: synchronous external abort:
0000000096000050 [#1] SMP
[ 64.180719] Modules linked in:aes_ce_blkaes_ce_cipherpolyval_cepolyval_genericghash_cegf128mulsha2_cebinfmt_miscsha256_arm64sha1_cenls_asciinls_cp437vfat fat evdev cfg80211 rfkill loop fuseefi_pstoredrmdm_moddax configfs efivarfsqemu_fw_cfgip_tablesx_tablesautofs4 ext4 crc16 mbcache jbd2crc32c_genericvirtio_scsivirtio_netscsi_modnet_failoverfailovervirtio_blkscsi_commoncrct10dif_cecrct10dif_commonvirtio_pcivirtio_pci_legacy_devvirtio_pci_modern_devvirtio_mmio
[ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1
[ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 64.184759] Workqueue:kacpi_hotplugacpi_hotplug_work_fn[ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 64.185737] pc :acpi_ex_system_memory_space_handler+0x290/0x300[ 64.186175] lr :acpi_ev_address_space_dispatch+0x124/0x334[ 64.186490] sp :ffff80000a6bb3b0
[ 64.186663] x29:ffff80000a6bb3b0x28:ffff0003fcbb08b8x27:
0000000000000000
[ 64.187126] x26:ffff0003fcbb0288x25:ffff80000a6bb568x24:
0000000000000001
[ 64.187499] x23:ffff80000a6bb568x22: 0000000000000004 x21:ffff0000c206cb00
[ 64.187885] x20:00000000090c0014x19: 0000000000000020 x18:
0000000000000000
[ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
0000000000000000
[ 64.188640] x14: 0000000000000000 x13:4d43c3194dea1791x12:4d7a3553e5c937d0
[ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :ffff800008735b34
[ 64.189383] x8 : 0000000000000001 x7 :ffff80000873c850x6 :00000000000000f8
[ 64.189778] x5 :ffff0000c206cb00x4 : 0000000000000000 x3 :00000000090c0018
[ 64.190163] x2 :ffff80000a9af014x1 :00000000090c0018x0 :
0000000000000001
[ 64.190734] Call trace:
[ 64.191086]acpi_ex_system_memory_space_handler+0x290/0x300[ 64.191696]acpi_ev_address_space_dispatch+0x124/0x334[ 64.192042]acpi_ex_access_region+0xe4/0x2e0
[ 64.192287]acpi_ex_field_datum_io+0x88/0x200
[ 64.192509]acpi_ex_write_with_update_rule+0xd4/0x120
[ 64.192793]acpi_ex_insert_into_field+0x210/0x2b0
[ 64.193048]acpi_ex_write_data_to_field+0xa0/0x190
[ 64.193298]acpi_ex_store_object_to_node+0x150/0x240
[ 64.193527]acpi_ex_store+0x144/0x300
[ 64.193726]acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 64.193971]acpi_ds_exec_end_op+0x24c/0x4b0
[ 64.194227]acpi_ps_parse_loop+0x100/0x6a0
[ 64.194477]acpi_ps_parse_aml+0x94/0x3b0
[ 64.194674]acpi_ps_execute_method+0x128/0x25c
[ 64.194922]acpi_ns_evaluate+0x1f0/0x2d0
[ 64.195148]acpi_evaluate_object+0x138/0x2d0
[ 64.195380]acpi_evaluate_dsm+0xb8/0x134
[ 64.195613]acpi_check_dsm+0x34/0xdc
[ 64.195822]smbios_attr_is_visible+0x5c/0xb0
[ 64.196089]internal_create_group+0xd0/0x3d0
[ 64.196335]internal_create_groups+0x58/0xe0
[ 64.196584]sysfs_create_groups+0x20/0x30
[ 64.196813]device_add_groups+0x18/0x2c
[ 64.197039]bus_add_device+0x48/0x160
[ 64.197260]device_add+0x3a4/0x85c
[ 64.197463]pci_device_add+0x308/0x660
[ 64.197680]pci_scan_single_device+0xe4/0x114
[ 64.197941]pci_scan_slot+0x70/0x1fc
[ 64.198155]acpiphp_rescan_slot+0x90/0xa4
[ 64.198366]acpiphp_hotplug_notify+0x2a8/0x300
[ 64.198584]acpi_device_hotplug+0x138/0x4c0
[ 64.198819]acpi_hotplug_work_fn+0x2c/0x4c
[ 64.199045]process_one_work+0x1f4/0x460
[ 64.199277]worker_thread+0x188/0x4e0
[ 64.199492]kthread+0xe0/0xe4
[ 64.199671]ret_from_fork+0x10/0x20
[ 64.200114] Code:f90002e05280000017ffff97f94002e0(b9000040) [ 64.200820] ---[ end trace 0000000000000000 ]---(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fd
Quoted 2 lines
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
I have just tested debian-12-nocloud-arm64.qcow2 which features 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to hotplug/hot-unplug the virtio-net-pci device. Can you retry without
-initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" ?
Cheers
Eric
Quoted 61 lines
It seems Linux acpi crashed when ingesting the
_DSMmethod but I could not
figure out what exactly in it could cause it.Cheers,
GustavoQuoted 51 lines
Eric Auger (24):
hw/pci/pcie_port: Fixpcie_slot_is_hotpluggbale_bustypo hw/acpi/ged: Fix wrong identation
hw/i386/acpi-build: Fixbuild_append_notfication_callbacktypo hw/i386/acpi-build: Makeaml_pci_device_dsm()static hw/arm/virt: Introduce machine state acpi pcihp flags and props hw/acpi: Rename and movebuild_x86_acpi_pci_hotplugto pcihp hw/pci-host/gpex-acpi: Addnative_pci_hotplugarg toacpi_dsdt_add_pci_osc
hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
hw/i386/acpi-build: Turnbuild_q35_osc_methodinto a generic method hw/pci-host/gpex-acpi: Usebuild_pci_host_bridge_osc_methodhw/i386/acpi-build: Introducebuild_append_pcihp_resources()helper hw/acpi/pcihp: Add an AmlRegionSpace arg tobuild_acpi_pci_hotplughw/i386/acpi-build: Movebuild_append_notification_callbackto pcihp hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp hw/i386/acpi-build: Introduce and useacpi_get_pci_hosthw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug hw/acpi/ged: Prepare the device to react to PCI hotplug events hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation
hw/acpi/ged: Support migration of AcpiPciHpState hw/core/sysbus: Introducesysbus_mmio_map_name()helper hw/arm/virt: Let virt support pci hotplug/unplug GED event hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks hw/arm/virt: Use ACPI PCI hotplug by defaulthw/i386/acpi-build.h | 4 - include/hw/acpi/aml-build.h | 2 +
include/hw/acpi/generic_event_device.h| 5 + include/hw/acpi/pci.h | 4 +- include/hw/acpi/pcihp.h | 14 + include/hw/arm/virt.h | 4 + include/hw/pci-host/gpex.h | 1 + include/hw/sysbus.h | 1 + hw/acpi/aml-build.c | 50 +++ hw/acpi/generic_event_device.c | 64 +++- hw/acpi/pci.c | 20 ++ hw/acpi/pcihp.c | 428 +++++++++++++++++++++- hw/arm/virt-acpi-build.c | 26 ++ hw/arm/virt.c | 100 +++++- hw/core/sysbus.c | 11 + hw/i386/acpi-build.c | 475 +------------------------ hw/pci-host/gpex-acpi.c | 75 +--- hw/pci/pcie_port.c | 4 +- hw/arm/Kconfig | 2 +19 files changed, 748 insertions(+), 542 deletions(-)
Quoted 147 lines · Eric Auger
Hi Gustavo,
Quoted 141 lines · Gustavo Romero
Hi Eric,
Quoted 22 lines · Eric Auger
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from
hw/i386/acpi-build.cto a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Quoted 7 lines
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/I've just started to review your series and went to a quick smoke test by hotplugging a net adapter and got the following kernel internal error:
(qemu)
device_addvirtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class0x020000
[ 64.165895] pci 0000:01:00.0: reg0x14: [mem 0x00000000-0x00000fff] [ 64.166259] pci 0000:01:00.0: reg0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 64.166658] pci 0000:01:00.0: reg0x30: [mem 0x00000000-0x0003ffff pref]
[ 64.167153] pci 0000:01:00.0: enabling Extended Tags
[ 64.179972] Internal error: synchronous external abort:
0000000096000050 [#1] SMP
[ 64.180719] Modules linked in:aes_ce_blkaes_ce_cipherpolyval_cepolyval_genericghash_cegf128mulsha2_cebinfmt_miscsha256_arm64sha1_cenls_asciinls_cp437vfat fat evdev cfg80211 rfkill loop fuseefi_pstoredrmdm_moddax configfs efivarfsqemu_fw_cfgip_tablesx_tablesautofs4 ext4 crc16 mbcache jbd2crc32c_genericvirtio_scsivirtio_netscsi_modnet_failoverfailovervirtio_blkscsi_commoncrct10dif_cecrct10dif_commonvirtio_pcivirtio_pci_legacy_devvirtio_pci_modern_devvirtio_mmio
[ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1
[ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 64.184759] Workqueue:kacpi_hotplugacpi_hotplug_work_fn[ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 64.185737] pc :acpi_ex_system_memory_space_handler+0x290/0x300[ 64.186175] lr :acpi_ev_address_space_dispatch+0x124/0x334[ 64.186490] sp :ffff80000a6bb3b0
[ 64.186663] x29:ffff80000a6bb3b0x28:ffff0003fcbb08b8x27:
0000000000000000
[ 64.187126] x26:ffff0003fcbb0288x25:ffff80000a6bb568x24:
0000000000000001
[ 64.187499] x23:ffff80000a6bb568x22: 0000000000000004 x21:ffff0000c206cb00
[ 64.187885] x20:00000000090c0014x19: 0000000000000020 x18:
0000000000000000
[ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
0000000000000000
[ 64.188640] x14: 0000000000000000 x13:4d43c3194dea1791x12:4d7a3553e5c937d0
[ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :ffff800008735b34
[ 64.189383] x8 : 0000000000000001 x7 :ffff80000873c850x6 :00000000000000f8
[ 64.189778] x5 :ffff0000c206cb00x4 : 0000000000000000 x3 :00000000090c0018
[ 64.190163] x2 :ffff80000a9af014x1 :00000000090c0018x0 :
0000000000000001
[ 64.190734] Call trace:
[ 64.191086]acpi_ex_system_memory_space_handler+0x290/0x300[ 64.191696]acpi_ev_address_space_dispatch+0x124/0x334[ 64.192042]acpi_ex_access_region+0xe4/0x2e0
[ 64.192287]acpi_ex_field_datum_io+0x88/0x200
[ 64.192509]acpi_ex_write_with_update_rule+0xd4/0x120
[ 64.192793]acpi_ex_insert_into_field+0x210/0x2b0
[ 64.193048]acpi_ex_write_data_to_field+0xa0/0x190
[ 64.193298]acpi_ex_store_object_to_node+0x150/0x240
[ 64.193527]acpi_ex_store+0x144/0x300
[ 64.193726]acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 64.193971]acpi_ds_exec_end_op+0x24c/0x4b0
[ 64.194227]acpi_ps_parse_loop+0x100/0x6a0
[ 64.194477]acpi_ps_parse_aml+0x94/0x3b0
[ 64.194674]acpi_ps_execute_method+0x128/0x25c
[ 64.194922]acpi_ns_evaluate+0x1f0/0x2d0
[ 64.195148]acpi_evaluate_object+0x138/0x2d0
[ 64.195380]acpi_evaluate_dsm+0xb8/0x134
[ 64.195613]acpi_check_dsm+0x34/0xdc
[ 64.195822]smbios_attr_is_visible+0x5c/0xb0
[ 64.196089]internal_create_group+0xd0/0x3d0
[ 64.196335]internal_create_groups+0x58/0xe0
[ 64.196584]sysfs_create_groups+0x20/0x30
[ 64.196813]device_add_groups+0x18/0x2c
[ 64.197039]bus_add_device+0x48/0x160
[ 64.197260]device_add+0x3a4/0x85c
[ 64.197463]pci_device_add+0x308/0x660
[ 64.197680]pci_scan_single_device+0xe4/0x114
[ 64.197941]pci_scan_slot+0x70/0x1fc
[ 64.198155]acpiphp_rescan_slot+0x90/0xa4
[ 64.198366]acpiphp_hotplug_notify+0x2a8/0x300
[ 64.198584]acpi_device_hotplug+0x138/0x4c0
[ 64.198819]acpi_hotplug_work_fn+0x2c/0x4c
[ 64.199045]process_one_work+0x1f4/0x460
[ 64.199277]worker_thread+0x188/0x4e0
[ 64.199492]kthread+0xe0/0xe4
[ 64.199671]ret_from_fork+0x10/0x20
[ 64.200114] Code:f90002e05280000017ffff97f94002e0(b9000040) [ 64.200820] ---[ end trace 0000000000000000 ]---(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fdQuoted 2 lines
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
Quoted 7 lines
I have just tested debian-12-nocloud-arm64.qcow2 which features 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to hotplug/hot-unplug the virtio-net-pci device. Can you retry without
-initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" ?
Also tried with an upstream kernel 6.15-rc3 and it works for me:
/home/augere/UPSTREAM/acpipcihp-qemu/build/qemu-system-aarch64 -M virt,acpi-pcihp=on,gic-version=host -cpu max -smp 8 -m
16G,maxmem=32G,slots=3 -display none --enable-kvm -serial
tcp:localhost:4444,server -device
pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -device pcie-root-port,bus=pcie.0,chassis=2,id=pcie.2,addr=0x3.0x0 -device pcie-root-port,bus=pcie.0,chassis=3,id=pcie.3,addr=0x4.0x0 -device pcie-root-port,bus=pcie.0,chassis=4,id=pcie.4,addr=0x5.0x0 -device pcie-root-port,bus=pcie.0,chassis=5,id=pcie.5,addr=0x6.0x0 -netdev tap,id=nic1,script=/home/augere/TEST/SCRIPTS/qemu-ifup,downscript=/home/augere/TEST/SCRIPTS/qemu-ifdown -qmp unix:/home/augere/TEST/QEMU/qmp-sock,server,nowait -drive file=/home/nfs_vm/UEFI/edk2-aarch64-code.fd,if=pflash,format=raw,unit=0,readonly=on
-drive file=/home/nfs_vm/UEFI/vars,if=pflash,format=raw,unit=1 -device virtio-blk-pci,bus=pcie.4,drive=drv0,id=virtio-disk0,bootindex=1,werror=stop,rerror=stop -drive file=/home/nfs_vm/IMAGES/aarch64/debian-12-nocloud-arm64.qcow2,format=qcow2,if=none,cache=writethrough,id=drv0 -kernel /home/nfs_vm/BOOT/aarch64/vmlinuz-6.15.0-rc3-acpi-hp-guest+
-initrd /home/nfs_vm/BOOT/aarch64/initrd.img-6.15.0-rc3-acpi-hp-guest+
-append 'root=/dev/vda1 console=ttyAMA0,115200 acpi=force earlyprintk
iommu.strict=no acpi=force' -net none -d guest_errors
(QEMU) device_add driver=virtio-net-pci bus=pcie.1 netdev=nic1 mac=6a:f5:10:b1:3d:d3 id=net
Cheers
Eric
Quoted 66 lines
Cheers
Eric
Quoted 61 lines
It seems Linux acpi crashed when ingesting the
_DSMmethod but I could not
figure out what exactly in it could cause it.Cheers,
GustavoQuoted 51 lines
Eric Auger (24):
hw/pci/pcie_port: Fixpcie_slot_is_hotpluggbale_bustypo hw/acpi/ged: Fix wrong identation
hw/i386/acpi-build: Fixbuild_append_notfication_callbacktypo hw/i386/acpi-build: Makeaml_pci_device_dsm()static hw/arm/virt: Introduce machine state acpi pcihp flags and props hw/acpi: Rename and movebuild_x86_acpi_pci_hotplugto pcihp hw/pci-host/gpex-acpi: Addnative_pci_hotplugarg toacpi_dsdt_add_pci_osc
hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
hw/i386/acpi-build: Turnbuild_q35_osc_methodinto a generic method hw/pci-host/gpex-acpi: Usebuild_pci_host_bridge_osc_methodhw/i386/acpi-build: Introducebuild_append_pcihp_resources()helper hw/acpi/pcihp: Add an AmlRegionSpace arg tobuild_acpi_pci_hotplughw/i386/acpi-build: Movebuild_append_notification_callbackto pcihp hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp hw/i386/acpi-build: Introduce and useacpi_get_pci_hosthw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug hw/acpi/ged: Prepare the device to react to PCI hotplug events hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation
hw/acpi/ged: Support migration of AcpiPciHpState hw/core/sysbus: Introducesysbus_mmio_map_name()helper hw/arm/virt: Let virt support pci hotplug/unplug GED event hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks hw/arm/virt: Use ACPI PCI hotplug by defaulthw/i386/acpi-build.h | 4 - include/hw/acpi/aml-build.h | 2 +
include/hw/acpi/generic_event_device.h| 5 + include/hw/acpi/pci.h | 4 +- include/hw/acpi/pcihp.h | 14 + include/hw/arm/virt.h | 4 + include/hw/pci-host/gpex.h | 1 + include/hw/sysbus.h | 1 + hw/acpi/aml-build.c | 50 +++ hw/acpi/generic_event_device.c | 64 +++- hw/acpi/pci.c | 20 ++ hw/acpi/pcihp.c | 428 +++++++++++++++++++++- hw/arm/virt-acpi-build.c | 26 ++ hw/arm/virt.c | 100 +++++- hw/core/sysbus.c | 11 + hw/i386/acpi-build.c | 475 +------------------------ hw/pci-host/gpex-acpi.c | 75 +--- hw/pci/pcie_port.c | 4 +- hw/arm/Kconfig | 2 +19 files changed, 748 insertions(+), 542 deletions(-)
Hi Eric,
Quoted 147 lines · Eric Auger
Hi Gustavo,
Quoted 141 lines · Gustavo Romero
Hi Eric,
Quoted 22 lines · Eric Auger
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from
hw/i386/acpi-build.cto a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Quoted 7 lines
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/I've just started to review your series and went to a quick smoke test by hotplugging a net adapter and got the following kernel internal error:
(qemu)
device_addvirtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class0x020000
[ 64.165895] pci 0000:01:00.0: reg0x14: [mem 0x00000000-0x00000fff] [ 64.166259] pci 0000:01:00.0: reg0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 64.166658] pci 0000:01:00.0: reg0x30: [mem 0x00000000-0x0003ffff pref]
[ 64.167153] pci 0000:01:00.0: enabling Extended Tags
[ 64.179972] Internal error: synchronous external abort:
0000000096000050 [#1] SMP
[ 64.180719] Modules linked in:aes_ce_blkaes_ce_cipherpolyval_cepolyval_genericghash_cegf128mulsha2_cebinfmt_miscsha256_arm64sha1_cenls_asciinls_cp437vfat fat evdev cfg80211 rfkill loop fuseefi_pstoredrmdm_moddax configfs efivarfsqemu_fw_cfgip_tablesx_tablesautofs4 ext4 crc16 mbcache jbd2crc32c_genericvirtio_scsivirtio_netscsi_modnet_failoverfailovervirtio_blkscsi_commoncrct10dif_cecrct10dif_commonvirtio_pcivirtio_pci_legacy_devvirtio_pci_modern_devvirtio_mmio
[ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1
[ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 64.184759] Workqueue:kacpi_hotplugacpi_hotplug_work_fn[ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 64.185737] pc :acpi_ex_system_memory_space_handler+0x290/0x300[ 64.186175] lr :acpi_ev_address_space_dispatch+0x124/0x334[ 64.186490] sp :ffff80000a6bb3b0
[ 64.186663] x29:ffff80000a6bb3b0x28:ffff0003fcbb08b8x27:
0000000000000000
[ 64.187126] x26:ffff0003fcbb0288x25:ffff80000a6bb568x24:
0000000000000001
[ 64.187499] x23:ffff80000a6bb568x22: 0000000000000004 x21:ffff0000c206cb00
[ 64.187885] x20:00000000090c0014x19: 0000000000000020 x18:
0000000000000000
[ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
0000000000000000
[ 64.188640] x14: 0000000000000000 x13:4d43c3194dea1791x12:4d7a3553e5c937d0
[ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :ffff800008735b34
[ 64.189383] x8 : 0000000000000001 x7 :ffff80000873c850x6 :00000000000000f8
[ 64.189778] x5 :ffff0000c206cb00x4 : 0000000000000000 x3 :00000000090c0018
[ 64.190163] x2 :ffff80000a9af014x1 :00000000090c0018x0 :
0000000000000001
[ 64.190734] Call trace:
[ 64.191086]acpi_ex_system_memory_space_handler+0x290/0x300[ 64.191696]acpi_ev_address_space_dispatch+0x124/0x334[ 64.192042]acpi_ex_access_region+0xe4/0x2e0
[ 64.192287]acpi_ex_field_datum_io+0x88/0x200
[ 64.192509]acpi_ex_write_with_update_rule+0xd4/0x120
[ 64.192793]acpi_ex_insert_into_field+0x210/0x2b0
[ 64.193048]acpi_ex_write_data_to_field+0xa0/0x190
[ 64.193298]acpi_ex_store_object_to_node+0x150/0x240
[ 64.193527]acpi_ex_store+0x144/0x300
[ 64.193726]acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 64.193971]acpi_ds_exec_end_op+0x24c/0x4b0
[ 64.194227]acpi_ps_parse_loop+0x100/0x6a0
[ 64.194477]acpi_ps_parse_aml+0x94/0x3b0
[ 64.194674]acpi_ps_execute_method+0x128/0x25c
[ 64.194922]acpi_ns_evaluate+0x1f0/0x2d0
[ 64.195148]acpi_evaluate_object+0x138/0x2d0
[ 64.195380]acpi_evaluate_dsm+0xb8/0x134
[ 64.195613]acpi_check_dsm+0x34/0xdc
[ 64.195822]smbios_attr_is_visible+0x5c/0xb0
[ 64.196089]internal_create_group+0xd0/0x3d0
[ 64.196335]internal_create_groups+0x58/0xe0
[ 64.196584]sysfs_create_groups+0x20/0x30
[ 64.196813]device_add_groups+0x18/0x2c
[ 64.197039]bus_add_device+0x48/0x160
[ 64.197260]device_add+0x3a4/0x85c
[ 64.197463]pci_device_add+0x308/0x660
[ 64.197680]pci_scan_single_device+0xe4/0x114
[ 64.197941]pci_scan_slot+0x70/0x1fc
[ 64.198155]acpiphp_rescan_slot+0x90/0xa4
[ 64.198366]acpiphp_hotplug_notify+0x2a8/0x300
[ 64.198584]acpi_device_hotplug+0x138/0x4c0
[ 64.198819]acpi_hotplug_work_fn+0x2c/0x4c
[ 64.199045]process_one_work+0x1f4/0x460
[ 64.199277]worker_thread+0x188/0x4e0
[ 64.199492]kthread+0xe0/0xe4
[ 64.199671]ret_from_fork+0x10/0x20
[ 64.200114] Code:f90002e05280000017ffff97f94002e0(b9000040) [ 64.200820] ---[ end trace 0000000000000000 ]---(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fdQuoted 2 lines
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
Quoted 7 lines
I have just tested debian-12-nocloud-arm64.qcow2 which features 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to hotplug/hot-unplug the virtio-net-pci device. Can you retry without
-initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" ?
Sure, so I got the same internal error without passing the kernel, the initrd, and the append command.
I also tried with a pristine Debian .qcow2 taken from:
https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.qcow2
I'm building your Github branch:
gromero@gromero0:/mnt/git/qemu_/build$ git branch -vv | grep eauger * arm-acpi-pcihp-rfc cf92b293ff [eauger/arm-acpi-pcihp-rfc] hw/arm/virt: Use ACPI PCI hotplug by default gromero@gromero0:/mnt/git/qemu_/build$ git log --oneline -1 cf92b293ff (HEAD -> arm-acpi-pcihp-rfc, eauger/arm-acpi-pcihp-rfc) hw/arm/virt: Use ACPI PCI hotplug by default
I tried in a pristine ./build dir.
QEMU options:
gromero@gromero0:/mnt/git/qemu_/build$ ./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu max -drive if=none,file=/mnt/debian/debian-12-nocloud-arm64.qcow2,format=qcow2,id=hd -device virtio-blk-device,drive=hd -device pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -bios ./pc-bios/edk2-aarch64-code.fd UEFI firmware (version edk2-stable202408-prebuilt.qemu.org built at 16:28:50 on Sep 12 2024)
gromero@gromero0:/mnt/git/qemu_/build$ md5sum ./pc-bios/edk2-aarch64-code.fd 3426cd25efb1593f86352ec0c61d66f5 ./pc-bios/edk2-aarch64-code.fd
and I get the same error:
root@localhost:~# QEMU 10.0.50 monitor - type 'help' for more information (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 56.865284] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000 [ 56.866620] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff] [ 56.867711] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref] [ 56.868287] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref] [ 56.869143] pci 0000:01:00.0: enabling Extended Tags [ 56.900481] Internal error: synchronous external abort: 0000000096000050 [#1] SMP [ 56.900911] Modules linked in: aes_ce_blk binfmt_misc aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha3_ce sha3_generic sha512_ce sha512_arm64 sha2_ce sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse drm efi_pstore dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_net net_failover failover virtio_blk crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio [ 56.903132] CPU: 0 PID: 10 Comm: kworker/u2:0 Not tainted 6.1.0-34-arm64 #1 Debian 6.1.135-1 [ 56.903753] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024 [ 56.904126] Workqueue: kacpi_hotplug acpi_hotplug_work_fn [ 56.904877] pstate: 60402005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 56.905085] pc : acpi_ex_system_memory_space_handler+0x290/0x300 [ 56.905306] lr : acpi_ev_address_space_dispatch+0x124/0x334 [ 56.905471] sp : ffff80000809b3b0 [ 56.905580] x29: ffff80000809b3b0 x28: ffff0003fcb852d0 x27: 0000000000000000 [ 56.905856] x26: ffff0003fcb85558 x25: ffff80000809b568 x24: 0000000000000001 [ 56.906092] x23: ffff80000809b568 x22: 0000000000000004 x21: ffff0000c1644980 [ 56.906333] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000 [ 56.906557] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 [ 56.906793] x14: 0000000000000000 x13: ffffb8324c78ebb0 x12: 0000000000000001 [ 56.907016] x11: 000000000000002e x10: ffffb8324cab6e20 x9 : ffffb8324b2076b4 [ 56.907236] x8 : 0000000000000001 x7 : ffffb8324b20e3d0 x6 : 00000000000000f8 [ 56.907473] x5 : ffff0000c1644980 x4 : 0000000000000000 x3 : 00000000090c0018 [ 56.907705] x2 : ffff800008837014 x1 : 00000000090c0018 x0 : 0000000000000001 [ 56.908026] Call trace: [ 56.908226] acpi_ex_system_memory_space_handler+0x290/0x300 [ 56.908540] acpi_ev_address_space_dispatch+0x124/0x334 [ 56.908736] acpi_ex_access_region+0xe4/0x2e0 [ 56.908870] acpi_ex_field_datum_io+0x88/0x200 [ 56.909003] acpi_ex_write_with_update_rule+0xd4/0x120 [ 56.909152] acpi_ex_insert_into_field+0x210/0x2b0 [ 56.909285] acpi_ex_write_data_to_field+0xa0/0x190 [ 56.909426] acpi_ex_store_object_to_node+0x150/0x240 [ 56.909569] acpi_ex_store+0x144/0x300 [ 56.909688] acpi_ex_opcode_1A_1T_1R+0x218/0x580 [ 56.909824] acpi_ds_exec_end_op+0x24c/0x4b0 [ 56.909953] acpi_ps_parse_loop+0x100/0x6a0 [ 56.910074] acpi_ps_parse_aml+0x94/0x3b0 [ 56.910197] acpi_ps_execute_method+0x128/0x25c [ 56.910331] acpi_ns_evaluate+0x1f0/0x2d0 [ 56.910445] acpi_evaluate_object+0x138/0x2d0 [ 56.910573] acpi_evaluate_dsm+0xb8/0x134 [ 56.910696] acpi_check_dsm+0x34/0xdc [ 56.910809] smbios_attr_is_visible+0x5c/0xb0 [ 56.910937] internal_create_group+0xd0/0x3d0 [ 56.911066] internal_create_groups+0x58/0xe0 [ 56.911194] sysfs_create_groups+0x20/0x30 [ 56.911315] device_add_groups+0x18/0x2c [ 56.911435] bus_add_device+0x48/0x160 [ 56.911552] device_add+0x3a4/0x85c [ 56.911678] pci_device_add+0x308/0x660 [ 56.911803] pci_scan_single_device+0xe4/0x114 [ 56.911937] pci_scan_slot+0x70/0x1fc [ 56.912039] acpiphp_rescan_slot+0x90/0xa4 [ 56.912161] acpiphp_hotplug_notify+0x2a8/0x300 [ 56.912290] acpi_device_hotplug+0x138/0x4c0 [ 56.912428] acpi_hotplug_work_fn+0x2c/0x4c [ 56.912549] process_one_work+0x1f4/0x460 [ 56.912679] worker_thread+0x188/0x4e0 [ 56.912792] kthread+0xe0/0xe4 [ 56.912892] ret_from_fork+0x10/0x20 [ 56.913136] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040) [ 56.913532] ---[ end trace 0000000000000000 ]---
I'm wondering if we are using the same ./pc-bios/edk2-aarch64-code.fd, although I can't see how it would cause such error.
Cheers,
Gustavo
Hi Eric,
Quoted 252 lines · Gustavo Romero
Hi Eric,
Quoted 147 lines · Eric Auger
Hi Gustavo,
Quoted 141 lines · Gustavo Romero
Hi Eric,
Quoted 22 lines · Eric Auger
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from
hw/i386/acpi-build.cto a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Quoted 7 lines
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/I've just started to review your series and went to a quick smoke test by hotplugging a net adapter and got the following kernel internal error:
(qemu)
device_addvirtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class0x020000
[ 64.165895] pci 0000:01:00.0: reg0x14: [mem 0x00000000-0x00000fff] [ 64.166259] pci 0000:01:00.0: reg0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 64.166658] pci 0000:01:00.0: reg0x30: [mem 0x00000000-0x0003ffff pref]
[ 64.167153] pci 0000:01:00.0: enabling Extended Tags
[ 64.179972] Internal error: synchronous external abort:
0000000096000050 [#1] SMP
[ 64.180719] Modules linked in:aes_ce_blkaes_ce_cipherpolyval_cepolyval_genericghash_cegf128mulsha2_cebinfmt_miscsha256_arm64sha1_cenls_asciinls_cp437vfat fat evdev cfg80211 rfkill loop fuseefi_pstoredrmdm_moddax configfs efivarfsqemu_fw_cfgip_tablesx_tablesautofs4 ext4 crc16 mbcache jbd2crc32c_genericvirtio_scsivirtio_netscsi_modnet_failoverfailovervirtio_blkscsi_commoncrct10dif_cecrct10dif_commonvirtio_pcivirtio_pci_legacy_devvirtio_pci_modern_devvirtio_mmio
[ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1
[ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 64.184759] Workqueue:kacpi_hotplugacpi_hotplug_work_fn[ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 64.185737] pc :acpi_ex_system_memory_space_handler+0x290/0x300[ 64.186175] lr :acpi_ev_address_space_dispatch+0x124/0x334[ 64.186490] sp :ffff80000a6bb3b0
[ 64.186663] x29:ffff80000a6bb3b0x28:ffff0003fcbb08b8x27:
0000000000000000
[ 64.187126] x26:ffff0003fcbb0288x25:ffff80000a6bb568x24:
0000000000000001
[ 64.187499] x23:ffff80000a6bb568x22: 0000000000000004 x21:ffff0000c206cb00
[ 64.187885] x20:00000000090c0014x19: 0000000000000020 x18:
0000000000000000
[ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
0000000000000000
[ 64.188640] x14: 0000000000000000 x13:4d43c3194dea1791x12:4d7a3553e5c937d0
[ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :ffff800008735b34
[ 64.189383] x8 : 0000000000000001 x7 :ffff80000873c850x6 :00000000000000f8
[ 64.189778] x5 :ffff0000c206cb00x4 : 0000000000000000 x3 :00000000090c0018
[ 64.190163] x2 :ffff80000a9af014x1 :00000000090c0018x0 :
0000000000000001
[ 64.190734] Call trace:
[ 64.191086]acpi_ex_system_memory_space_handler+0x290/0x300[ 64.191696]acpi_ev_address_space_dispatch+0x124/0x334[ 64.192042]acpi_ex_access_region+0xe4/0x2e0
[ 64.192287]acpi_ex_field_datum_io+0x88/0x200
[ 64.192509]acpi_ex_write_with_update_rule+0xd4/0x120
[ 64.192793]acpi_ex_insert_into_field+0x210/0x2b0
[ 64.193048]acpi_ex_write_data_to_field+0xa0/0x190
[ 64.193298]acpi_ex_store_object_to_node+0x150/0x240
[ 64.193527]acpi_ex_store+0x144/0x300
[ 64.193726]acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 64.193971]acpi_ds_exec_end_op+0x24c/0x4b0
[ 64.194227]acpi_ps_parse_loop+0x100/0x6a0
[ 64.194477]acpi_ps_parse_aml+0x94/0x3b0
[ 64.194674]acpi_ps_execute_method+0x128/0x25c
[ 64.194922]acpi_ns_evaluate+0x1f0/0x2d0
[ 64.195148]acpi_evaluate_object+0x138/0x2d0
[ 64.195380]acpi_evaluate_dsm+0xb8/0x134
[ 64.195613]acpi_check_dsm+0x34/0xdc
[ 64.195822]smbios_attr_is_visible+0x5c/0xb0
[ 64.196089]internal_create_group+0xd0/0x3d0
[ 64.196335]internal_create_groups+0x58/0xe0
[ 64.196584]sysfs_create_groups+0x20/0x30
[ 64.196813]device_add_groups+0x18/0x2c
[ 64.197039]bus_add_device+0x48/0x160
[ 64.197260]device_add+0x3a4/0x85c
[ 64.197463]pci_device_add+0x308/0x660
[ 64.197680]pci_scan_single_device+0xe4/0x114
[ 64.197941]pci_scan_slot+0x70/0x1fc
[ 64.198155]acpiphp_rescan_slot+0x90/0xa4
[ 64.198366]acpiphp_hotplug_notify+0x2a8/0x300
[ 64.198584]acpi_device_hotplug+0x138/0x4c0
[ 64.198819]acpi_hotplug_work_fn+0x2c/0x4c
[ 64.199045]process_one_work+0x1f4/0x460
[ 64.199277]worker_thread+0x188/0x4e0
[ 64.199492]kthread+0xe0/0xe4
[ 64.199671]ret_from_fork+0x10/0x20
[ 64.200114] Code:f90002e05280000017ffff97f94002e0(b9000040) [ 64.200820] ---[ end trace 0000000000000000 ]---(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fdQuoted 2 lines
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
Quoted 7 lines
I have just tested debian-12-nocloud-arm64.qcow2 which features 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to hotplug/hot-unplug the virtio-net-pci device. Can you retry without
-initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" ?Sure, so I got the same internal error without passing the kernel, the initrd, and the append command.
I also tried with a pristine Debian .qcow2 taken from:
https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.qcow2
I'm building your Github branch:
gromero@gromero0:/mnt/git/qemu_/build$ git branch -vv | grep eauger * arm-acpi-pcihp-rfc cf92b293ff [eauger/arm-acpi-pcihp-rfc] hw/arm/virt: Use ACPI PCI hotplug by default gromero@gromero0:/mnt/git/qemu_/build$ git log --oneline -1 cf92b293ff (HEAD -> arm-acpi-pcihp-rfc, eauger/arm-acpi-pcihp-rfc) hw/arm/virt: Use ACPI PCI hotplug by defaultI tried in a pristine ./build dir.
QEMU options:
gromero@gromero0:/mnt/git/qemu_/build$ ./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu max -drive if=none,file=/mnt/debian/debian-12-nocloud-arm64.qcow2,format=qcow2,id=hd -device virtio-blk-device,drive=hd -device pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -bios ./pc-bios/edk2-aarch64-code.fd UEFI firmware (version edk2-stable202408-prebuilt.qemu.org built at 16:28:50 on Sep 12 2024)gromero@gromero0:/mnt/git/qemu_/build$ md5sum ./pc-bios/edk2-aarch64-code.fd 3426cd25efb1593f86352ec0c61d66f5 ./pc-bios/edk2-aarch64-code.fdand I get the same error:
root@localhost:~# QEMU 10.0.50 monitor - type 'help' for more information (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 56.865284] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000 [ 56.866620] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff] [ 56.867711] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref] [ 56.868287] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref] [ 56.869143] pci 0000:01:00.0: enabling Extended Tags [ 56.900481] Internal error: synchronous external abort: 0000000096000050 [#1] SMP [ 56.900911] Modules linked in: aes_ce_blk binfmt_misc aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha3_ce sha3_generic sha512_ce sha512_arm64 sha2_ce sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse drm efi_pstore dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_net net_failover failover virtio_blk crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio [ 56.903132] CPU: 0 PID: 10 Comm: kworker/u2:0 Not tainted 6.1.0-34-arm64 #1 Debian 6.1.135-1 [ 56.903753] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024 [ 56.904126] Workqueue: kacpi_hotplug acpi_hotplug_work_fn [ 56.904877] pstate: 60402005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 56.905085] pc : acpi_ex_system_memory_space_handler+0x290/0x300 [ 56.905306] lr : acpi_ev_address_space_dispatch+0x124/0x334 [ 56.905471] sp : ffff80000809b3b0 [ 56.905580] x29: ffff80000809b3b0 x28: ffff0003fcb852d0 x27: 0000000000000000 [ 56.905856] x26: ffff0003fcb85558 x25: ffff80000809b568 x24: 0000000000000001 [ 56.906092] x23: ffff80000809b568 x22: 0000000000000004 x21: ffff0000c1644980 [ 56.906333] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000 [ 56.906557] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 [ 56.906793] x14: 0000000000000000 x13: ffffb8324c78ebb0 x12: 0000000000000001 [ 56.907016] x11: 000000000000002e x10: ffffb8324cab6e20 x9 : ffffb8324b2076b4 [ 56.907236] x8 : 0000000000000001 x7 : ffffb8324b20e3d0 x6 : 00000000000000f8 [ 56.907473] x5 : ffff0000c1644980 x4 : 0000000000000000 x3 : 00000000090c0018 [ 56.907705] x2 : ffff800008837014 x1 : 00000000090c0018 x0 : 0000000000000001 [ 56.908026] Call trace: [ 56.908226] acpi_ex_system_memory_space_handler+0x290/0x300 [ 56.908540] acpi_ev_address_space_dispatch+0x124/0x334 [ 56.908736] acpi_ex_access_region+0xe4/0x2e0 [ 56.908870] acpi_ex_field_datum_io+0x88/0x200 [ 56.909003] acpi_ex_write_with_update_rule+0xd4/0x120 [ 56.909152] acpi_ex_insert_into_field+0x210/0x2b0 [ 56.909285] acpi_ex_write_data_to_field+0xa0/0x190 [ 56.909426] acpi_ex_store_object_to_node+0x150/0x240 [ 56.909569] acpi_ex_store+0x144/0x300 [ 56.909688] acpi_ex_opcode_1A_1T_1R+0x218/0x580 [ 56.909824] acpi_ds_exec_end_op+0x24c/0x4b0 [ 56.909953] acpi_ps_parse_loop+0x100/0x6a0 [ 56.910074] acpi_ps_parse_aml+0x94/0x3b0 [ 56.910197] acpi_ps_execute_method+0x128/0x25c [ 56.910331] acpi_ns_evaluate+0x1f0/0x2d0 [ 56.910445] acpi_evaluate_object+0x138/0x2d0 [ 56.910573] acpi_evaluate_dsm+0xb8/0x134 [ 56.910696] acpi_check_dsm+0x34/0xdc [ 56.910809] smbios_attr_is_visible+0x5c/0xb0 [ 56.910937] internal_create_group+0xd0/0x3d0 [ 56.911066] internal_create_groups+0x58/0xe0 [ 56.911194] sysfs_create_groups+0x20/0x30 [ 56.911315] device_add_groups+0x18/0x2c [ 56.911435] bus_add_device+0x48/0x160 [ 56.911552] device_add+0x3a4/0x85c [ 56.911678] pci_device_add+0x308/0x660 [ 56.911803] pci_scan_single_device+0xe4/0x114 [ 56.911937] pci_scan_slot+0x70/0x1fc [ 56.912039] acpiphp_rescan_slot+0x90/0xa4 [ 56.912161] acpiphp_hotplug_notify+0x2a8/0x300 [ 56.912290] acpi_device_hotplug+0x138/0x4c0 [ 56.912428] acpi_hotplug_work_fn+0x2c/0x4c [ 56.912549] process_one_work+0x1f4/0x460 [ 56.912679] worker_thread+0x188/0x4e0 [ 56.912792] kthread+0xe0/0xe4 [ 56.912892] ret_from_fork+0x10/0x20 [ 56.913136] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040) [ 56.913532] ---[ end trace 0000000000000000 ]---
Quoted 2 lines
I'm wondering if we are using the same ./pc-bios/edk2-aarch64-code.fd, although I can't see how it would cause such error.
hmm actually I'm able to properly hotplug the network device using the exactly same sw stack as above (your branch, Debian 12, edk2) but running on an arm64 host.
It seems your running on a arm64 host since you're passing --enable-kvm. Do you mind trying it on a x86_64 or without --enable-kvm on the arm64 host? I'm able to reproduce it on arm64 host without --enable-kvm but not with --enable-kvm passed to QEMU.
Cheers,
Gustavo
Hi Eric,
Quoted 258 lines · Gustavo Romero
Hi Eric,
Quoted 252 lines · Gustavo Romero
Hi Eric,
Quoted 147 lines · Eric Auger
Hi Gustavo,
Quoted 141 lines · Gustavo Romero
Hi Eric,
Quoted 22 lines · Eric Auger
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from
hw/i386/acpi-build.cto a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Quoted 7 lines
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/I've just started to review your series and went to a quick smoke test by hotplugging a net adapter and got the following kernel internal error:
(qemu)
device_addvirtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class0x020000
[ 64.165895] pci 0000:01:00.0: reg0x14: [mem 0x00000000-0x00000fff] [ 64.166259] pci 0000:01:00.0: reg0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 64.166658] pci 0000:01:00.0: reg0x30: [mem 0x00000000-0x0003ffff pref]
[ 64.167153] pci 0000:01:00.0: enabling Extended Tags
[ 64.179972] Internal error: synchronous external abort:
0000000096000050 [#1] SMP
[ 64.180719] Modules linked in:aes_ce_blkaes_ce_cipherpolyval_cepolyval_genericghash_cegf128mulsha2_cebinfmt_miscsha256_arm64sha1_cenls_asciinls_cp437vfat fat evdev cfg80211 rfkill loop fuseefi_pstoredrmdm_moddax configfs efivarfsqemu_fw_cfgip_tablesx_tablesautofs4 ext4 crc16 mbcache jbd2crc32c_genericvirtio_scsivirtio_netscsi_modnet_failoverfailovervirtio_blkscsi_commoncrct10dif_cecrct10dif_commonvirtio_pcivirtio_pci_legacy_devvirtio_pci_modern_devvirtio_mmio
[ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1
[ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 64.184759] Workqueue:kacpi_hotplugacpi_hotplug_work_fn[ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 64.185737] pc :acpi_ex_system_memory_space_handler+0x290/0x300[ 64.186175] lr :acpi_ev_address_space_dispatch+0x124/0x334[ 64.186490] sp :ffff80000a6bb3b0
[ 64.186663] x29:ffff80000a6bb3b0x28:ffff0003fcbb08b8x27:
0000000000000000
[ 64.187126] x26:ffff0003fcbb0288x25:ffff80000a6bb568x24:
0000000000000001
[ 64.187499] x23:ffff80000a6bb568x22: 0000000000000004 x21:ffff0000c206cb00
[ 64.187885] x20:00000000090c0014x19: 0000000000000020 x18:
0000000000000000
[ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
0000000000000000
[ 64.188640] x14: 0000000000000000 x13:4d43c3194dea1791x12:4d7a3553e5c937d0
[ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :ffff800008735b34
[ 64.189383] x8 : 0000000000000001 x7 :ffff80000873c850x6 :00000000000000f8
[ 64.189778] x5 :ffff0000c206cb00x4 : 0000000000000000 x3 :00000000090c0018
[ 64.190163] x2 :ffff80000a9af014x1 :00000000090c0018x0 :
0000000000000001
[ 64.190734] Call trace:
[ 64.191086]acpi_ex_system_memory_space_handler+0x290/0x300[ 64.191696]acpi_ev_address_space_dispatch+0x124/0x334[ 64.192042]acpi_ex_access_region+0xe4/0x2e0
[ 64.192287]acpi_ex_field_datum_io+0x88/0x200
[ 64.192509]acpi_ex_write_with_update_rule+0xd4/0x120
[ 64.192793]acpi_ex_insert_into_field+0x210/0x2b0
[ 64.193048]acpi_ex_write_data_to_field+0xa0/0x190
[ 64.193298]acpi_ex_store_object_to_node+0x150/0x240
[ 64.193527]acpi_ex_store+0x144/0x300
[ 64.193726]acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 64.193971]acpi_ds_exec_end_op+0x24c/0x4b0
[ 64.194227]acpi_ps_parse_loop+0x100/0x6a0
[ 64.194477]acpi_ps_parse_aml+0x94/0x3b0
[ 64.194674]acpi_ps_execute_method+0x128/0x25c
[ 64.194922]acpi_ns_evaluate+0x1f0/0x2d0
[ 64.195148]acpi_evaluate_object+0x138/0x2d0
[ 64.195380]acpi_evaluate_dsm+0xb8/0x134
[ 64.195613]acpi_check_dsm+0x34/0xdc
[ 64.195822]smbios_attr_is_visible+0x5c/0xb0
[ 64.196089]internal_create_group+0xd0/0x3d0
[ 64.196335]internal_create_groups+0x58/0xe0
[ 64.196584]sysfs_create_groups+0x20/0x30
[ 64.196813]device_add_groups+0x18/0x2c
[ 64.197039]bus_add_device+0x48/0x160
[ 64.197260]device_add+0x3a4/0x85c
[ 64.197463]pci_device_add+0x308/0x660
[ 64.197680]pci_scan_single_device+0xe4/0x114
[ 64.197941]pci_scan_slot+0x70/0x1fc
[ 64.198155]acpiphp_rescan_slot+0x90/0xa4
[ 64.198366]acpiphp_hotplug_notify+0x2a8/0x300
[ 64.198584]acpi_device_hotplug+0x138/0x4c0
[ 64.198819]acpi_hotplug_work_fn+0x2c/0x4c
[ 64.199045]process_one_work+0x1f4/0x460
[ 64.199277]worker_thread+0x188/0x4e0
[ 64.199492]kthread+0xe0/0xe4
[ 64.199671]ret_from_fork+0x10/0x20
[ 64.200114] Code:f90002e05280000017ffff97f94002e0(b9000040) [ 64.200820] ---[ end trace 0000000000000000 ]---(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fdQuoted 2 lines
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
Quoted 7 lines
I have just tested debian-12-nocloud-arm64.qcow2 which features 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to hotplug/hot-unplug the virtio-net-pci device. Can you retry without
-initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" ?Sure, so I got the same internal error without passing the kernel, the initrd, and the append command.
I also tried with a pristine Debian .qcow2 taken from:
https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.qcow2
I'm building your Github branch:
gromero@gromero0:/mnt/git/qemu_/build$ git branch -vv | grep eauger * arm-acpi-pcihp-rfc cf92b293ff [eauger/arm-acpi-pcihp-rfc] hw/arm/virt: Use ACPI PCI hotplug by default gromero@gromero0:/mnt/git/qemu_/build$ git log --oneline -1 cf92b293ff (HEAD -> arm-acpi-pcihp-rfc, eauger/arm-acpi-pcihp-rfc) hw/arm/virt: Use ACPI PCI hotplug by defaultI tried in a pristine ./build dir.
QEMU options:
gromero@gromero0:/mnt/git/qemu_/build$ ./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu max -drive if=none,file=/mnt/debian/debian-12-nocloud-arm64.qcow2,format=qcow2,id=hd -device virtio-blk-device,drive=hd -device pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -bios ./pc-bios/edk2-aarch64-code.fd UEFI firmware (version edk2-stable202408-prebuilt.qemu.org built at 16:28:50 on Sep 12 2024)gromero@gromero0:/mnt/git/qemu_/build$ md5sum ./pc-bios/edk2-aarch64-code.fd 3426cd25efb1593f86352ec0c61d66f5 ./pc-bios/edk2-aarch64-code.fdand I get the same error:
root@localhost:~# QEMU 10.0.50 monitor - type 'help' for more information (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 56.865284] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000 [ 56.866620] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff] [ 56.867711] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref] [ 56.868287] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref] [ 56.869143] pci 0000:01:00.0: enabling Extended Tags [ 56.900481] Internal error: synchronous external abort: 0000000096000050 [#1] SMP [ 56.900911] Modules linked in: aes_ce_blk binfmt_misc aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha3_ce sha3_generic sha512_ce sha512_arm64 sha2_ce sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse drm efi_pstore dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_net net_failover failover virtio_blk crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio [ 56.903132] CPU: 0 PID: 10 Comm: kworker/u2:0 Not tainted 6.1.0-34-arm64 #1 Debian 6.1.135-1 [ 56.903753] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024 [ 56.904126] Workqueue: kacpi_hotplug acpi_hotplug_work_fn [ 56.904877] pstate: 60402005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 56.905085] pc : acpi_ex_system_memory_space_handler+0x290/0x300 [ 56.905306] lr : acpi_ev_address_space_dispatch+0x124/0x334 [ 56.905471] sp : ffff80000809b3b0 [ 56.905580] x29: ffff80000809b3b0 x28: ffff0003fcb852d0 x27: 0000000000000000 [ 56.905856] x26: ffff0003fcb85558 x25: ffff80000809b568 x24: 0000000000000001 [ 56.906092] x23: ffff80000809b568 x22: 0000000000000004 x21: ffff0000c1644980 [ 56.906333] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000 [ 56.906557] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 [ 56.906793] x14: 0000000000000000 x13: ffffb8324c78ebb0 x12: 0000000000000001 [ 56.907016] x11: 000000000000002e x10: ffffb8324cab6e20 x9 : ffffb8324b2076b4 [ 56.907236] x8 : 0000000000000001 x7 : ffffb8324b20e3d0 x6 : 00000000000000f8 [ 56.907473] x5 : ffff0000c1644980 x4 : 0000000000000000 x3 : 00000000090c0018 [ 56.907705] x2 : ffff800008837014 x1 : 00000000090c0018 x0 : 0000000000000001 [ 56.908026] Call trace: [ 56.908226] acpi_ex_system_memory_space_handler+0x290/0x300 [ 56.908540] acpi_ev_address_space_dispatch+0x124/0x334 [ 56.908736] acpi_ex_access_region+0xe4/0x2e0 [ 56.908870] acpi_ex_field_datum_io+0x88/0x200 [ 56.909003] acpi_ex_write_with_update_rule+0xd4/0x120 [ 56.909152] acpi_ex_insert_into_field+0x210/0x2b0 [ 56.909285] acpi_ex_write_data_to_field+0xa0/0x190 [ 56.909426] acpi_ex_store_object_to_node+0x150/0x240 [ 56.909569] acpi_ex_store+0x144/0x300 [ 56.909688] acpi_ex_opcode_1A_1T_1R+0x218/0x580 [ 56.909824] acpi_ds_exec_end_op+0x24c/0x4b0 [ 56.909953] acpi_ps_parse_loop+0x100/0x6a0 [ 56.910074] acpi_ps_parse_aml+0x94/0x3b0 [ 56.910197] acpi_ps_execute_method+0x128/0x25c [ 56.910331] acpi_ns_evaluate+0x1f0/0x2d0 [ 56.910445] acpi_evaluate_object+0x138/0x2d0 [ 56.910573] acpi_evaluate_dsm+0xb8/0x134 [ 56.910696] acpi_check_dsm+0x34/0xdc [ 56.910809] smbios_attr_is_visible+0x5c/0xb0 [ 56.910937] internal_create_group+0xd0/0x3d0 [ 56.911066] internal_create_groups+0x58/0xe0 [ 56.911194] sysfs_create_groups+0x20/0x30 [ 56.911315] device_add_groups+0x18/0x2c [ 56.911435] bus_add_device+0x48/0x160 [ 56.911552] device_add+0x3a4/0x85c [ 56.911678] pci_device_add+0x308/0x660 [ 56.911803] pci_scan_single_device+0xe4/0x114 [ 56.911937] pci_scan_slot+0x70/0x1fc [ 56.912039] acpiphp_rescan_slot+0x90/0xa4 [ 56.912161] acpiphp_hotplug_notify+0x2a8/0x300 [ 56.912290] acpi_device_hotplug+0x138/0x4c0 [ 56.912428] acpi_hotplug_work_fn+0x2c/0x4c [ 56.912549] process_one_work+0x1f4/0x460 [ 56.912679] worker_thread+0x188/0x4e0 [ 56.912792] kthread+0xe0/0xe4 [ 56.912892] ret_from_fork+0x10/0x20 [ 56.913136] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040) [ 56.913532] ---[ end trace 0000000000000000 ]---Quoted 2 lines
I'm wondering if we are using the same ./pc-bios/edk2-aarch64-code.fd, although I can't see how it would cause such error.
Quoted 6 lines
hmm actually I'm able to properly hotplug the network device using the exactly same sw stack as above (your branch, Debian 12, edk2) but running on an arm64 host.
It seems your running on a arm64 host since you're passing --enable-kvm. Do you mind trying it on a
x86_64or without --enable-kvm on the arm64 host? I'm able to reproduce it on arm64 host without --enable-kvm but not with --enable-kvm passed to QEMU.
What causes this behaviour is that the container size is < than the register region in the pcihp device:
[...]
00000000090c0000-00000000090c0013 (prio 0, i/o): pcihp container
00000000090c0000-00000000090c0017 (prio 0, i/o): acpi-pci-hotplug[...]
Because ACPI_PCI_HOTPLUG_REG_LEN and ACPI_PCIHP_SIZE values don't match. Please see my comment in patch 18/24 for a possible fix for it.
Cheers,
Gustavo
Hi Gustavo,
Quoted 318 lines · Gustavo Romero
Hi Eric,
Quoted 304 lines · Gustavo Romero
Hi Eric,
Quoted 292 lines · Gustavo Romero
Hi Eric,
Quoted 151 lines · Eric Auger
Hi Gustavo,
Quoted 145 lines · Gustavo Romero
Hi Eric,
Quoted 22 lines · Eric Auger
This series enables APCI PCI hotplug/hotunplug on ARM and makes it default for 10.1 machine type. This aligns with x86 q35 machine. Expected benefits should be similar to those listed in [1].
The infrastructure used in x86 is heavily reused and a huge part of the series consists in moving code from
hw/i386/acpi-build.cto a generic place and slightly adapting it to make it usable on ARM. The DSDT table is augmented to support ACPI PCI hotplug elements.On ARM we use use a GED event to notify the OS about hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures neither on x86 nor ARM. x86 DSDT table has not changed. ARM DSDT table definitively has but there are no tests impacted. ARM misses hotplug tests that do exist on x86. This most probably should be considered in the future.
Best Regards
Quoted 8 lines
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/I've just started to review your series and went to a quick smoke test
by hotplugging a net adapter and got the following kernel internal error:(qemu)
device_addvirtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class0x020000
[ 64.165895] pci 0000:01:00.0: reg0x14: [mem 0x00000000-0x00000fff]
[ 64.166259] pci 0000:01:00.0: reg0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 64.166658] pci 0000:01:00.0: reg0x30: [mem 0x00000000-0x0003ffff pref]
[ 64.167153] pci 0000:01:00.0: enabling Extended Tags
[ 64.179972] Internal error: synchronous external abort:
0000000096000050 [#1] SMP
[ 64.180719] Modules linked in:aes_ce_blkaes_ce_cipherpolyval_cepolyval_genericghash_cegf128mulsha2_cebinfmt_miscsha256_arm64sha1_cenls_asciinls_cp437vfat fat evdev cfg80211 rfkill loop fuseefi_pstoredrmdm_moddax configfs efivarfsqemu_fw_cfgip_tablesx_tablesautofs4 ext4 crc16 mbcache jbd2crc32c_genericvirtio_scsivirtio_netscsi_modnet_failoverfailovervirtio_blkscsi_commoncrct10dif_cecrct10dif_commonvirtio_pcivirtio_pci_legacy_devvirtio_pci_modern_devvirtio_mmio
[ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1
[ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 64.184759] Workqueue:kacpi_hotplugacpi_hotplug_work_fn[ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 64.185737] pc :acpi_ex_system_memory_space_handler+0x290/0x300[ 64.186175] lr :acpi_ev_address_space_dispatch+0x124/0x334[ 64.186490] sp :ffff80000a6bb3b0
[ 64.186663] x29:ffff80000a6bb3b0x28:ffff0003fcbb08b8x27:
0000000000000000
[ 64.187126] x26:ffff0003fcbb0288x25:ffff80000a6bb568x24:
0000000000000001
[ 64.187499] x23:ffff80000a6bb568x22: 0000000000000004 x21:ffff0000c206cb00
[ 64.187885] x20:00000000090c0014x19: 0000000000000020 x18:
0000000000000000
[ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
0000000000000000
[ 64.188640] x14: 0000000000000000 x13:4d43c3194dea1791x12:4d7a3553e5c937d0
[ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :ffff800008735b34
[ 64.189383] x8 : 0000000000000001 x7 :ffff80000873c850x6 :00000000000000f8
[ 64.189778] x5 :ffff0000c206cb00x4 : 0000000000000000 x3 :00000000090c0018
[ 64.190163] x2 :ffff80000a9af014x1 :00000000090c0018x0 :
0000000000000001
[ 64.190734] Call trace:
[ 64.191086]acpi_ex_system_memory_space_handler+0x290/0x300[ 64.191696]acpi_ev_address_space_dispatch+0x124/0x334[ 64.192042]acpi_ex_access_region+0xe4/0x2e0
[ 64.192287]acpi_ex_field_datum_io+0x88/0x200
[ 64.192509]acpi_ex_write_with_update_rule+0xd4/0x120[ 64.192793]acpi_ex_insert_into_field+0x210/0x2b0
[ 64.193048]acpi_ex_write_data_to_field+0xa0/0x190
[ 64.193298]acpi_ex_store_object_to_node+0x150/0x240
[ 64.193527]acpi_ex_store+0x144/0x300
[ 64.193726]acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 64.193971]acpi_ds_exec_end_op+0x24c/0x4b0
[ 64.194227]acpi_ps_parse_loop+0x100/0x6a0
[ 64.194477]acpi_ps_parse_aml+0x94/0x3b0
[ 64.194674]acpi_ps_execute_method+0x128/0x25c
[ 64.194922]acpi_ns_evaluate+0x1f0/0x2d0
[ 64.195148]acpi_evaluate_object+0x138/0x2d0
[ 64.195380]acpi_evaluate_dsm+0xb8/0x134
[ 64.195613]acpi_check_dsm+0x34/0xdc
[ 64.195822]smbios_attr_is_visible+0x5c/0xb0
[ 64.196089]internal_create_group+0xd0/0x3d0
[ 64.196335]internal_create_groups+0x58/0xe0
[ 64.196584]sysfs_create_groups+0x20/0x30
[ 64.196813]device_add_groups+0x18/0x2c
[ 64.197039]bus_add_device+0x48/0x160
[ 64.197260]device_add+0x3a4/0x85c
[ 64.197463]pci_device_add+0x308/0x660
[ 64.197680]pci_scan_single_device+0xe4/0x114
[ 64.197941]pci_scan_slot+0x70/0x1fc
[ 64.198155]acpiphp_rescan_slot+0x90/0xa4
[ 64.198366]acpiphp_hotplug_notify+0x2a8/0x300
[ 64.198584]acpi_device_hotplug+0x138/0x4c0
[ 64.198819]acpi_hotplug_work_fn+0x2c/0x4c
[ 64.199045]process_one_work+0x1f4/0x460
[ 64.199277]worker_thread+0x188/0x4e0
[ 64.199492]kthread+0xe0/0xe4
[ 64.199671]ret_from_fork+0x10/0x20
[ 64.200114] Code:f90002e05280000017ffff97f94002e0(b9000040) [ 64.200820] ---[ end trace 0000000000000000 ]---(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fdQuoted 2 lines
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
Quoted 7 lines
I have just tested debian-12-nocloud-arm64.qcow2 which features 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to hotplug/hot-unplug the virtio-net-pci device. Can you retry without
-initrd
/mnt/initrd.img-6.1.0-30-arm64-kernel/mnt/vmlinuz-6.1.0-30-arm64-append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" ?Sure, so I got the same internal error without passing the kernel, the initrd,
and the append command.I also tried with a pristine Debian .qcow2 taken from:
https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.qcow2
I'm building your Github branch:
gromero@gromero0:/mnt/git/qemu_/build$ git branch -vv | grep eauger * arm-acpi-pcihp-rfc cf92b293ff [eauger/arm-acpi-pcihp-rfc] hw/arm/virt: Use ACPI PCI hotplug by default gromero@gromero0:/mnt/git/qemu_/build$ git log --oneline -1 cf92b293ff (HEAD -> arm-acpi-pcihp-rfc, eauger/arm-acpi-pcihp-rfc) hw/arm/virt: Use ACPI PCI hotplug by defaultI tried in a pristine ./build dir.
QEMU options:
gromero@gromero0:/mnt/git/qemu_/build$ ./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu max -drive if=none,file=/mnt/debian/debian-12-nocloud-arm64.qcow2,format=qcow2,id=hd -device virtio-blk-device,drive=hd -device pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -bios ./pc-bios/edk2-aarch64-code.fd UEFI firmware (version edk2-stable202408-prebuilt.qemu.org built at 16:28:50 on Sep 12 2024)gromero@gromero0:/mnt/git/qemu_/build$ md5sum ./pc-bios/edk2-aarch64-code.fd 3426cd25efb1593f86352ec0c61d66f5 ./pc-bios/edk2-aarch64-code.fdand I get the same error:
root@localhost:~# QEMU 10.0.50 monitor - type 'help' for more information (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na (qemu) [ 56.865284] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000 [ 56.866620] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff] [ 56.867711] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref] [ 56.868287] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref] [ 56.869143] pci 0000:01:00.0: enabling Extended Tags [ 56.900481] Internal error: synchronous external abort: 0000000096000050 [#1] SMP [ 56.900911] Modules linked in: aes_ce_blk binfmt_misc aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha3_ce sha3_generic sha512_ce sha512_arm64 sha2_ce sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse drm efi_pstore dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_net net_failover failover virtio_blk crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio [ 56.903132] CPU: 0 PID: 10 Comm: kworker/u2:0 Not tainted 6.1.0-34-arm64 #1 Debian 6.1.135-1 [ 56.903753] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024 [ 56.904126] Workqueue: kacpi_hotplug acpi_hotplug_work_fn [ 56.904877] pstate: 60402005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 56.905085] pc : acpi_ex_system_memory_space_handler+0x290/0x300 [ 56.905306] lr : acpi_ev_address_space_dispatch+0x124/0x334 [ 56.905471] sp : ffff80000809b3b0 [ 56.905580] x29: ffff80000809b3b0 x28: ffff0003fcb852d0 x27: 0000000000000000 [ 56.905856] x26: ffff0003fcb85558 x25: ffff80000809b568 x24: 0000000000000001 [ 56.906092] x23: ffff80000809b568 x22: 0000000000000004 x21: ffff0000c1644980 [ 56.906333] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000 [ 56.906557] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000 [ 56.906793] x14: 0000000000000000 x13: ffffb8324c78ebb0 x12: 0000000000000001 [ 56.907016] x11: 000000000000002e x10: ffffb8324cab6e20 x9 : ffffb8324b2076b4 [ 56.907236] x8 : 0000000000000001 x7 : ffffb8324b20e3d0 x6 : 00000000000000f8 [ 56.907473] x5 : ffff0000c1644980 x4 : 0000000000000000 x3 : 00000000090c0018 [ 56.907705] x2 : ffff800008837014 x1 : 00000000090c0018 x0 : 0000000000000001 [ 56.908026] Call trace: [ 56.908226] acpi_ex_system_memory_space_handler+0x290/0x300 [ 56.908540] acpi_ev_address_space_dispatch+0x124/0x334 [ 56.908736] acpi_ex_access_region+0xe4/0x2e0 [ 56.908870] acpi_ex_field_datum_io+0x88/0x200 [ 56.909003] acpi_ex_write_with_update_rule+0xd4/0x120 [ 56.909152] acpi_ex_insert_into_field+0x210/0x2b0 [ 56.909285] acpi_ex_write_data_to_field+0xa0/0x190 [ 56.909426] acpi_ex_store_object_to_node+0x150/0x240 [ 56.909569] acpi_ex_store+0x144/0x300 [ 56.909688] acpi_ex_opcode_1A_1T_1R+0x218/0x580 [ 56.909824] acpi_ds_exec_end_op+0x24c/0x4b0 [ 56.909953] acpi_ps_parse_loop+0x100/0x6a0 [ 56.910074] acpi_ps_parse_aml+0x94/0x3b0 [ 56.910197] acpi_ps_execute_method+0x128/0x25c [ 56.910331] acpi_ns_evaluate+0x1f0/0x2d0 [ 56.910445] acpi_evaluate_object+0x138/0x2d0 [ 56.910573] acpi_evaluate_dsm+0xb8/0x134 [ 56.910696] acpi_check_dsm+0x34/0xdc [ 56.910809] smbios_attr_is_visible+0x5c/0xb0 [ 56.910937] internal_create_group+0xd0/0x3d0 [ 56.911066] internal_create_groups+0x58/0xe0 [ 56.911194] sysfs_create_groups+0x20/0x30 [ 56.911315] device_add_groups+0x18/0x2c [ 56.911435] bus_add_device+0x48/0x160 [ 56.911552] device_add+0x3a4/0x85c [ 56.911678] pci_device_add+0x308/0x660 [ 56.911803] pci_scan_single_device+0xe4/0x114 [ 56.911937] pci_scan_slot+0x70/0x1fc [ 56.912039] acpiphp_rescan_slot+0x90/0xa4 [ 56.912161] acpiphp_hotplug_notify+0x2a8/0x300 [ 56.912290] acpi_device_hotplug+0x138/0x4c0 [ 56.912428] acpi_hotplug_work_fn+0x2c/0x4c [ 56.912549] process_one_work+0x1f4/0x460 [ 56.912679] worker_thread+0x188/0x4e0 [ 56.912792] kthread+0xe0/0xe4 [ 56.912892] ret_from_fork+0x10/0x20 [ 56.913136] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040) [ 56.913532] ---[ end trace 0000000000000000 ]---Quoted 3 lines
I'm wondering if we are using the same
./pc-bios/edk2-aarch64-code.fd, although
I can't see how it would cause such error.hmm actually I'm able to properly hotplug the network device using the exactly
same sw stack as above (your branch, Debian 12, edk2) but running on an arm64 host.Quoted 6 lines
It seems your running on a arm64 host since you're passing --enable-kvm. Do you
mind trying it on ax86_64or without --enable-kvm on the arm64 host? I'm able to
reproduce it on arm64 host without --enable-kvm but not with --enable-kvm passed to QEMU.What causes this behaviour is that the container size is < than the register region
in the pcihp device:
Quoted 8 lines
[...]
00000000090c0000-00000000090c0013 (prio 0, i/o): pcihp container 00000000090c0000-00000000090c0017 (prio 0, i/o): acpi-pci-hotplug [...]Because
ACPI_PCI_HOTPLUG_REG_LENandACPI_PCIHP_SIZEvalues don't match. Please see my
comment in patch 18/24 for a possible fix for it.
thank you very much for the investigation. This should be fixed in the next version I am about the send ...
Eric
Quoted 5 lines
Cheers,
Gustavo