ACPI PCI Hotplug support on ARM
v2 cover ACPI PCI Hotplug support on ARM
This series enables ACPI 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], ie. removal of some racy behaviors, improved latencies.
It is still possible to disable it using a virt machine
option: virt,acpi-pcihp=off and restore the legacy behavior.
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.
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-v2
previous series:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-v1
History:
v1 -> v2:
- collected a bunch of R-bs from Gustavo (many thanks!)
- Fixed the breakage of bios-tables-test in TCG mode by incorporating Gustavo's patches (part of
[PATCH 0/5] ACPI tests for PCI Hotplug on ARM
https://lore.kernel.org/all/[email protected]/)
- Tweeked the dsdt aml changes to avoid any dsdt blob difference when acpi-pcihp is off.
RFC -> v1:
- First 3 trivial patches were pulled separately
- Fix of the register region size (0x18), ie. ACPI_PCIHP_SIZE
- addition of aml_pci_edsm which was not called in RFC
- acpi-index feature is now fixed. vms->bus was not set on acpi_pcihp_init. The init sequence is still hacky though. Suggestions are welcome.
[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/[email protected]/
Eric Auger (22):
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 build_append_pci_bus_devices/pcihp_slots to
pcihp
hw/i386/acpi-build: Introduce and use acpi_get_pci_host hw/i386/acpi-build: Move aml_pci_edsm to a generic place hw/arm/virt-acpi-build: Modify the DSDT ACPI table to enable ACPI 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
Gustavo Romero (3):
tests/qtest/bios-tables-test: Prepare for changes in the DSDT table tests/qtest/bios-tables-test: Update DSDT blobs after GPEX _OSC change tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
hw/i386/acpi-build.h | 4 - include/hw/acpi/aml-build.h | 2 + include/hw/acpi/generic_event_device.h | 7 + include/hw/acpi/pci.h | 4 +- include/hw/acpi/pcihp.h | 19 +- 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 | 54 ++ hw/acpi/pci.c | 20 + hw/acpi/pcihp.c | 482 ++++++++++++++- hw/arm/virt-acpi-build.c | 23 + hw/arm/virt.c | 107 +++- hw/core/sysbus.c | 11 + hw/i386/acpi-build.c | 552 +----------------- hw/pci-host/gpex-acpi.c | 75 +-- tests/qtest/bios-tables-test.c | 13 +- hw/arm/Kconfig | 2 + tests/data/acpi/aarch64/virt/DSDT | Bin 5196 -> 5170 bytes .../data/acpi/aarch64/virt/DSDT.acpihmatvirt | Bin 5282 -> 5256 bytes tests/data/acpi/aarch64/virt/DSDT.memhp | Bin 6557 -> 6531 bytes tests/data/acpi/aarch64/virt/DSDT.pxb | Bin 7679 -> 7627 bytes tests/data/acpi/aarch64/virt/DSDT.topology | Bin 5398 -> 5372 bytes 24 files changed, 812 insertions(+), 619 deletions(-)
Signature · 1 line
2.49.0
PATCH v2 1/25 hw/i386/acpi-build: Make aml_pci_device_dsm() static
No 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
Re: [PATCH v2 01/25] hw/i386/acpi-build: Make aml_pci_device_dsm() static
Quoted 6 lines · On Tue, 27 May 2025 09:40:03 +0200 Eric Auger <[email protected]> wrote:
No need to export
aml_pci_device_dsm()as it is only used inhw/i386/acpi-build.c.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 30 lines
--- 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;
Re: [PATCH v2 01/25] hw/i386/acpi-build: Make aml_pci_device_dsm() static
In reply to Eric AugerQuoted 6 lines · On Tue, 27 May 2025 09:40:03 +0200 Eric Auger <[email protected]> wrote:
No need to export
aml_pci_device_dsm()as it is only used inhw/i386/acpi-build.c.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 30 lines
--- 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;
PATCH v2 2/25 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 must 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
@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {
@@ -150,6 +151,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
@@ -2397,8 +2397,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); }
@@ -2593,6 +2595,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);
@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)
@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;
@@ -3394,8 +3417,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: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Quoted 5 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
acpi_pcihpVirtMachineClass state flag will allow to opt in for acpi pci hotplug. This is guarded by aclass
no_acpi_pcihpflag to manage compats (<= 10.0 machine types will not support ACPI PCI hotplug).
there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 6 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "_Sxx" slot naming. /so configs tied to nic go down the drain/
Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;
I don't particularly like no_foo naming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults using hw_compat_xxx
Quoted 61 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Igor,
Quoted 22 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/
Quoted 6 lines
Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known issue you report above?
The no_foo compat stuff was especially introduced to avoid breaking the guest ABI for old machine types (like the NIC naming alternation you evoke).
Quoted 44 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)
Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxx
no_foo still is a largely used pattern in arm virt: no_ged, kvm_no_adjvtime, no_kvm_steal_time, no_tcg_lpa2, ../.. There are plenty of them and I am not under the impression this is going to be changed.
If you refer to 8d23b1df7212 ("hw/arm/virt: Remove VirtMachineClass::no_its field") I think the no_its was removed because the machine it applied was removed.
If I understand correctly you would like the prop to be attached to the GED device. However the GED device is internally created by the virt machine code and not passed through a "-device" CLI option. So how would you pass the option on the cmd line if you don't want it to be set by default per machine type?
Thanks
Eric
Quoted 63 lines
Quoted 63 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Quoted 29 lines · On Tue, 27 May 2025 15:54:15 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 26 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)
Quoted 6 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known issue you report above?
Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted to default (so hopefully that won't happen on with ARM). Also given that ARM VM is less popular like hood breaking someone setup is even less.
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
Quoted 2 lines
The
no_foocompat stuff was especially introduced to avoid breaking the guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foo is just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast. Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)
to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86
Quoted 128 lines
Quoted 44 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because the machine it applied was removed.If I understand correctly you would like the prop to be attached to the GED device. However the GED device is internally created by the virt machine code and not passed through a "-device" CLI option. So how would you pass the option on the cmd line if you don't want it to be set by default per machine type?
Thanks
Eric
Quoted 63 lines
Quoted 63 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Gustavo, Alex,
Quoted 43 lines · Igor Mammedov
Quoted 29 lines · On Tue, 27 May 2025 15:54:15 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 26 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)Quoted 5 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known issue you report above?
Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted to default (so hopefully that won't happen on with ARM). Also given that ARM VM is less popular like hood breaking someone setup is even less.
Quoted 5 lines
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
What is your preference? Do you prefer enabling ACPI PCI HP by default or the opposite.
Anybody else?
On my end I think I would prefer to have the same default setting than on x86 (ie. ACPI PCI hotplug set by default) but I have no strong opinion either.
Thanks
Eric
Quoted 137 lines
Quoted 4 lines
The
no_foocompat stuff was especially introduced to avoid breaking the guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foois just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast. Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)
to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86Quoted 126 lines
Quoted 44 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because the machine it applied was removed.If I understand correctly you would like the prop to be attached to the GED device. However the GED device is internally created by the virt machine code and not passed through a "-device" CLI option. So how would you pass the option on the cmd line if you don't want it to be set by default per machine type?
Thanks
Eric
Quoted 62 lines
Quoted 62 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Quoted 46 lines · On Wed, 11 Jun 2025 08:53:28 +0200 Eric Auger <[email protected]> wrote:
Hi Gustavo, Alex,
Quoted 43 lines · Igor Mammedov
Quoted 29 lines · On Tue, 27 May 2025 15:54:15 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 26 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)Quoted 5 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known issue you report above?
Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted to default (so hopefully that won't happen on with ARM). Also given that ARM VM is less popular like hood breaking someone setup is even less.
Quoted 7 lines
Quoted 5 lines
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
What is your preference? Do you prefer enabling ACPI PCI HP by default or the opposite.
I'd prefer native PCIe hotplug being default,
that way we have less chance of causing regressions not to mention less complexity (as acpi pcihp adds up quite a bit of it).
And ones who want/need acpi-pcihp/acpi-index can enable it explicitly, to play with.
Quoted 147 lines
Anybody else?
On my end I think I would prefer to have the same default setting than on x86 (ie. ACPI PCI hotplug set by default) but I have no strong opinion either.
Thanks
Eric
Quoted 137 lines
Quoted 4 lines
The
no_foocompat stuff was especially introduced to avoid breaking the guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foois just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast. Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)
to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86Quoted 126 lines
Quoted 44 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because the machine it applied was removed.If I understand correctly you would like the prop to be attached to the GED device. However the GED device is internally created by the virt machine code and not passed through a "-device" CLI option. So how would you pass the option on the cmd line if you don't want it to be set by default per machine type?
Thanks
Eric
Quoted 62 lines
Quoted 62 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Igor,
Quoted 54 lines · Igor Mammedov
Quoted 51 lines · On Wed, 11 Jun 2025 08:53:28 +0200 Eric Auger <[email protected]> wrote:
Hi Gustavo, Alex,
Quoted 48 lines · Igor Mammedov
Quoted 29 lines · On Tue, 27 May 2025 15:54:15 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 26 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)Quoted 5 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known issue you report above?
Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted to default (so hopefully that won't happen on with ARM). Also given that ARM VM is less popular like hood breaking someone setup is even less.
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
Quoted 8 lines
Quoted 2 lines
What is your preference? Do you prefer enabling ACPI PCI HP by default or the opposite.
I'd prefer native PCIe hotplug being default,
that way we have less chance of causing regressions not to mention less complexity (as acpi pcihp adds up quite a bit of it).And ones who want/need acpi-pcihp/acpi-index can enable it explicitly, to play with.
OK I will follow your suggestion. You have definitively more expertise than me here ! ;-)
Thanks!
Eric
Quoted 146 lines
Quoted 146 lines
Anybody else?
On my end I think I would prefer to have the same default setting than on x86 (ie. ACPI PCI hotplug set by default) but I have no strong opinion either.
Thanks
Eric
Quoted 136 lines
Quoted 3 lines
The
no_foocompat stuff was especially introduced to avoid breaking the guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foois just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast. Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)
to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86Quoted 126 lines
Quoted 44 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because the machine it applied was removed.If I understand correctly you would like the prop to be attached to the GED device. However the GED device is internally created by the virt machine code and not passed through a "-device" CLI option. So how would you pass the option on the cmd line if you don't want it to be set by default per machine type?
Thanks
Eric
Quoted 62 lines
Quoted 62 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Quoted 62 lines · On Wed, 11 Jun 2025 10:50:04 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 60 lines · Igor Mammedov
Quoted 46 lines · On Wed, 11 Jun 2025 08:53:28 +0200 Eric Auger <[email protected]> wrote:
Hi Gustavo, Alex,
Quoted 43 lines · Igor Mammedov
Quoted 29 lines · On Tue, 27 May 2025 15:54:15 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 26 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)Quoted 5 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known issue you report above?
Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted to default (so hopefully that won't happen on with ARM). Also given that ARM VM is less popular like hood breaking someone setup is even less.
Quoted 7 lines
Quoted 5 lines
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
What is your preference? Do you prefer enabling ACPI PCI HP by default or the opposite.
I'd prefer native PCIe hotplug being default,
that way we have less chance of causing regressions not to mention less complexity (as acpi pcihp adds up quite a bit of it).
Quoted 5 lines
Quoted 2 lines
And ones who want/need acpi-pcihp/acpi-index can enable it explicitly, to play with.
OK I will follow your suggestion. You have definitively more expertise than me here ! ;-)
So far what I suggest looks like better option compared to multiple machine knobs fiddling. But I can easily change my mind once I see respin, if experiment with compat props is not coming well together.
Quoted 151 lines
Thanks!
Eric
Quoted 146 lines
Quoted 146 lines
Anybody else?
On my end I think I would prefer to have the same default setting than on x86 (ie. ACPI PCI hotplug set by default) but I have no strong opinion either.
Thanks
Eric
Quoted 136 lines
Quoted 3 lines
The
no_foocompat stuff was especially introduced to avoid breaking the guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foois just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast. Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)
to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86Quoted 126 lines
Quoted 44 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because the machine it applied was removed.If I understand correctly you would like the prop to be attached to the GED device. However the GED device is internally created by the virt machine code and not passed through a "-device" CLI option. So how would you pass the option on the cmd line if you don't want it to be set by default per machine type?
Thanks
Eric
Quoted 62 lines
Quoted 62 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Eric,
Quoted 68 lines · Igor Mammedov
Quoted 65 lines · On Wed, 11 Jun 2025 10:50:04 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 62 lines · Igor Mammedov
Quoted 46 lines · On Wed, 11 Jun 2025 08:53:28 +0200 Eric Auger <[email protected]> wrote:
Hi Gustavo, Alex,
Quoted 43 lines · Igor Mammedov
Quoted 29 lines · On Tue, 27 May 2025 15:54:15 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 26 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)Quoted 5 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known issue you report above?
Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted to default (so hopefully that won't happen on with ARM). Also given that ARM VM is less popular like hood breaking someone setup is even less.
Quoted 7 lines
Quoted 5 lines
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
What is your preference? Do you prefer enabling ACPI PCI HP by default or the opposite.
I'd prefer native PCIe hotplug being default,
that way we have less chance of causing regressions not to mention less complexity (as acpi pcihp adds up quite a bit of it).And ones who want/need acpi-pcihp/acpi-index can enable it explicitly, to play with.
Quoted 6 lines
Quoted 2 lines
OK I will follow your suggestion. You have definitively more expertise than me here ! ;-)
So far what I suggest looks like better option compared to multiple machine knobs fiddling. But I can easily change my mind once I see respin, if experiment with compat props is not coming well together.
For now, I think it's okay to let ACPI PCI hotplug stabilize (while not being the default) for at least one release cycle. So I'm fine with keeping acpi-pcihp=off as the default.
As I mentioned elsewhere, I don't consider native PCIe hotplug to be legacy.
We can make acpi-pcihp=on the default in a future release once it's been more widely exercised.
I'll update the bios-tables-test.c test accordingly, then you can either put them in the v3 (if you happen to send v3 next week) or add them to a v4.
Cheers,
Gustavo
Quoted 151 lines
Quoted 150 lines
Thanks!
Eric
Quoted 146 lines
Quoted 146 lines
Anybody else?
On my end I think I would prefer to have the same default setting than on x86 (ie. ACPI PCI hotplug set by default) but I have no strong opinion either.
Thanks
Eric
Quoted 136 lines
Quoted 3 lines
The
no_foocompat stuff was especially introduced to avoid breaking the guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foois just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast. Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)
to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86Quoted 126 lines
Quoted 44 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because the machine it applied was removed.If I understand correctly you would like the prop to be attached to the GED device. However the GED device is internally created by the virt machine code and not passed through a "-device" CLI option. So how would you pass the option on the cmd line if you don't want it to be set by default per machine type?
Thanks
Eric
Quoted 62 lines
Quoted 62 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Gustavo,
Quoted 95 lines · Gustavo Romero
Hi Eric,
Quoted 74 lines · Igor Mammedov
Quoted 71 lines · On Wed, 11 Jun 2025 10:50:04 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 68 lines · Igor Mammedov
On Wed, 11 Jun 2025 08:53:28 +0200
Eric Auger <[email protected]> wrote:Quoted 51 lines
Hi Gustavo, Alex,
Quoted 48 lines · Igor Mammedov
On Tue, 27 May 2025 15:54:15 +0200
Eric Auger <[email protected]> wrote:Quoted 31 lines
Hi Igor,
Quoted 28 lines · Igor Mammedov
On Tue, 27 May 2025 09:40:04 +0200
Eric Auger <[email protected]> wrote:Quoted 4 lines
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec (it should be unique system wide, there was a gitlab issue for that,
there is no easy fix that though)Quoted 6 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known
issue you report above?Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted
to default (so hopefully that won't happen on with ARM). Also given that ARM VM is less popular like hood breaking someone setup is even less.Quoted 8 lines
Quoted 5 lines
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
What is your preference? Do you prefer enabling ACPI PCI HP by default
or the opposite.I'd prefer native PCIe hotplug being default,
that way we have less chance of causing regressions not to mention less complexity (as acpi pcihp adds up quite a bit of it).And ones who want/need acpi-pcihp/acpi-index can enable it explicitly, to play with.
Quoted 8 lines
Quoted 2 lines
OK I will follow your suggestion. You have definitively more expertise than me here ! ;-)
So far what I suggest looks like better option compared to multiple machine knobs
fiddling. But I can easily change my mind once I see respin, if experiment
with compat props is not coming well together.For now, I think it's okay to let ACPI PCI hotplug stabilize (while not being the
default) for at least one release cycle. So I'm fine with keeping acpi-pcihp=off as
the default.As I mentioned elsewhere, I don't consider native PCIe hotplug to be legacy.
Quoted 7 lines
We can make acpi-pcihp=on the default in a future release once it's been more
widely exercised.I'll update the
bios-tables-test.ctest accordingly, then you can either put them
in the v3 (if you happen to send v3 next week) or add them to a v4.
OK thank you for the confirmation. So following Igor's suggestion I indeed kept the current default value (legacy PCIe hotplug) and I don't use a machine option anymore. Instead I use the x86 trick, ie.
-global acpi-ged.acpi-pci-hotplug-with-bridge-support=on
I can easily update your tests with that option, don't bother respinning. I should be able to send the v3 by beginning of next week.
Thanks!
Eric
Quoted 173 lines
Cheers,
GustavoQuoted 167 lines
Quoted 166 lines
Thanks!
Eric
Quoted 162 lines
Quoted 161 lines
Anybody else?
On my end I think I would prefer to have the same default setting than
on x86 (ie. ACPI PCI hotplug set by default) but I have no strong opinion either.Thanks
Eric
Quoted 151 lines
Quoted 4 lines
The
no_foocompat stuff was especially introduced to avoid breaking the
guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foois just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast.
Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86Quoted 138 lines
Quoted 46 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass { bool no_tcg_lpa2; bool no_ns_el2_virt_timer_irq; bool no_nested_smmu; + bool no_acpi_pcihp; }; struct VirtMachineState {@@ -150,6 +151,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@@ -2397,8 +2397,10 @@ static void machvirt_init(MachineState *machine) create_pcie(vms);Quoted 3 lines
if (
has_ged&& aarch64 &&firmware_loaded&&virt_is_acpi_enabled(vms)) {
+vms->acpi_pcihp&= !vmc->no_acpi_pcihp;I don't particularly like
no_foonaming as it makes code harder to read
and combined with 'duplicated' field in machine state it make even things worse.
(if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 4 lines
instead of adding machine property (both class and state), I'd suggest adding the only property to GPE device (akin to what we have in x86 world)
And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty
of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because
the machine it applied was removed.If I understand correctly you would like the prop to be attached to the
GED device. However the GED device is internally created by the virt
machine code and not passed through a "-device" CLI option. So how would
you pass the option on the cmd line if you don't want it to be set by
default per machine type?Thanks
Eric
Quoted 64 lines
Quoted 63 lines
vms->acpi_dev=create_acpi_ged(vms);
} else {
+vms->acpi_pcihp= false;create_gpio_devices(vms, VIRT_GPIO, sysmem); }
@@ -2593,6 +2595,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 +7
-0+{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->acpi_pcihp; +} + +static void virt_set_acpi_pcihp(Object *obj, bool value,Error **errp)
hw/arm/virt.c +6
-0+{ + 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@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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 voidvirt_instance_init(Object *obj)hw/arm/virt.c +0
-0@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; }+ /* default disallows ACPI PCI hotplug */
+vms->acpi_pcihp= false;
+
/* Default disallows iommu instantiation */vms->iommu=VIRT_IOMMU_NONE;
@@ -3394,8 +3417,12 @@DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)static voidvirt_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)
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Eric,
Quoted 102 lines · Eric Auger
Hi Gustavo,
Quoted 99 lines · Gustavo Romero
Hi Eric,
Quoted 74 lines · Igor Mammedov
Quoted 71 lines · On Wed, 11 Jun 2025 10:50:04 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 68 lines · Igor Mammedov
Quoted 51 lines · On Wed, 11 Jun 2025 08:53:28 +0200 Eric Auger <[email protected]> wrote:
Hi Gustavo, Alex,
Quoted 48 lines · Igor Mammedov
Quoted 31 lines · On Tue, 27 May 2025 15:54:15 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 28 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec (it should be unique system wide, there was a gitlab issue for that,
there is no easy fix that though)Quoted 6 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known
issue you report above?Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted
to default (so hopefully that won't happen on with ARM). Also given that ARM VM is less popular like hood breaking someone setup is even less.Quoted 8 lines
Quoted 5 lines
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
What is your preference? Do you prefer enabling ACPI PCI HP by default
or the opposite.I'd prefer native PCIe hotplug being default,
that way we have less chance of causing regressions not to mention less complexity (as acpi pcihp adds up quite a bit of it).And ones who want/need acpi-pcihp/acpi-index can enable it explicitly, to play with.
Quoted 8 lines
Quoted 2 lines
OK I will follow your suggestion. You have definitively more expertise than me here ! ;-)
So far what I suggest looks like better option compared to multiple machine knobs
fiddling. But I can easily change my mind once I see respin, if experiment
with compat props is not coming well together.For now, I think it's okay to let ACPI PCI hotplug stabilize (while not being the
default) for at least one release cycle. So I'm fine with keeping acpi-pcihp=off as
the default.As I mentioned elsewhere, I don't consider native PCIe hotplug to be legacy.
We can make acpi-pcihp=on the default in a future release once it's been more
widely exercised.
Quoted 6 lines
Quoted 3 lines
I'll update the
bios-tables-test.ctest accordingly, then you can either put them
in the v3 (if you happen to send v3 next week) or add them to a v4.OK thank you for the confirmation. So following Igor's suggestion I indeed kept the current default value (legacy PCIe hotplug) and I don't
_native_ PCIe hotplug? :)
Quoted 3 lines
use a machine option anymore. Instead I use the x86 trick, ie.
-global acpi-ged.acpi-pci-hotplug-with-bridge-support=on
hm but why you don't keep the machine option "acpi-pcihp" and just don't set it as "on" by default? I find global options like that a tad difficult to follow, feels indeed like a trick. Also, I don't like much not mentioning GPEX in the option name (and only the event notification device, "ged).
Am I missing something why a global would work better than a machine option when the default is the native PCIe hotplug?
Quoted 2 lines
I can easily update your tests with that option, don't bother respinning. I should be able to send the v3 by beginning of next week.
Got it! Thanks.
Cheers,
Gustavo
Quoted 178 lines
Thanks!
Eric
Quoted 173 lines
Cheers,
GustavoQuoted 167 lines
Quoted 166 lines
Thanks!
Eric
Quoted 162 lines
Quoted 162 lines
Anybody else?
On my end I think I would prefer to have the same default setting than
on x86 (ie. ACPI PCI hotplug set by default) but I have no strong opinion either.Thanks
Eric
Quoted 151 lines
Quoted 5 lines
The
no_foocompat stuff was especially introduced to avoid breaking the
guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foois just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast.
Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)
to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86Quoted 138 lines
Quoted 46 lines
Quoted 34 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass { bool no_tcg_lpa2; bool no_ns_el2_virt_timer_irq; bool no_nested_smmu; + bool no_acpi_pcihp; }; struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState · line 2401
Quoted 5 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read
and combined with 'duplicated' field in machine state it make even things worse.
(if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 4 lines
instead of adding machine property (both class and state), I'd suggest adding the only property to GPE device (akin to what we have in x86 world)
And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty
of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because
the machine it applied was removed.If I understand correctly you would like the prop to be attached to the
GED device. However the GED device is internally created by the virt
machine code and not passed through a "-device" CLI option. So how would
you pass the option on the cmd line if you don't want it to be set by
default per machine type?Thanks
Eric
Quoted 64 lines
Quoted 64 lines
hw/arm/virt.c +1
-0vms->acpi_dev = create_acpi_ged(vms); } else { + vms->acpi_pcihp = false; create_gpio_devices(vms, VIRT_GPIO, sysmem); }@@ -2593,6 +2595,20 @@ static void virt_set_its(Object *obj,
bool value, Error **errp)
vms->its= value;
}
+static boolvirt_get_acpi_pcihp(Object *obj, Error **errp)hw/arm/virt.c +7
-0+{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->acpi_pcihp; +} + +static void virt_set_acpi_pcihp(Object *obj, bool value,Error **errp)
hw/arm/virt.c +6
-0+{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + vms->acpi_pcihp = value; +} + static bool virt_get_dtb_randomness(Object *obj, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(obj);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const void *data) "in ACPI tableheader."
"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 voidvirt_instance_init(Object *obj)hw/arm/virt.c +3
-0@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } + /* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; + /* Default disallows iommu instantiation */ vms->iommu = VIRT_IOMMU_NONE; @@ -3394,8 +3417,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)
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Gustavo,
Quoted 109 lines · Gustavo Romero
Hi Eric,
Quoted 106 lines · Eric Auger
Hi Gustavo,
Quoted 103 lines · Gustavo Romero
Hi Eric,
Quoted 81 lines · Igor Mammedov
Quoted 70 lines · On Wed, 11 Jun 2025 10:50:04 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 68 lines · Igor Mammedov
On Wed, 11 Jun 2025 08:53:28 +0200
Eric Auger <[email protected]> wrote:Quoted 53 lines
Hi Gustavo, Alex,
Quoted 50 lines · Igor Mammedov
On Tue, 27 May 2025 15:54:15 +0200
Eric Auger <[email protected]> wrote:Quoted 31 lines
Hi Igor,
Quoted 28 lines · Igor Mammedov
On Tue, 27 May 2025 09:40:04 +0200
Eric Auger <[email protected]> wrote:Quoted 4 lines
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec (it should be unique system wide, there was a gitlab issue for that,
there is no easy fix that though)Quoted 6 lines
Quoted 2 lines
So I'd leave it disabled by default and let users to turn it on explicitly when needed.
what is the status on q35, isn't it enabled by default? If so why wouldn't we want the same setting on ARM? Is that because of the known
issue you report above?Above issue is not a blocker (for thae lack of a good way to fix it)
on q35 we have had a few complains and fixes, after pcihp was promoted
to default (so hopefully that won't happen on with ARM). Also given
that ARM VM is less popular like hood breaking someone setup is even less.Quoted 8 lines
Quoted 5 lines
That said I'd be cautions keep native hotplug as default, and only ones who need ACPI one, could turn it on explicitly.
But well it's policies, so it's up to you ARM folks to decide what virt board should look like.
What is your preference? Do you prefer enabling ACPI PCI HP by default
or the opposite.I'd prefer native PCIe hotplug being default,
that way we have less chance of causing regressions not to mention less complexity (as acpi pcihp adds up quite a bit of it).Quoted 7 lines
Quoted 3 lines
And ones who want/need acpi-pcihp/acpi-index can enable it explicitly,
to play with.OK I will follow your suggestion. You have definitively more expertise
than me here ! ;-)Quoted 5 lines
So far what I suggest looks like better option compared to multiple machine knobs
fiddling. But I can easily change my mind once I see respin, if experiment
with compat props is not coming well together.For now, I think it's okay to let ACPI PCI hotplug stabilize (while not being the
default) for at least one release cycle. So I'm fine with keeping acpi-pcihp=off as
the default.As I mentioned elsewhere, I don't consider native PCIe hotplug to be legacy.
We can make acpi-pcihp=on the default in a future release once it's been more
widely exercised.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
I'll update the
bios-tables-test.ctest accordingly, then you can either put them
in the v3 (if you happen to send v3 next week) or add them to a v4.OK thank you for the confirmation. So following Igor's suggestion I indeed kept the current default value (legacy PCIe hotplug) and I don't
_native_ PCIe hotplug? :)
yes!
Quoted 13 lines
Quoted 5 lines
use a machine option anymore. Instead I use the x86 trick, ie.
-global acpi-ged.acpi-pci-hotplug-with-bridge-support=on
hm but why you don't keep the machine option "acpi-pcihp" and just don't set it as "on" by default? I find global options like that a tad difficult
to follow, feels indeed like a trick. Also, I don't like much not mentioning GPEX in the option name (and only the event notification device, "ged).
Quoted 3 lines
Am I missing something why a global would work better than a machine option
when the default is the native PCIe hotplug?
I am just following Igor's suggestion at the moment. According to Igor the benefit is that it looks exactly the same as x86 integration (which would ease libvirt integration) and it is also reusable with microvm.
Anyway if reviewers are not happy with the end result I will revert ;-)
Thanks
Eric
Quoted 193 lines
Quoted 4 lines
I can easily update your tests with that option, don't bother respinning. I should be able to send the v3 by beginning of next week.
Got it! Thanks.
Cheers,
GustavoQuoted 181 lines
Thanks!
Eric
Quoted 176 lines
Cheers,
GustavoQuoted 170 lines
Quoted 169 lines
Thanks!
Eric
Quoted 165 lines
Quoted 164 lines
Anybody else?
On my end I think I would prefer to have the same default setting than
on x86 (ie. ACPI PCI hotplug set by default) but I have no strong opinion either.Thanks
Eric
Quoted 154 lines
Quoted 4 lines
The
no_foocompat stuff was especially introduced to avoid breaking the
guest ABI for old machine types (like the NIC naming alternation you evoke).
no_foois just another way to handle compat stuff,
and when it's more than one knob per feature it gets ugly really fast.
Hence, I'd prefer pcihp done in x86 way aka:
hw_compat_OLD(ged.use_acpi_hotplug_bridge, false|true)to manage presence of ACPI hotplug on desired machine version. Side benefit it's consistent with how pcihp works on x86Quoted 141 lines
Quoted 47 lines
Quoted 35 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass { bool no_tcg_lpa2; bool no_ns_el2_virt_timer_irq; bool no_nested_smmu; + bool no_acpi_pcihp; }; struct VirtMachineState {@@ -150,6 +151,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@@ -2397,8 +2397,10 @@ static void machvirt_init(MachineState *machine) create_pcie(vms);Quoted 3 lines
if (
has_ged&& aarch64 &&firmware_loaded&&virt_is_acpi_enabled(vms)) {
+vms->acpi_pcihp&= !vmc->no_acpi_pcihp;I don't particularly like
no_foonaming as it makes code harder to read
and combined with 'duplicated' field in machine state it make even things worse.
(if I recall right Philippe was cleaning mess similar flags usage
have introduced with ITS)Quoted 4 lines
instead of adding machine property (both class and state), I'd suggest adding the only property to GPE device (akin to what we have in x86 world)
And then one can meddle with defaults usinghw_compat_xxx
no_foostill is a largely used pattern in arm virt:no_ged,kvm_no_adjvtime,no_kvm_steal_time,no_tcg_lpa2, ../.. There are plenty
of them and I am not under the impression this is going to be changed.If you refer to
8d23b1df7212("hw/arm/virt: RemoveVirtMachineClass::no_itsfield") I think theno_itswas removed because
the machine it applied was removed.If I understand correctly you would like the prop to be attached to the
GED device. However the GED device is internally created by the virt
machine code and not passed through a "-device" CLI option. So how would
you pass the option on the cmd line if you don't want it to be set by
default per machine type?Thanks
Eric
Quoted 66 lines
Quoted 65 lines
vms->acpi_dev=create_acpi_ged(vms);
} else {
+vms->acpi_pcihp= false;create_gpio_devices(vms, VIRT_GPIO, sysmem); }
@@ -2593,6 +2595,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 +7
-0+{ + VirtMachineState *vms = VIRT_MACHINE(obj); + + return vms->acpi_pcihp; +} + +static void virt_set_acpi_pcihp(Object *obj, bool value,Error **errp)
hw/arm/virt.c +6
-0+{ + 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@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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 voidvirt_instance_init(Object *obj)hw/arm/virt.c +0
-0@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; }+ /* default disallows ACPI PCI hotplug */
+vms->acpi_pcihp= false;
+
/* Default disallows iommu instantiation */vms->iommu=VIRT_IOMMU_NONE;
@@ -3394,8 +3417,12 @@DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)static voidvirt_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)
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
In reply to Igor MammedovHi Igor,
Quoted 72 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)So I'd leave it disabled by default and let users to turn it on explicitly when needed.
Quoted 34 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)
Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxx
What I fail to understand is whether you want me to attach this property to the GPEX host bridge device or to the GED device. Comment on patch 6/25 seems to indicate you expect it to be attached to the GPEX. I ask here because also the GED device will need to be configured depending on the hp setting. Maybe we can retrieve the info from the gpex at that time. on x86 it is attached to piix4 or ich9 I/O controller hub which do not have direct equivalent on ARM.
Thanks
Eric
Quoted 63 lines
Quoted 63 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Quoted 75 lines · On Wed, 11 Jun 2025 08:47:36 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 72 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)So I'd leave it disabled by default and let users to turn it on explicitly when needed.
Quoted 34 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)
Quoted 5 lines
Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxxWhat I fail to understand is whether you want me to attach this property to the GPEX host bridge device or to the GED device. Comment on patch
I'd say GED.
Quoted 5 lines
6/25 seems to indicate you expect it to be attached to the GPEX. I ask here because also the GED device will need to be configured depending on the hp setting. Maybe we can retrieve the info from the gpex at that time. on x86 it is attached to piix4 or ich9 I/O controller hub which do not have direct equivalent on ARM.
for ARM, equivalent would be GED device which hosts our paravirt acpi registers.
Quoted 68 lines
Thanks
Eric
Quoted 63 lines
Quoted 63 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Quoted 83 lines · Igor Mammedov
Quoted 75 lines · On Wed, 11 Jun 2025 08:47:36 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 72 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)So I'd leave it disabled by default and let users to turn it on explicitly when needed.
Quoted 34 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 5 lines
Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxxWhat I fail to understand is whether you want me to attach this property to the GPEX host bridge device or to the GED device. Comment on patch
Quoted 8 lines
I'd say GED.
Quoted 5 lines
6/25 seems to indicate you expect it to be attached to the GPEX. I ask here because also the GED device will need to be configured depending on the hp setting. Maybe we can retrieve the info from the gpex at that time. on x86 it is attached to piix4 or ich9 I/O controller hub which do not have direct equivalent on ARM.
for ARM, equivalent would be GED device which hosts our paravirt acpi registers.
OK thank you for the clarification. I will add a property to the GED device.
As the GED device is directly instantiated by the virt machine code (not exposed to the end user CLI) I guess we still want a virt machine option that would allow to set the property explicitly from CLI?
Thanks
Eric
Quoted 66 lines
Quoted 66 lines
Thanks
Eric
Quoted 62 lines
Quoted 62 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Quoted 91 lines · On Wed, 11 Jun 2025 10:56:36 +0200 Eric Auger <[email protected]> wrote:
Quoted 90 lines · Igor Mammedov
Quoted 75 lines · On Wed, 11 Jun 2025 08:47:36 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 72 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)So I'd leave it disabled by default and let users to turn it on explicitly when needed.
Quoted 34 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 5 lines
Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxxWhat I fail to understand is whether you want me to attach this property to the GPEX host bridge device or to the GED device. Comment on patch
I'd say GED.
Quoted 5 lines
6/25 seems to indicate you expect it to be attached to the GPEX. I ask here because also the GED device will need to be configured depending on the hp setting. Maybe we can retrieve the info from the gpex at that time. on x86 it is attached to piix4 or ich9 I/O controller hub which do not have direct equivalent on ARM.
Quoted 7 lines
Quoted 1 line
for ARM, equivalent would be GED device which hosts our paravirt acpi registers.
OK thank you for the clarification. I will add a property to the GED device.
As the GED device is directly instantiated by the virt machine code (not exposed to the end user CLI) I guess we still want a virt machine option that would allow to set the property explicitly from CLI?
Instead of machine option,
I'd go pc/q35 way (aka -global ged.acpi-pci-hotplug-with-bridges=on/off). it's not as pretty as machine specific option but that would work just as well and as bonus could be used for microvm in the same form.
Quoted 71 lines
Thanks
Eric
Quoted 66 lines
Quoted 66 lines
Thanks
Eric
Quoted 62 lines
Quoted 62 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
Hi Igor,
Quoted 97 lines · Igor Mammedov
Quoted 94 lines · On Wed, 11 Jun 2025 10:56:36 +0200 Eric Auger <[email protected]> wrote:
Quoted 83 lines · Igor Mammedov
Quoted 75 lines · On Wed, 11 Jun 2025 08:47:36 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 72 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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).there is no reason to put an effort in force disabling it on old machines, as long as code works when explicitly enabled property on CLI.
See comment below on how to deal with it
Quoted 5 lines
Machine state
acpi_pcihpflag must 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.
one thing to note, is that turning it on by default might cause change of NIC naming in guest as this brings in new "
_Sxx" slot naming. /so configs tied to nic go down the drain/Naming, we have, also happens to be broken wrt spec
(it should be unique system wide, there was a gitlab issue for that, there is no easy fix that though)So I'd leave it disabled by default and let users to turn it on explicitly when needed.
Quoted 34 lines
We also introduce properties to allow disabling it.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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@@ -129,6 +129,7 @@ struct VirtMachineClass {bool no_tcg_lpa2;bool no_ns_el2_virt_timer_irq;bool no_nested_smmu; +bool no_acpi_pcihp; };struct VirtMachineState {@@ -150,6 +151,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
-0hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2400
Quoted 4 lines
hw/arm/virt.c +1
-0@@ -2397,8 +2397,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;I don't particularly like
no_foonaming as it makes code harder to read and combined with 'duplicated' field in machine state it make even things worse. (if I recall right Philippe was cleaning mess similar flags usage have introduced with ITS)Quoted 5 lines
Quoted 3 lines
instead of adding machine property (both class and state),
I'd suggest adding the only property to GPE device (akin to what we have in x86 world) And then one can meddle with defaults usinghw_compat_xxxWhat I fail to understand is whether you want me to attach this property to the GPEX host bridge device or to the GED device. Comment on patch
Quoted 8 lines
I'd say GED.
Quoted 5 lines
6/25 seems to indicate you expect it to be attached to the GPEX. I ask here because also the GED device will need to be configured depending on the hp setting. Maybe we can retrieve the info from the gpex at that time. on x86 it is attached to piix4 or ich9 I/O controller hub which do not have direct equivalent on ARM.
for ARM, equivalent would be GED device which hosts our paravirt acpi registers.
OK thank you for the clarification. I will add a property to the GED device.
Quoted 7 lines
Quoted 3 lines
As the GED device is directly instantiated by the virt machine code (not exposed to the end user CLI) I guess we still want a virt machine option that would allow to set the property explicitly from CLI?
Instead of machine option,
I'd go pc/q35 way (aka -global ged.acpi-pci-hotplug-with-bridges=on/off). it's not as pretty as machine specific option but that would work just as well and as bonus could be used for microvm in the same form.
Ah OK. Then I need to rework it.
Thanks!
Eric
Quoted 70 lines
Quoted 70 lines
Thanks
Eric
Quoted 66 lines
Quoted 66 lines
Thanks
Eric
Quoted 62 lines
Quoted 62 lines
hw/arm/virt.c +26
-0vms->acpi_dev =create_acpi_ged (vms); }else { + vms->acpi_pcihp = false;create_gpio_devices (vms,VIRT_GPIO , sysmem); }@@ -2593,6 +2595,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);@@ -3310,6 +3326,10 @@ static void virt_machine_class_init(ObjectClass *oc, const 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)@@ -3344,6 +3364,9 @@ static void virt_instance_init(Object *obj) vms->tcg_its = true; } +/* default disallows ACPI PCI hotplug */ + vms->acpi_pcihp = false; +/* Default disallows iommu instantiation */ vms->iommu =VIRT_IOMMU_NONE ;@@ -3394,8 +3417,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 )
Re: [PATCH v2 02/25] hw/arm/virt: Introduce machine state acpi pcihp flags and props
In reply to Eric AugerQuoted 8 lines · On Tue, 27 May 2025 09:40:04 +0200 Eric Auger <[email protected]> wrote:
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 must be set before the creation of the GED device which will use it.
Quoted 7 lines
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]>Reviewed-by Gustavo Romero <[email protected]>
Seems fine though I'm not sure on the default for 10.1 I don't feel that strongly about it though.
PATCH v2 3/25 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.
Also fix the reference to acpi_pci_hotplug.rst documentation
---
v1 -> v2:
- s/spec/specs in reference to rst (Gustavo)
- fixed double space in commit msg (Gustavo)
rfc -> v1:
- make build_append_pci_dsm_func0_common non static and move it to pcihp
--- hw/i386/acpi-build.h | 4 - include/hw/acpi/pcihp.h | 9 +- hw/acpi/pcihp.c | 174 ++++++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 176 +--------------------------------------- 4 files changed, 183 insertions(+), 180 deletions(-)
hw/i386/acpi-build.h +0 -4
@@ -5,10 +5,6 @@extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; -/* PCI Hot-plug registers' base. See docs/specs/acpi_pci_hotplug.rst */ -#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 +8 -1
@@ -3,7 +3,7 @@* * QEMU supports PCI hotplug via ACPI. This module * implements the interface between QEMU and the ACPI BIOS. -* Interface specification - see docs/specs/acpi_pci_hotplug.txt +* Interface specification - see docs/specs/acpi_pci_hotplug.rst * * Copyright (c) 2013, Red Hat Inc, Michael S. Tsirkin ([email protected]) * Copyright (c) 2006 Fabrice Bellard
@@ -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/specs/acpi_pci_hotplug.rst */ +#define ACPI_PCIHP_SEJ_BASE 0x8 +#define ACPI_PCIHP_BNMR_BASE 0x10 + typedef struct AcpiPciHpPciStatus { uint32_t up; uint32_t down;
@@ -69,6 +73,9 @@ 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_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar); +/* 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 -174
206 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH v2 03/25] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
Quoted 6 lines · On Tue, 27 May 2025 09:40:05 +0200 Eric Auger <[email protected]> wrote:
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().
Quoted 6 lines
No code change intended.
Also fix the reference to
acpi_pci_hotplug.rstdocumentationSigned-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Quoted 473 lines
---
v1 -> v2:
- s/spec/specs in reference to rst (Gustavo)
- fixed double space in commit msg (Gustavo)rfc -> v1:
- makebuild_append_pci_dsm_func0_commonnon static and move it to pcihp--- hw/i386/acpi-build.h | 4 - include/hw/acpi/pcihp.h | 9 +- hw/acpi/pcihp.c | 174 ++++++++++++++++++++++++++++++++++++++- hw/i386/acpi-build.c | 176 +--------------------------------------- 4 files changed, 183 insertions(+), 180 deletions(-)hw/i386/acpi-build.h +0
-4@@ -5,10 +5,6 @@extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio; -/* PCI Hot-plug registers' base. See docs/specs/acpi_pci_hotplug.rst */ -#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 +8
-1@@ -3,7 +3,7 @@* * QEMU supports PCI hotplug via ACPI. This module * implements the interface between QEMU and the ACPI BIOS. -* Interface specification - see docs/specs/acpi_pci_hotplug.txt +* Interface specification - see docs/specs/acpi_pci_hotplug.rst * * Copyright (c) 2013, Red Hat Inc, Michael S. Tsirkin ([email protected]) * Copyright (c) 2006 Fabrice Bellard @@ -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/specs/acpi_pci_hotplug.rst */ +#define ACPI_PCIHP_SEJ_BASE 0x8 +#define ACPI_PCIHP_BNMR_BASE 0x10 + typedef struct AcpiPciHpPciStatus { uint32_t up; uint32_t down;@@ -69,6 +73,9 @@ 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_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar); +/* 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); } +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
-174@@ -361,32 +361,6 @@ static Aml *aml_pci_device_dsm(void)return method; } -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_edsm (void ) {Aml *method, *ifctx;@@ -647,96 +621,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 +1111,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 +1222,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 +1266,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: [PATCH v2 03/25] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
In reply to Eric AugerQuoted 6 lines · On Tue, 27 May 2025 09:40:05 +0200 Eric Auger <[email protected]> wrote:
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().
Quoted 6 lines
No code change intended.
Also fix the reference to
acpi_pci_hotplug.rstdocumentationSigned-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Indeed moves the code as described...
PATCH v2 4/25 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.
---
rfc -> v1:
- updated the "Allow OS control for all 5 features" comment
--- hw/pci-host/gpex-acpi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
hw/pci-host/gpex-acpi.c +8 -7
@@ -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;
@@ -77,11 +77,12 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" )));/* -* Allow OS control for all 5 features: -* PCIeHotplug SHPCHotplug PME AER PCIeCapability. +* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, +* and PCIeHotplug depending on enable_native_pcie_hotplug */ -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: [PATCH v2 04/25] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
Quoted 5 lines · On Tue, 27 May 2025 09:40:06 +0200 Eric Auger <[email protected]> wrote:
Add a new argument to
acpi_dsdt_add_pci_oscto be able to disable native pci hotplug.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Quoted 57 lines
---
rfc -> v1:
- updated the "Allow OS control for all 5 features" comment--- hw/pci-host/gpex-acpi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)hw/pci-host/gpex-acpi.c +8
-7@@ -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;@@ -77,11 +77,12 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" )));/* -* Allow OS control for all 5 features: -* PCIeHotplug SHPCHotplug PME AER PCIeCapability. +* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, +* and PCIeHotplug depending on enable_native_pcie_hotplug */ -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: [PATCH v2 04/25] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
In reply to Eric AugerQuoted 5 lines · On Tue, 27 May 2025 09:40:06 +0200 Eric Auger <[email protected]> wrote:
Add a new argument to
acpi_dsdt_add_pci_oscto be able to disable native pci hotplug.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Hi Eric,
Makes me wonder what we should do for CXL - I was expecting a very similar change. Currently seems like those always allow native hotplug (__build_cxl_osc_method()) on x86 and arm64 (patches on list).
Maybe that has only been working because the kernel is reading the PCI _OSC first. Or it's always been doing native hotplug an no one noticed. A quick look at logs shows the kernel first gets told no, then yes as it queries the two different _OSC types.
Looks like I should fix that _OSC then it should be carried over to this as well (or if you don't mind adding a trivial patch to replicate this patch for the CXL _OSC, even better!)
Other than that, this patch looks fine to me though I do wonder if we could unify this with build_q35_osc_method()? I'm not the best at reading AML generation code but whilst they are written quite differently they seem to be functionally very similar, more so after this patch.
Quoted 40 lines
---
rfc -> v1:
- updated the "Allow OS control for all 5 features" comment--- hw/pci-host/gpex-acpi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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;@@ -77,11 +77,12 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" )));/* -* Allow OS control for all 5 features: -* PCIeHotplug SHPCHotplug PME AER PCIeCapability. +* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, +* and PCIeHotplug depending on enable_native_pcie_hotplug */ -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 void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 194
Quoted 2 lines
hw/pci-host/gpex-acpi.c +0
-0@@ -192,7 +193,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev);
This was the path I was expecting to change as well.
Quoted 15 lines
hw/pci-host/gpex-acpi.c +2
-2}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: [PATCH v2 04/25] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
Quoted 26 lines · On Fri, 30 May 2025 10:27:11 +0100 Jonathan Cameron…
Quoted 5 lines · On Tue, 27 May 2025 09:40:06 +0200 Eric Auger <[email protected]> wrote:
Add a new argument to
acpi_dsdt_add_pci_oscto be able to disable native pci hotplug.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Hi Eric,
Makes me wonder what we should do for CXL - I was expecting a very similar change. Currently seems like those always allow native hotplug (
__build_cxl_osc_method()) on x86 and arm64 (patches on list).Maybe that has only been working because the kernel is reading the PCI
_OSCfirst. Or it's always been doing native hotplug an no one noticed. A quick look at logs shows the kernel first gets told no, then yes as it queries the two different_OSCtypes.Looks like I should fix that
_OSCthen it should be carried over to this as well (or if you don't mind adding a trivial patch to replicate this patch for the CXL_OSC, even better!)
Quoted 6 lines
Other than that, this patch looks fine to me though I do wonder if we could unify this with
build_q35_osc_method()? I'm not the best at reading AML generation code but whilst they are written quite differently they seem to be functionally very similar, more so after this patch.
I should have read on... Sorry for the noise!
J
Quoted 61 lines
Quoted 40 lines
---
rfc -> v1:
- updated the "Allow OS control for all 5 features" comment--- hw/pci-host/gpex-acpi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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;@@ -77,11 +77,12 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" )));/* -* Allow OS control for all 5 features: -* PCIeHotplug SHPCHotplug PME AER PCIeCapability. +* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, +* and PCIeHotplug depending on enable_native_pcie_hotplug */ -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 void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 194
Quoted 2 lines
hw/pci-host/gpex-acpi.c +0
-0@@ -192,7 +193,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev);This was the path I was expecting to change as well.
Quoted 15 lines
hw/pci-host/gpex-acpi.c +2
-2}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: [PATCH v2 04/25] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
In reply to Jonathan CameronHi Jonathan,
Quoted 21 lines · Jonathan Cameron
Quoted 5 lines · On Tue, 27 May 2025 09:40:06 +0200 Eric Auger <[email protected]> wrote:
Add a new argument to
acpi_dsdt_add_pci_oscto be able to disable native pci hotplug.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Hi Eric,
Makes me wonder what we should do for CXL - I was expecting a very similar change. Currently seems like those always allow native hotplug (
__build_cxl_osc_method()) on x86 and arm64 (patches on list).Maybe that has only been working because the kernel is reading the PCI
_OSCfirst. Or it's always been doing native hotplug an no one noticed. A quick look at logs shows the kernel first gets told no, then yes as it queries the two different_OSCtypes.
Quoted 3 lines
Looks like I should fix that
_OSCthen it should be carried over to this as well (or if you don't mind adding a trivial patch to replicate this patch for the CXL_OSC, even better!)
If you don't mind I would prefer we carry out cxl changes separately as it may also require some test blob changes and I am not much knowledgable on CXL yet. I would prefer stabilizing this series before extending it.
But sure if it is relevant we can then mimic that change on cxl path.
Eric
Quoted 65 lines
Other than that, this patch looks fine to me though I do wonder if we could unify this with
build_q35_osc_method()? I'm not the best at reading AML generation code but whilst they are written quite differently they seem to be functionally very similar, more so after this patch.Quoted 39 lines
---
rfc -> v1:
- updated the "Allow OS control for all 5 features" comment--- hw/pci-host/gpex-acpi.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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;@@ -77,11 +77,12 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" )));/* -* Allow OS control for all 5 features: -* PCIeHotplug SHPCHotplug PME AER PCIeCapability. +* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, +* and PCIeHotplug depending on enable_native_pcie_hotplug */ -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 void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 194
Quoted 2 lines
hw/pci-host/gpex-acpi.c +0
-0@@ -192,7 +193,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)if (is_cxl) {build_cxl_osc_method (dev);This was the path I was expecting to change as well.
Quoted 15 lines
hw/pci-host/gpex-acpi.c +2
-2}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" )));
PATCH v2 5/25 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: [PATCH v2 05/25] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
Quoted 8 lines · On Tue, 27 May 2025 09:40:07 +0200 Eric Auger <[email protected]> wrote:
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.
Quoted 5 lines
acpi_dsdt_add_host_bridge_methodsis a new top helper that generates both the_OSCand_DSMmethods.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Quoted 77 lines
--- 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" )));
Re: [PATCH v2 05/25] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
In reply to Eric AugerQuoted 8 lines · On Tue, 27 May 2025 09:40:07 +0200 Eric Auger <[email protected]> wrote:
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.
Quoted 5 lines
acpi_dsdt_add_host_bridge_methodsis a new top helper that generates both the_OSCand_DSMmethods.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Makes complete sense. I've had local equivalent of this on the CXL tree for a while as without it we don't register the _DSM for the CXL path (and we should). However, can you modify it a little to make that easier for me? Basically make sure the _DSM is registered for the CXL path as well.
One other comment inline.
Quoted 43 lines
--- hw/pci-host/gpex-acpi.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)hw/pci-host/gpex-acpi.c +8
-7@@ -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);
hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) · line 135
Quoted 10 lines
hw/pci-host/gpex-acpi.c +8
-1aml_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 )));
These two declarations seem to be very much part of the _OSC build though not within the the method. I 'think' you get left with them later with no users. So move them into the osc build here and they will naturally go away when you move to the generic code.
They end up unused in the DSDT at the end of the series.
I ran a quick GPEX + pxb-pcie test and we do get the odd mix that the OSC for the GPEX say no native hotplug but the OSC for the PXB allows it.
hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 207
Quoted 12 lines
hw/pci-host/gpex-acpi.c +4
-1+/* 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);
Can you either drop the use of the wrapper for the DSM part here and call it unconditionally (for cxl and PCIe cases) or add an extra call to aml_append(dev, build_host_bridge_dsm()) for the is_cxl path?
Quoted 12 lines
hw/pci-host/gpex-acpi.c +1
-1}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" )));
Re: [PATCH v2 05/25] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
Quoted 14 lines · On Fri, 30 May 2025 11:02:27 +0100 Jonathan Cameron…
Quoted 11 lines · On Tue, 27 May 2025 09:40:07 +0200 Eric Auger <[email protected]> wrote:
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.
Quoted 9 lines
Quoted 2 lines
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Makes complete sense. I've had local equivalent of this on the CXL tree for a while as without it we don't register the
_DSMfor the CXL path (and we should). However, can you modify it a little to make that easier for me? Basically make sure the_DSMis registered for the CXL path as well.
[...]
unless CXL is root host bridge, current _DSM shouldn't be added to it. read on comment below.
Quoted 19 lines
hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) · line 135
Quoted 13 lines
hw/pci-host/gpex-acpi.c +8
-1@@ -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 )));These two declarations seem to be very much part of the
_OSCbuild though not within the the method. I 'think' you get left with them later with no users. So move them into the osc build here and they will naturally go away when you move to the generic code.
Quoted 4 lines
They end up unused in the DSDT at the end of the series.
I ran a quick GPEX + pxb-pcie test and we do get the odd mix that the OSC for the GPEX say no native hotplug but the OSC for the PXB allows it.
It's fine for each PXB to have it's own _OSC.
Also current incarnation of ACPI pcihp doesn't support PXBs at all, it would be wrong to enable the on PXBs.
Thus I'd avoid touching CXL related code paths from this series.
I'm working on extending ACPI pcihp to PXBs
(for the same reason as Eric does for arm/virt, i.e. enable acpi-index support there). I can add CXL bits then if there is a need/demand for that in CXL land.
[...]
Re: [PATCH v2 05/25] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
Quoted 26 lines · On Fri, 30 May 2025 14:05:16 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 14 lines · On Fri, 30 May 2025 11:02:27 +0100 Jonathan Cameron…
Quoted 11 lines · On Tue, 27 May 2025 09:40:07 +0200 Eric Auger <[email protected]> wrote:
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.Quoted 9 lines
Quoted 2 lines
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Makes complete sense. I've had local equivalent of this on the CXL tree for a while as without it we don't register the
_DSMfor the CXL path (and we should). However, can you modify it a little to make that easier for me? Basically make sure the_DSMis registered for the CXL path as well.
Quoted 3 lines
[...]
unless CXL is root host bridge, current_DSMshouldn't be added to it. read on comment below.
I'm not clear how this is different from pxb-pcie where we do have the _DSM. Both are pretending to be real host bridges.
Quoted 29 lines
Quoted 20 lines
Quoted 4 lines
hw/pci-host/gpex-acpi.c +0
-0@@ -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);hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) · line 135
Quoted 10 lines
hw/pci-host/gpex-acpi.c +8
-1aml_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 )));These two declarations seem to be very much part of the
_OSCbuild though not within the the method. I 'think' you get left with them later with no users. So move them into the osc build here and they will naturally go away when you move to the generic code.Quoted 4 lines
They end up unused in the DSDT at the end of the series.
I ran a quick GPEX + pxb-pcie test and we do get the odd mix that the OSC for the GPEX say no native hotplug but the OSC for the PXB allows it.
It's fine for each PXB to have it's own
_OSC.
Also current incarnation of ACPI pcihp doesn't support PXBs at all, it would be wrong to enable the on PXBs.
Quoted 5 lines
Thus I'd avoid touching CXL related code paths from this series.
I'm working on extending ACPI pcihp to PXBs
(for the same reason as Eric does for arm/virt, i.e. enable acpi-index support there). I can add CXL bits then if there is a need/demand for that in CXL land.
Ok. My original motivation for _DSM on CXL was function 5 to stop Linux messing up the reenumeration which I know has been rejected upstream for a bunch of compatibility reasons. Anyhow, that's a future problem.
Thanks,
Jonathan
Quoted 4 lines
[...]
Re: [PATCH v2 05/25] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
Quoted 29 lines · On Fri, 30 May 2025 16:00:19 +0100 Jonathan Cameron…
Quoted 26 lines · On Fri, 30 May 2025 14:05:16 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 23 lines · On Fri, 30 May 2025 11:02:27 +0100 Jonathan Cameron…
Quoted 8 lines · On Tue, 27 May 2025 09:40:07 +0200 Eric Auger <[email protected]> wrote:
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.Quoted 5 lines
acpi_dsdt_add_host_bridge_methodsis a new top helper that generates both the_OSCand_DSMmethods.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Makes complete sense. I've had local equivalent of this on the CXL tree for a while as without it we don't register the
_DSMfor the CXL path (and we should). However, can you modify it a little to make that easier for me? Basically make sure the_DSMis registered for the CXL path as well.
Quoted 6 lines
Quoted 3 lines
[...]
unless CXL is root host bridge, current_DSMshouldn't be added to it. read on comment below.I'm not clear how this is different from pxb-pcie where we do have the
_DSM. Both are pretending to be real host bridges.
there is some space for _OSC consolidation, but it's not realy related to pcihp, so I'd rather do it as a separate series on top.
current PCI _DSM and _CXL one (build_cxl_dsm_method) are implementing different namespaces, there is not much to consolidate there.
If later on CXL would need E5C937D0-3553-4D7A-9117-EA4D19C3434D, then, I'd say do it at that time and use that moment as an opportunity to consolidate.
Quoted 31 lines
Quoted 31 lines
Quoted 20 lines
Quoted 4 lines
hw/pci-host/gpex-acpi.c +0
-0@@ -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);hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) · line 135
Quoted 10 lines
hw/pci-host/gpex-acpi.c +8
-1aml_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 )));These two declarations seem to be very much part of the
_OSCbuild though not within the the method. I 'think' you get left with them later with no users. So move them into the osc build here and they will naturally go away when you move to the generic code.Quoted 4 lines
They end up unused in the DSDT at the end of the series.
I ran a quick GPEX + pxb-pcie test and we do get the odd mix that the OSC for the GPEX say no native hotplug but the OSC for the PXB allows it.
It's fine for each PXB to have it's own
_OSC.
Also current incarnation of ACPI pcihp doesn't support PXBs at all, it would be wrong to enable the on PXBs.Thus I'd avoid touching CXL related code paths from this series.
Quoted 7 lines
Quoted 3 lines
I'm working on extending ACPI pcihp to PXBs
(for the same reason as Eric does for arm/virt, i.e. enable acpi-index support there). I can add CXL bits then if there is a need/demand for that in CXL land.Ok. My original motivation for
_DSMon CXL was function 5 to stop Linux messing up the reenumeration which I know has been rejected upstream for a bunch of compatibility reasons. Anyhow, that's a future problem.
yep, let's worry about merging _DSMs when that future comes.
Quoted 10 lines
Thanks,
Jonathan
Quoted 4 lines
[...]
Re: [PATCH v2 05/25] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
In reply to Jonathan CameronHi Jonathan,
Quoted 83 lines · Jonathan Cameron
Quoted 8 lines · On Tue, 27 May 2025 09:40:07 +0200 Eric Auger <[email protected]> wrote:
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.Quoted 5 lines
acpi_dsdt_add_host_bridge_methodsis a new top helper that generates both the_OSCand_DSMmethods.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Makes complete sense. I've had local equivalent of this on the CXL tree for a while as without it we don't register the
_DSMfor the CXL path (and we should). However, can you modify it a little to make that easier for me? Basically make sure the_DSMis registered for the CXL path as well.One other comment inline.
Quoted 43 lines
--- hw/pci-host/gpex-acpi.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)hw/pci-host/gpex-acpi.c +8
-7@@ -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);hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) · line 135
Quoted 10 lines
hw/pci-host/gpex-acpi.c +8
-1aml_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 )));These two declarations seem to be very much part of the
_OSCbuild though not within the the method. I 'think' you get left with them later with no users. So move them into the osc build here and they will naturally go away when you move to the generic code.
Quoted 1 line
They end up unused in the DSDT at the end of the series.
Done
Thanks
Eric
Quoted 32 lines
I ran a quick GPEX + pxb-pcie test and we do get the odd mix that the OSC for the GPEX say no native hotplug but the OSC for the PXB allows it.
hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 207
Quoted 12 lines
hw/pci-host/gpex-acpi.c +4
-1+/* 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);Can you either drop the use of the wrapper for the DSM part here and call it unconditionally (for cxl and PCIe cases) or add an extra call to
aml_append(dev, build_host_bridge_dsm())for theis_cxlpath?Quoted 12 lines
hw/pci-host/gpex-acpi.c +1
-1}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" )));
Re: [PATCH v2 05/25] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
In reply to Jonathan CameronHi Jonathan
Quoted 93 lines · Jonathan Cameron
Quoted 8 lines · On Tue, 27 May 2025 09:40:07 +0200 Eric Auger <[email protected]> wrote:
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.Quoted 5 lines
acpi_dsdt_add_host_bridge_methodsis a new top helper that generates both the_OSCand_DSMmethods.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Makes complete sense. I've had local equivalent of this on the CXL tree for a while as without it we don't register the
_DSMfor the CXL path (and we should). However, can you modify it a little to make that easier for me? Basically make sure the_DSMis registered for the CXL path as well.One other comment inline.
Quoted 43 lines
--- hw/pci-host/gpex-acpi.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-)hw/pci-host/gpex-acpi.c +8
-7@@ -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);hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug) · line 135
Quoted 10 lines
hw/pci-host/gpex-acpi.c +8
-1aml_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 )));These two declarations seem to be very much part of the
_OSCbuild though not within the the method. I 'think' you get left with them later with no users. So move them into the osc build here and they will naturally go away when you move to the generic code.They end up unused in the DSDT at the end of the series.
I ran a quick GPEX + pxb-pcie test and we do get the odd mix that the OSC for the GPEX say no native hotplug but the OSC for the PXB allows it.
Quoted 5 lines
hw/pci-host/gpex-acpi.c +3
-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 ()); }
Quoted 10 lines
hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 207
Quoted 7 lines
hw/pci-host/gpex-acpi.c +1
-1void 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);Can you either drop the use of the wrapper for the DSM part here and call it unconditionally (for cxl and PCIe cases) or add an extra call to
aml_append(dev, build_host_bridge_dsm())for theis_cxlpath?
Given the following discussion between you and Igor, I understand we can keep the code as is for now. cxl alignment would be done later and also pxb support might be reworked in near future.
Eric
Quoted 13 lines
Quoted 13 lines
hw/pci-host/gpex-acpi.c +1
-1}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" )));
PATCH v2 6/25 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: [PATCH v2 06/25] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
Quoted 4 lines · On Tue, 27 May 2025 09:40:08 +0200 Eric Auger <[email protected]> wrote:
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.
this is not needed if done as suggested in 2/25
Quoted 54 lines
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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 +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" )));
Re: [PATCH v2 06/25] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
Hi Igor,
Quoted 8 lines · Igor Mammedov
Quoted 4 lines · On Tue, 27 May 2025 09:40:08 +0200 Eric Auger <[email protected]> wrote:
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.this is not needed if done as suggested in 2/25
So since the property would be applied to the GED device we will still need a patch that retrieves the GED setting and propagate it to the GPEX device.
Thanks
Eric
Quoted 55 lines
Quoted 54 lines
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[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 +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" )));
Re: [PATCH v2 06/25] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
Quoted 6 lines · On Wed, 11 Jun 2025 11:00:02 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 3 lines · Igor Mammedov
On Tue, 27 May 2025 09:40:08 +0200
Eric Auger <[email protected]> wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
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.this is not needed if done as suggested in 2/25
So since the property would be applied to the GED device we will still need a patch that retrieves the GED setting and propagate it to the GPEX device.
I don't see a need for propagating it to GPEX device itself for ACPI sake.
For ACPI code, what we do in q35 case is fetching pm->pcihp_bridge_en from acpi_dev(whatever it is) and then passing it down trough call-chain
build_dsdt->build_q35_osc_method
the only hack that touches GPEX device model, is the need to wire up root bus to GED, when GED is being created. So that GED would be able to swap hotplug handler on an acpi specific one when configured to do so.
Quoted 6 lines
Thanks
Eric
Quoted 3 lines
Quoted 3 lines
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
[...]
Quoted 6 lines
Quoted 6 lines
hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 283
Quoted 6 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);
also, having sufficiently forgotten this series context.
It might be better to abandon idea of consolidating osc and dsm methods in acpi_dsdt_add_host_bridge_methods().
Just looking at above is confusing and forces one to re-rear previous commits to figure out what acpi_dsdt_add_host_bridge_methods() is doing.
having here separate sequence of
add_osc()
add_dsm()
would be much more readable.
Lets drop acpi_dsdt_add_host_bridge_methods() helper.
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
hw/pci-host/gpex-acpi.c +0
-0Aml *dev_res0 =aml_device ("%s" ,"RES0" );aml_append (dev_res0,aml_name_decl ("_HID" ,aml_string ("PNP0C02" )));
Re: [PATCH v2 06/25] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
In reply to Eric AugerQuoted 42 lines · On Tue, 27 May 2025 09:40:08 +0200 Eric Auger <[email protected]> wrote:
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]>Reviewed-by Gustavo Romero <[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 +0
-0
hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 208
Quoted 5 lines
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);
This is awkward but explains why my CXL cases weren't causing trouble. A mixed config is counter to the recommendation in the PCI firmware spec
"It is recommended that a machine with multiple host bridge devices should report the same capabilities for all host bridges of the same type and also negotiate control of the features described in the Control Field in the same way for all host bridges of the same type"
I guess if any OS isn't coping with the mix then they can request native hotplug.
Quoted 11 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" )));
Re: [PATCH v2 06/25] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
Quoted 54 lines · On Fri, 30 May 2025 11:14:13 +0100 Jonathan Cameron…
Quoted 42 lines · On Tue, 27 May 2025 09:40:08 +0200 Eric Auger <[email protected]> wrote:
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]>Reviewed-by Gustavo Romero <[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 +0
-0hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 208
Quoted 5 lines
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);This is awkward but explains why my CXL cases weren't causing trouble. A mixed config is counter to the recommendation in the PCI firmware spec
Quoted 7 lines
"It is recommended that a machine with multiple host bridge devices should report the same capabilities for all host bridges of the same type and also negotiate control of the features described in the Control Field in the same way for all host bridges of the same type"
I guess if any OS isn't coping with the mix then they can request native hotplug.
guest should be able to cope with mixed configs, ACPI pcihp is a crutch and works only for coldplugged bridges, while hotplugged bridges are handled by native hotplug.
Quoted 15 lines
Quoted 14 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" )));
Re: [PATCH v2 06/25] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
In reply to Jonathan CameronHi Jonathan,
Quoted 53 lines · Jonathan Cameron
Quoted 42 lines · On Tue, 27 May 2025 09:40:08 +0200 Eric Auger <[email protected]> wrote:
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]>Reviewed-by Gustavo Romero <[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 +0
-0hw/pci-host/gpex-acpi.c void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg) · line 208
Quoted 5 lines
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);This is awkward but explains why my CXL cases weren't causing trouble. A mixed config is counter to the recommendation in the PCI firmware spec
Quoted 4 lines
"It is recommended that a machine with multiple host bridge devices should report the same capabilities for all host bridges of the same type and also negotiate control of the features described in the Control Field in the same way for all host bridges of the same type"
Thank for pointing to this spec excerpt.
Maybe the nuance relates to "host bridges of the same type", ie. gpex versus pxb?
refering to Igor's following reply i will leave it as is. This is inherited from existing x86 code inhw/i386/acpi-build.c build_dsdt():
/* Expander bridges do not have ACPI PCI Hot-plug enabled */ aml_append(dev, build_q35_osc_method(true));
Eric
Quoted 17 lines
I guess if any OS isn't coping with the mix then they can request native hotplug.
Quoted 11 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" )));
PATCH v2 7/25 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
Re: [PATCH v2 07/25] hw/i386/acpi-build: Turn build_q35_osc_method into a generic method
hw/acpi/aml-build.c
Quoted 27 lines · On Tue, 27 May 2025 09:40:09 +0200 Eric Auger <[email protected]> wrote:
GPEX
acpi_dsdt_add_pci_osc()does basically the same asbuild_q35_osc_method().Rename
build_q35_osc_method()intobuild_pci_host_bridge_osc_method()and move it intohw/acpi/aml-build.c. In a subsequent patch we will use this later in place ofacpi_dsdt_add_pci_osc().Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>--- 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 +0
-0
I'd suggest to use hw/acpi/pci.c for PCI stuff instead of generic aml-build.c
Quoted 136 lines
index
f8f93a9f66..ba1dfe0b52100644hw/acpi/aml-build.c +50
-0@@ -2614,3 +2614,53 @@ Aml *aml_i2c_serial_bus_device(uint16_t address, const char *resource_source)return var; } + +Aml *build_pci_host_bridge_osc_method (bool enable_native_pcie_hotplug) +{ +Aml *if_ctx; +Aml *if_ctx2; +Aml *else_ctx; +Aml *method; +Aml *a_cwd1 =aml_name ("CDW1" ); +Aml *a_ctrl =aml_local (0 ); + + method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED ); +aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" )); + + if_ctx =aml_if (aml_equal ( +aml_arg (0 ),aml_touuid ("33DB4D5B-1FF7-401C-9657-7441C03DD766" ))); +aml_append (if_ctx,aml_create_dword_field (aml_arg (3 ),aml_int (4 ),"CDW2" )); +aml_append (if_ctx,aml_create_dword_field (aml_arg (3 ),aml_int (8 ),"CDW3" )); + +aml_append (if_ctx,aml_store (aml_name ("CDW3" ), a_ctrl)); + +/* +* Always allow native PME, AER (no dependencies) +* Allow SHPC (PCI bridges can have SHPC controller) +* Disable PCIe Native Hot-plug if ACPI PCI Hot-plug is enabled. +*/ +aml_append (if_ctx,aml_and (a_ctrl, +aml_int (0x1E | (enable_native_pcie_hotplug ?0x1 :0x0 )), a_ctrl)); + + if_ctx2 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (1 )))); +/* Unknown revision */ +aml_append (if_ctx2,aml_or (a_cwd1,aml_int (0x08 ), a_cwd1)); +aml_append (if_ctx, if_ctx2); + + if_ctx2 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ), a_ctrl))); +/* Capabilities bits were masked */ +aml_append (if_ctx2,aml_or (a_cwd1,aml_int (0x10 ), a_cwd1)); +aml_append (if_ctx, if_ctx2); + +/* Update DWORD3 in the buffer */ +aml_append (if_ctx,aml_store (a_ctrl,aml_name ("CDW3" ))); +aml_append (method, if_ctx); + + else_ctx =aml_else (); +/* Unrecognized UUID */ +aml_append (else_ctx,aml_or (a_cwd1,aml_int (4 ), a_cwd1)); +aml_append (method, else_ctx); + +aml_append (method,aml_return (aml_arg (3 ))); +return method; +}hw/i386/acpi-build.c +2
-52@@ -1111,56 +1111,6 @@ static Aml *build_q35_dram_controller(const AcpiMcfgInfo *mcfg)return dev; } -static Aml *build_q35_osc_method (bool enable_native_pcie_hotplug) -{ -Aml *if_ctx; -Aml *if_ctx2; -Aml *else_ctx; -Aml *method; -Aml *a_cwd1 =aml_name ("CDW1" ); -Aml *a_ctrl =aml_local (0 ); - - method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED ); -aml_append (method,aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" )); - - if_ctx =aml_if (aml_equal ( -aml_arg (0 ),aml_touuid ("33DB4D5B-1FF7-401C-9657-7441C03DD766" ))); -aml_append (if_ctx,aml_create_dword_field (aml_arg (3 ),aml_int (4 ),"CDW2" )); -aml_append (if_ctx,aml_create_dword_field (aml_arg (3 ),aml_int (8 ),"CDW3" )); - -aml_append (if_ctx,aml_store (aml_name ("CDW3" ), a_ctrl)); - -/* -* Always allow native PME, AER (no dependencies) -* Allow SHPC (PCI bridges can have SHPC controller) -* Disable PCIe Native Hot-plug if ACPI PCI Hot-plug is enabled. -*/ -aml_append (if_ctx,aml_and (a_ctrl, -aml_int (0x1E | (enable_native_pcie_hotplug ?0x1 :0x0 )), a_ctrl)); - - if_ctx2 =aml_if (aml_lnot (aml_equal (aml_arg (1 ),aml_int (1 )))); -/* Unknown revision */ -aml_append (if_ctx2,aml_or (a_cwd1,aml_int (0x08 ), a_cwd1)); -aml_append (if_ctx, if_ctx2); - - if_ctx2 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ), a_ctrl))); -/* Capabilities bits were masked */ -aml_append (if_ctx2,aml_or (a_cwd1,aml_int (0x10 ), a_cwd1)); -aml_append (if_ctx, if_ctx2); - -/* Update DWORD3 in the buffer */ -aml_append (if_ctx,aml_store (a_ctrl,aml_name ("CDW3" ))); -aml_append (method, if_ctx); - - else_ctx =aml_else (); -/* Unrecognized UUID */ -aml_append (else_ctx,aml_or (a_cwd1,aml_int (4 ), a_cwd1)); -aml_append (method, else_ctx); - -aml_append (method,aml_return (aml_arg (3 ))); -return method; -} -static void build_acpi0017 (Aml *table) {Aml *dev, *scope, *method;@@ -1231,7 +1181,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A08" )));aml_append (dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A03" )));aml_append (dev,aml_name_decl ("_UID" ,aml_int (pcmc->pci_root_uid))); -aml_append (dev,build_q35_osc_method (!pm->pcihp_bridge_en)); +aml_append (dev,build_pci_host_bridge_osc_method (!pm->pcihp_bridge_en));aml_append (dev,aml_pci_edsm ());aml_append (sb_scope, dev);if (mcfg_valid) {@@ -1353,7 +1303,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,aml_append (dev,aml_name_decl ("_CID" ,aml_eisaid ("PNP0A03" )));/* Expander bridges do not have ACPI PCI Hot-plug enabled */ -aml_append (dev,build_q35_osc_method (true)); +aml_append (dev,build_pci_host_bridge_osc_method (true)); }else {aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0A03" ))); }
PATCH v2 8/25 tests/qtest/bios-tables-test: Prepare for changes in the DSDT table
In reply to Eric AugerFrom: Gustavo Romero <[email protected]>
This commit adds DSDT blobs to the whilelist in the prospect to allow changes in the GPEX _OSC method.
--- tests/qtest/bios-tables-test-allowed-diff.h | 5 +++++ 1 file changed, 5 insertions(+)
tests/qtest/bios-tables-test-allowed-diff.h +5 -0
@@ -1 +1,6 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/DSDT" , +"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , +"tests/data/acpi/aarch64/virt/DSDT.memhp" , +"tests/data/acpi/aarch64/virt/DSDT.pxb" , +"tests/data/acpi/aarch64/virt/DSDT.topology",
Signature · 1 line
2.49.0
Re: [PATCH v2 08/25] tests/qtest/bios-tables-test: Prepare for changes in the DSDT table
Quoted 7 lines · On Tue, 27 May 2025 09:40:10 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
This commit adds DSDT blobs to the whilelist in the prospect to allow changes in the GPEX
_OSCmethod.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>
Quoted 15 lines
--- tests/qtest/bios-tables-test-allowed-diff.h | 5 +++++ 1 file changed, 5 insertions(+)tests/qtest/bios-tables-test-allowed-diff.h +5
-0@@ -1 +1,6 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/DSDT" , +"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , +"tests/data/acpi/aarch64/virt/DSDT.memhp" , +"tests/data/acpi/aarch64/virt/DSDT.pxb" , +"tests/data/acpi/aarch64/virt/DSDT.topology",
Re: [PATCH v2 08/25] tests/qtest/bios-tables-test: Prepare for changes in the DSDT table
Quoted 5 lines · On Tue, 27 May 2025 14:38:16 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 2 lines · On Tue, 27 May 2025 09:40:10 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
Quoted 7 lines
Quoted 5 lines
This commit adds DSDT blobs to the whilelist in the prospect to allow changes in the GPEX
_OSCmethod.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>Reviewed-by Igor Mammedov <[email protected]>
I take it back,
test with x86 enabled breaks on microvm,
so it's missing some DSTDs here
Quoted 17 lines
Quoted 16 lines
--- tests/qtest/bios-tables-test-allowed-diff.h | 5 +++++ 1 file changed, 5 insertions(+)tests/qtest/bios-tables-test-allowed-diff.h +5
-0@@ -1 +1,6 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/DSDT" , +"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , +"tests/data/acpi/aarch64/virt/DSDT.memhp" , +"tests/data/acpi/aarch64/virt/DSDT.pxb" , +"tests/data/acpi/aarch64/virt/DSDT.topology",
Re: [PATCH v2 08/25] tests/qtest/bios-tables-test: Prepare for changes in the DSDT table
Hi Igor and Eric,
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Tue, 27 May 2025 14:38:16 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 5 lines · On Tue, 27 May 2025 09:40:10 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
This commit adds DSDT blobs to the whilelist in the prospect to allow changes in the GPEX
_OSCmethod.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>Reviewed-by Igor Mammedov <[email protected]>I take it back,
test with x86 enabled breaks on microvm,
so it's missing some DSTDs here
It's fixed in the series I've just posted in 24/25 as we discuss it. Thanks.
Cheers,
Gustavo
Quoted 19 lines
Quoted 18 lines
Quoted 17 lines
--- tests/qtest/bios-tables-test-allowed-diff.h | 5 +++++ 1 file changed, 5 insertions(+)tests/qtest/bios-tables-test-allowed-diff.h +5
-0@@ -1 +1,6 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/DSDT" , +"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , +"tests/data/acpi/aarch64/virt/DSDT.memhp" , +"tests/data/acpi/aarch64/virt/DSDT.pxb" , +"tests/data/acpi/aarch64/virt/DSDT.topology",
Re: [PATCH v2 08/25] tests/qtest/bios-tables-test: Prepare for changes in the DSDT table
Hi Gustavo,
Quoted 17 lines · Gustavo Romero
Hi Igor and Eric,
Quoted 14 lines · Igor Mammedov
Quoted 11 lines · On Tue, 27 May 2025 14:38:16 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 7 lines · On Tue, 27 May 2025 09:40:10 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
This commit adds DSDT blobs to the whilelist in the prospect to allow changes in the GPEX
_OSCmethod.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Reviewed-by Igor Mammedov <[email protected]>I take it back,
test with x86 enabled breaks on microvm,
so it's missing some DSTDs hereIt's fixed in the series I've just posted in 24/25 as we discuss it. Thanks.
thanks! picked up your modification
Eric
Quoted 26 lines
Cheers,
GustavoQuoted 20 lines
Quoted 19 lines
Quoted 18 lines
---
tests/qtest/bios-tables-test-allowed-diff.h| 5 +++++1 file changed, 5 insertions(+)tests/qtest/bios-tables-test-allowed-diff.h +5
-0@@ -1 +1,6 @@ /* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/aarch64/virt/DSDT" , +"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , +"tests/data/acpi/aarch64/virt/DSDT.memhp" , +"tests/data/acpi/aarch64/virt/DSDT.pxb" , +"tests/data/acpi/aarch64/virt/DSDT.topology",
PATCH v2 9/25 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 disassembled DSDT difference is given below:
* 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
---
v1 -> v2:
- move in the dsdt.dsl diff in the commit message and remove useless info (Gustavi, Michael)
--- hw/pci-host/gpex-acpi.c | 60 +++-------------------------------------- 1 file changed, 4 insertions(+), 56 deletions(-)
hw/pci-host/gpex-acpi.c +4 -56
@@ -50,60 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static Aml *build_host_bridge_osc (bool enable_native_pcie_hotplug) -{ -Aml *method, *UUID , *ifctx, *ifctx1, *elsectx; - - method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" )); - -/* PCI Firmware Specification 3.0 -* 4.5.1. _OSC Interface for PCI Host Bridge Devices -* The _OSC interface for a PCI/PCI-X/PCI Express hierarchy is -* identified by the Universal Unique IDentifier (UUID) -* 33DB4D5B-1FF7-401C-9657-7441C03DD766 -*/ -UUID =aml_touuid ("33DB4D5B-1FF7-401C-9657-7441C03DD766" ); - ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); -aml_append (ifctx, -aml_create_dword_field (aml_arg (3 ),aml_int (4 ),"CDW2" )); -aml_append (ifctx, -aml_create_dword_field (aml_arg (3 ),aml_int (8 ),"CDW3" )); -aml_append (ifctx,aml_store (aml_name ("CDW2" ),aml_name ("SUPP" ))); -aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" ))); - -/* -* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, -* and PCIeHotplug depending on enable_native_pcie_hotplug -*/ -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 ), -aml_name ("CDW1" ))); -aml_append (ifctx, ifctx1); - - ifctx1 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ),aml_name ("CTRL" )))); -aml_append (ifctx1,aml_or (aml_name ("CDW1" ),aml_int (0x10 ), -aml_name ("CDW1" ))); -aml_append (ifctx, ifctx1); - -aml_append (ifctx,aml_store (aml_name ("CTRL" ),aml_name ("CDW3" ))); -aml_append (ifctx,aml_return (aml_arg (3 ))); -aml_append (method, ifctx); - - elsectx =aml_else (); -aml_append (elsectx,aml_or (aml_name ("CDW1" ),aml_int (4 ), -aml_name ("CDW1" ))); -aml_append (elsectx,aml_return (aml_arg (3 ))); -aml_append (method, elsectx); -return method; -} - -static Aml *build_host_bridge_dsm (void ) +static Aml *build_pci_host_bridge_dsm_method (void ) {Aml *method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED );Aml *UUID , *ifctx, *ifctx1, *buf;
@@ -134,8 +81,9 @@ static void acpi_dsdt_add_host_bridge_methods(Aml *dev,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 ()); +aml_append (dev, +build_pci_host_bridge_osc_method (enable_native_pcie_hotplug)); +aml_append (dev,build_pci_host_bridge_dsm_method ()); }void acpi_dsdt_add_gpex (Aml *scope,struct GPEXConfig *cfg)
Signature · 1 line
2.49.0
Re: [PATCH v2 09/25] hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
Quoted 56 lines · On Tue, 27 May 2025 09:40:11 +0200 Eric Auger <[email protected]> wrote:
gpex
build_host_bridge_osc()and x86 originatedbuild_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 removebuild_host_bridge_osc().The disassembled DSDT difference is given below:
* 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)(quoted diff) +6
-7@@ -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
Quoted 1 line
Signed-off-by Eric Auger <[email protected]>
Quoted 88 lines
---
v1 -> v2:
- move in the dsdt.dsl diff in the commit message and remove useless info (Gustavi, Michael)--- hw/pci-host/gpex-acpi.c | 60 +++-------------------------------------- 1 file changed, 4 insertions(+), 56 deletions(-)hw/pci-host/gpex-acpi.c +4
-56@@ -50,60 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static Aml *build_host_bridge_osc (bool enable_native_pcie_hotplug) -{ -Aml *method, *UUID , *ifctx, *ifctx1, *elsectx; - - method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" )); - -/* PCI Firmware Specification 3.0 -* 4.5.1. _OSC Interface for PCI Host Bridge Devices -* The _OSC interface for a PCI/PCI-X/PCI Express hierarchy is -* identified by the Universal Unique IDentifier (UUID) -* 33DB4D5B-1FF7-401C-9657-7441C03DD766 -*/ -UUID =aml_touuid ("33DB4D5B-1FF7-401C-9657-7441C03DD766" ); - ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); -aml_append (ifctx, -aml_create_dword_field (aml_arg (3 ),aml_int (4 ),"CDW2" )); -aml_append (ifctx, -aml_create_dword_field (aml_arg (3 ),aml_int (8 ),"CDW3" )); -aml_append (ifctx,aml_store (aml_name ("CDW2" ),aml_name ("SUPP" ))); -aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" ))); - -/* -* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, -* and PCIeHotplug depending on enable_native_pcie_hotplug -*/ -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 ), -aml_name ("CDW1" ))); -aml_append (ifctx, ifctx1); - - ifctx1 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ),aml_name ("CTRL" )))); -aml_append (ifctx1,aml_or (aml_name ("CDW1" ),aml_int (0x10 ), -aml_name ("CDW1" ))); -aml_append (ifctx, ifctx1); - -aml_append (ifctx,aml_store (aml_name ("CTRL" ),aml_name ("CDW3" ))); -aml_append (ifctx,aml_return (aml_arg (3 ))); -aml_append (method, ifctx); - - elsectx =aml_else (); -aml_append (elsectx,aml_or (aml_name ("CDW1" ),aml_int (4 ), -aml_name ("CDW1" ))); -aml_append (elsectx,aml_return (aml_arg (3 ))); -aml_append (method, elsectx); -return method; -} - -static Aml *build_host_bridge_dsm (void ) +static Aml *build_pci_host_bridge_dsm_method (void ) {Aml *method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED );Aml *UUID , *ifctx, *ifctx1, *buf;@@ -134,8 +81,9 @@ static void acpi_dsdt_add_host_bridge_methods(Aml *dev,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 ()); +aml_append (dev, +build_pci_host_bridge_osc_method (enable_native_pcie_hotplug)); +aml_append (dev,build_pci_host_bridge_dsm_method ()); }void acpi_dsdt_add_gpex (Aml *scope,struct GPEXConfig *cfg)
Re: [PATCH v2 09/25] hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
In reply to Eric AugerQuoted 134 lines · On Tue, 27 May 2025 09:40:11 +0200 Eric Auger <[email protected]> wrote:
gpex
build_host_bridge_osc()and x86 originatedbuild_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 removebuild_host_bridge_osc().The disassembled DSDT difference is given below:
* 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)(quoted diff) +6
-7@@ -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 MethodSigned-off-by Eric Auger <[email protected]>---
v1 -> v2:
- move in the dsdt.dsl diff in the commit message and remove useless info (Gustavi, Michael)--- hw/pci-host/gpex-acpi.c | 60 +++-------------------------------------- 1 file changed, 4 insertions(+), 56 deletions(-)hw/pci-host/gpex-acpi.c +1
-54@@ -50,60 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static Aml *build_host_bridge_osc (bool enable_native_pcie_hotplug) -{ -Aml *method, *UUID , *ifctx, *ifctx1, *elsectx; - - method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" )); - -/* PCI Firmware Specification 3.0 -* 4.5.1. _OSC Interface for PCI Host Bridge Devices -* The _OSC interface for a PCI/PCI-X/PCI Express hierarchy is -* identified by the Universal Unique IDentifier (UUID) -* 33DB4D5B-1FF7-401C-9657-7441C03DD766 -*/ -UUID =aml_touuid ("33DB4D5B-1FF7-401C-9657-7441C03DD766" ); - ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); -aml_append (ifctx, -aml_create_dword_field (aml_arg (3 ),aml_int (4 ),"CDW2" )); -aml_append (ifctx, -aml_create_dword_field (aml_arg (3 ),aml_int (8 ),"CDW3" )); -aml_append (ifctx,aml_store (aml_name ("CDW2" ),aml_name ("SUPP" ))); -aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" ))); - -/* -* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, -* and PCIeHotplug depending on enable_native_pcie_hotplug -*/ -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 ), -aml_name ("CDW1" ))); -aml_append (ifctx, ifctx1); - - ifctx1 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ),aml_name ("CTRL" )))); -aml_append (ifctx1,aml_or (aml_name ("CDW1" ),aml_int (0x10 ), -aml_name ("CDW1" ))); -aml_append (ifctx, ifctx1); - -aml_append (ifctx,aml_store (aml_name ("CTRL" ),aml_name ("CDW3" ))); -aml_append (ifctx,aml_return (aml_arg (3 ))); -aml_append (method, ifctx); - - elsectx =aml_else (); -aml_append (elsectx,aml_or (aml_name ("CDW1" ),aml_int (4 ), -aml_name ("CDW1" ))); -aml_append (elsectx,aml_return (aml_arg (3 ))); -aml_append (method, elsectx); -return method; -} - -static Aml *build_host_bridge_dsm (void ) +static Aml *build_pci_host_bridge_dsm_method (void ) {Aml *method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED );Aml *UUID , *ifctx, *ifctx1, *buf;
hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_host_bridge_methods(Aml *dev, · line 82
Quoted 2 lines
hw/pci-host/gpex-acpi.c +0
-0@@ -134,8 +81,9 @@ static void acpi_dsdt_add_host_bridge_methods(Aml *dev,aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 )));aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 )));
This is where they become unused I think...
Quoted 9 lines
hw/pci-host/gpex-acpi.c +3
-2/* 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 ()); +aml_append (dev, +build_pci_host_bridge_osc_method (enable_native_pcie_hotplug)); +aml_append (dev,build_pci_host_bridge_dsm_method ()); }void acpi_dsdt_add_gpex (Aml *scope,struct GPEXConfig *cfg)
Re: [PATCH v2 09/25] hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
Quoted 132 lines · Jonathan Cameron
Quoted 129 lines · On Tue, 27 May 2025 09:40:11 +0200 Eric Auger <[email protected]> wrote:
gpex
build_host_bridge_osc()and x86 originatedbuild_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 removebuild_host_bridge_osc().The disassembled DSDT difference is given below:
* 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)(quoted diff) +6
-7@@ -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 MethodSigned-off-by Eric Auger <[email protected]>---
v1 -> v2:
- move in the dsdt.dsl diff in the commit message and remove useless info (Gustavi, Michael)--- hw/pci-host/gpex-acpi.c | 60 +++-------------------------------------- 1 file changed, 4 insertions(+), 56 deletions(-)hw/pci-host/gpex-acpi.c +0
-54@@ -50,60 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq, } } -static Aml *build_host_bridge_osc (bool enable_native_pcie_hotplug) -{ -Aml *method, *UUID , *ifctx, *ifctx1, *elsectx; - - method =aml_method ("_OSC" ,4 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_create_dword_field (aml_arg (3 ),aml_int (0 ),"CDW1" )); - -/* PCI Firmware Specification 3.0 -* 4.5.1. _OSC Interface for PCI Host Bridge Devices -* The _OSC interface for a PCI/PCI-X/PCI Express hierarchy is -* identified by the Universal Unique IDentifier (UUID) -* 33DB4D5B-1FF7-401C-9657-7441C03DD766 -*/ -UUID =aml_touuid ("33DB4D5B-1FF7-401C-9657-7441C03DD766" ); - ifctx =aml_if (aml_equal (aml_arg (0 ),UUID )); -aml_append (ifctx, -aml_create_dword_field (aml_arg (3 ),aml_int (4 ),"CDW2" )); -aml_append (ifctx, -aml_create_dword_field (aml_arg (3 ),aml_int (8 ),"CDW3" )); -aml_append (ifctx,aml_store (aml_name ("CDW2" ),aml_name ("SUPP" ))); -aml_append (ifctx,aml_store (aml_name ("CDW3" ),aml_name ("CTRL" ))); - -/* -* Allow OS control for SHPCHotplug, PME, AER, PCIeCapability, -* and PCIeHotplug depending on enable_native_pcie_hotplug -*/ -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 ), -aml_name ("CDW1" ))); -aml_append (ifctx, ifctx1); - - ifctx1 =aml_if (aml_lnot (aml_equal (aml_name ("CDW3" ),aml_name ("CTRL" )))); -aml_append (ifctx1,aml_or (aml_name ("CDW1" ),aml_int (0x10 ), -aml_name ("CDW1" ))); -aml_append (ifctx, ifctx1); - -aml_append (ifctx,aml_store (aml_name ("CTRL" ),aml_name ("CDW3" ))); -aml_append (ifctx,aml_return (aml_arg (3 ))); -aml_append (method, ifctx); - - elsectx =aml_else (); -aml_append (elsectx,aml_or (aml_name ("CDW1" ),aml_int (4 ), -aml_name ("CDW1" ))); -aml_append (elsectx,aml_return (aml_arg (3 ))); -aml_append (method, elsectx); -return method; -} - -static Aml *build_host_bridge_dsm (void )
Quoted 8 lines
hw/pci-host/gpex-acpi.c static void acpi_dsdt_add_host_bridge_methods(Aml *dev, · line 82
Quoted 7 lines
hw/pci-host/gpex-acpi.c +1
-0+static Aml *build_pci_host_bridge_dsm_method (void ) {Aml *method =aml_method ("_DSM" ,4 ,AML_NOTSERIALIZED );Aml *UUID , *ifctx, *ifctx1, *buf;@@ -134,8 +81,9 @@ static void acpi_dsdt_add_host_bridge_methods(Aml *dev,aml_append (dev,aml_name_decl ("SUPP" ,aml_int (0 )));aml_append (dev,aml_name_decl ("CTRL" ,aml_int (0 )));This is where they become unused I think...
Indeed.
This means that I need to regenerate the reference blobs accordingly (for Gustavo's awarness).
Eric
Quoted 10 lines
Quoted 10 lines
hw/pci-host/gpex-acpi.c +3
-2/* 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 ()); +aml_append (dev, +build_pci_host_bridge_osc_method (enable_native_pcie_hotplug)); +aml_append (dev,build_pci_host_bridge_dsm_method ()); }void acpi_dsdt_add_gpex (Aml *scope,struct GPEXConfig *cfg)
PATCH v2 10/25 tests/qtest/bios-tables-test: Update DSDT blobs after GPEX _OSC change
In reply to Eric AugerFrom: Gustavo Romero <[email protected]>
Update the reference DSDT blobs after GPEX _OSC change.
DSDT diff can be found below.
*
* 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
--- tests/qtest/bios-tables-test-allowed-diff.h | 5 ----- tests/data/acpi/aarch64/virt/DSDT | Bin 5196 -> 5170 bytes .../data/acpi/aarch64/virt/DSDT.acpihmatvirt | Bin 5282 -> 5256 bytes tests/data/acpi/aarch64/virt/DSDT.memhp | Bin 6557 -> 6531 bytes tests/data/acpi/aarch64/virt/DSDT.pxb | Bin 7679 -> 7627 bytes tests/data/acpi/aarch64/virt/DSDT.topology | Bin 5398 -> 5372 bytes 6 files changed, 5 deletions(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -5
@@ -1,6 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/aarch64/virt/DSDT" , -"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , -"tests/data/acpi/aarch64/virt/DSDT.memhp" , -"tests/data/acpi/aarch64/virt/DSDT.pxb" , -"tests/data/acpi/aarch64/virt/DSDT.topology",
tests/data/acpi/aarch64/virt/DSDT binary +0 -0
tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt binary +0 -0
tests/data/acpi/aarch64/virt/DSDT.memhp binary +0 -0
tests/data/acpi/aarch64/virt/DSDT.pxb binary +0 -0
tests/data/acpi/aarch64/virt/DSDT.topology binary +0 -0
Signature · 1 line
2.49.0
Re: [PATCH v2 10/25] tests/qtest/bios-tables-test: Update DSDT blobs after GPEX _OSC change
Quoted 5 lines · On Tue, 27 May 2025 09:40:12 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
Update the reference DSDT blobs after GPEX
_OSCchange.DSDT diff can be found below.
this needs to be updated to take into account microvm
Quoted 139 lines
*
* 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)(quoted diff) +6
-7@@ -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 MethodSigned-off-by Eric Auger <[email protected]>Signed-off-by Gustavo Romero <[email protected]>--- tests/qtest/bios-tables-test-allowed-diff.h | 5 ----- tests/data/acpi/aarch64/virt/DSDT | Bin 5196 -> 5170 bytes .../data/acpi/aarch64/virt/DSDT.acpihmatvirt | Bin 5282 -> 5256 bytes tests/data/acpi/aarch64/virt/DSDT.memhp | Bin 6557 -> 6531 bytes tests/data/acpi/aarch64/virt/DSDT.pxb | Bin 7679 -> 7627 bytes tests/data/acpi/aarch64/virt/DSDT.topology | Bin 5398 -> 5372 bytes 6 files changed, 5 deletions(-)tests/qtest/bios-tables-test-allowed-diff.h +0
-5@@ -1,6 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/aarch64/virt/DSDT" , -"tests/data/acpi/aarch64/virt/DSDT.acpihmatvirt" , -"tests/data/acpi/aarch64/virt/DSDT.memhp" , -"tests/data/acpi/aarch64/virt/DSDT.pxb" , -"tests/data/acpi/aarch64/virt/DSDT.topology",tests/data/acpi/aarch64/virt/DSDT binary +0
-0z__0pjEu>{)oKT&>C7-ZBVAAAF##)dJ7YA5gc+zBNmvG|*h?oFKtRMj-vXE!9v9Kf~ E0NvLgQ~&?~
delta 139 zcmdm_aYlp7CD<jzM}&caNqQoeG*i3NMs+tXCWon;^SP
!1l>5}{ezuZy0RIZUBV3) zc(702EugV6dW25P~hwmZtNTq<WmhIxa2|P0)a`BGZ||^YPmSTI>aVThN*)H3xI?R SK#D=)OR^X8ZI%?4WCQ?(sV7tbtests/data/acpi/aarch64/virt/DSDT.acpihmatvirt binary +0
-0E06pL!c>n+a
delta 139 zcmeCsT%^h666_MPNQ8lb>BdAZX{KKHjp}o_m>i~VKFVdyA?U^#?;q^U(v{8N>=JIc zz=M6Vps<#oQE+HLK!LMMxUq9ckWV#;;F1TC3j
)j&Sb0wspaAT>kykX8Kw>*EC3QN S04WBEFUelWw>e)}kVy<UnqG1tests/data/acpi/aarch64/virt/DSDT.memhp binary +0
-0z__0pjEu>{)oKT&>C7-ZBVAAAF##)dJ7YA5gc+zBNmvG|*h?oFKtRMj-vXE!9v2Yd} E01f0IF8}}l
delta 139 zcmZoRo@>nI66_K(SCWB&$z~##G*id)jp}Y(Ob$~w=W|(e2)c2``v*I-bY(L*yM!Aq z@L-?3TS&{#C^$4ApupKB+}JrJ$fp`aaLI$n1p<>MXEN4;)N*lvb%;%x3{wXY761ts SfE0tomt-&G+bk)Z#RdSwDJU-h
tests/data/acpi/aarch64/virt/DSDT.pxb binary +0
-0zz>jruo{W}>aYA(hmwdtkfk~4y8EZi@TpVC|;YpL7UBZnMAYuX_v4RAU$U>gU&tz;j Ze-hGTWOAFlSxLm2gNkNvekLQy2mmfWJ;DG0
delta 256 zcmX?Y{ok6)CD<k8zbpd-Q^!OuX{N5b8
a&on4CK{=X3347j)x{_YZbv>B?qsb_q9J z;K4rGR!GawC^$4ApupKB+}JrJ$fpaaLI$n1p<>MXEN4;)N*lvb%;%x3{wXY761ts lfE0tomt-&G+dNw+n~}+3>ShiRYYw{DIC-{^?d10|cL0k$O`-q*tests/data/acpi/aarch64/virt/DSDT.topology binary +0
-0SAjKf@CD{x4Ha
}YWCQ>=S0Km
PATCH v2 11/25 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
@@ -75,6 +75,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr);void build_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar); +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
@@ -1432,19 +1432,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
Re: [PATCH v2 11/25] hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
Quoted 6 lines · On Tue, 27 May 2025 09:40:13 +0200 Eric Auger <[email protected]> wrote:
Extract the code that reserves resources for ACPI PCI hotplug into a new helper named
build_append_pcihp_resources()and move it topcihp.c. We will reuse it on ARM.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Quoted 76 lines
--- 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@@ -75,6 +75,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr);void build_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar); +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@@ -1432,19 +1432,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);
Re: [PATCH v2 11/25] hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
In reply to Eric AugerQuoted 6 lines · On Tue, 27 May 2025 09:40:13 +0200 Eric Auger <[email protected]> wrote:
Extract the code that reserves resources for ACPI PCI hotplug into a new helper named
build_append_pcihp_resources()and move it topcihp.c. We will reuse it on ARM.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Trivial comment inline.
Quoted 33 lines
--- 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@@ -75,6 +75,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr);void build_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar); +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 +6
-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; +
hw/acpi/pcihp.c void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr) · line 703
Quoted 10 lines
hw/acpi/pcihp.c +10
-0+ 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) + );
Trivial but this doesn't match local style. It is even inconsistent with the _UID line above.
hw/acpi/pcihp.c void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr) · line 705
Quoted 2 lines
hw/acpi/pcihp.c +2
-0+aml_append (crs, +aml_io (AML_DECODE16 , io_addr, io_addr,1 , io_len));
maybe?
Quoted 33 lines
hw/acpi/pcihp.c +4
-0+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@@ -1432,19 +1432,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);
Re: [PATCH v2 11/25] hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
Hi Jonathan,
Quoted 58 lines · Jonathan Cameron
Quoted 6 lines · On Tue, 27 May 2025 09:40:13 +0200 Eric Auger <[email protected]> wrote:
Extract the code that reserves resources for ACPI PCI hotplug into a new helper named
build_append_pcihp_resources()and move it topcihp.c. We will reuse it on ARM.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>Trivial comment inline.
Reviewed-by Jonathan Cameron <[email protected]>Quoted 33 lines
--- 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@@ -75,6 +75,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,void build_acpi_pci_hotplug (Aml *table,uint64_t pcihp_addr);void build_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar); +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 +6
-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; +hw/acpi/pcihp.c void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr) · line 703
Quoted 10 lines
hw/acpi/pcihp.c +10
-0+ 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) + );Trivial but this doesn't match local style. It is even inconsistent with the
_UIDline above.
Quoted 3 lines
hw/acpi/pcihp.c void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr) · line 705
Quoted 2 lines
hw/acpi/pcihp.c +2
-0+aml_append (crs, +aml_io (AML_DECODE16 , io_addr, io_addr,1 , io_len));maybe?
definivitely. Will be fixed in next version
Thanks!
Eric
Quoted 34 lines
Quoted 34 lines
hw/acpi/pcihp.c +4
-0+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@@ -1432,19 +1432,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);
PATCH v2 12/25 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_pci_dsm_func0_common (Aml *ctx,Aml *retvar);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
@@ -1172,7 +1172,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) {
@@ -1216,7 +1216,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
Re: [PATCH v2 12/25] hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
Quoted 5 lines · On Tue, 27 May 2025 09:40:14 +0200 Eric Auger <[email protected]> wrote:
On ARM we will put the operation regions in
AML_SYSTEM_MEMORY. So let's allow this configuration.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Quoted 87 lines
--- 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_pci_dsm_func0_common (Aml *ctx,Aml *retvar);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@@ -1172,7 +1172,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) {@@ -1216,7 +1216,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); }
Re: [PATCH v2 12/25] hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
In reply to Eric AugerQuoted 5 lines · On Tue, 27 May 2025 09:40:14 +0200 Eric Auger <[email protected]> wrote:
On ARM we will put the operation regions in
AML_SYSTEM_MEMORY. So let's allow this configuration.Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
PATCH v2 13/25 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
@@ -78,6 +78,7 @@ void build_acpi_pci_hotplug(Aml *table, AmlRegionSpace rs, uint64_t pcihp_addr);void build_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar);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
Re: [PATCH v2 13/25] hw/i386/acpi-build: Move build_append_notification_callback to pcihp
Quoted 7 lines · On Tue, 27 May 2025 09:40:15 +0200 Eric Auger <[email protected]> wrote:
We plan to reuse
build_append_notification_callback()on ARM so let's move it topcihp.c.No functional change intended.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Quoted 163 lines
--- 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@@ -78,6 +78,7 @@ void build_acpi_pci_hotplug(Aml *table, AmlRegionSpace rs, uint64_t pcihp_addr);void build_append_pci_dsm_func0_common (Aml *ctx,Aml *retvar);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@@ -39,6 +39,7 @@#include "migration/vmstate.h" #include "qapi/error.h" #include "qom/qom-qobject.h" +#include "qobject/qnum.h" #include "trace.h" #define ACPI_PCIHP_SIZE 0x0018@@ -705,6 +706,63 @@ void build_append_pcihp_resources(Aml *scope /* \\_SB.PCI0 */,aml_append (scope, dev); } +bool build_append_notification_callback (Aml *parent_scope,const PCIBus *bus) +{ +Aml *method; +PCIBus *sec; +QObject *bsel; +int nr_notifiers =0 ; +GQueue *pcnt_bus_list =g_queue_new (); + + QLIST_FOREACH(sec, &bus->child, sibling) { +Aml *br_scope =aml_scope ("S%.02X" , sec->parent_dev->devfn); +if (pci_bus_is_root (sec)) { +continue ; + } + nr_notifiers = nr_notifiers + +build_append_notification_callback (br_scope, sec); +/* +* add new child scope to parent +* and keep track of bus that have PCNT, +* bus list is used later to call children PCNTs from this level PCNT +*/ +if (nr_notifiers) { +g_queue_push_tail (pcnt_bus_list, sec); +aml_append (parent_scope, br_scope); + } + } + +/* +* Append PCNT method to notify about events on local and child buses. +* ps: hostbridge might not have hotplug (bsel) enabled but might have +* child bridges that do have bsel. +*/ + method =aml_method ("PCNT" ,0 ,AML_NOTSERIALIZED ); + +/* If bus supports hotplug select it and notify about local events */ + bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL ); +if (bsel) { +uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); + +aml_append (method,aml_store (aml_int (bsel_val),aml_name ("BNUM" ))); +aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCIU" ), +aml_int (1 )));/* Device Check */ +aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCID" ), +aml_int (3 )));/* Eject Request */ + nr_notifiers++; + } + +/* Notify about child bus events in any case */ +while ((sec =g_queue_pop_head (pcnt_bus_list))) { +aml_append (method,aml_name ("^S%.02X.PCNT" , sec->parent_dev->devfn)); + } + +aml_append (parent_scope, method); +qobject_unref (bsel); +g_queue_free (pcnt_bus_list); +return !!nr_notifiers; +} +const VMStateDescription vmstate_acpi_pcihp_pci_status = { .name ="acpi_pcihp_pci_status" , .version_id =1 ,hw/i386/acpi-build.c +0
-58@@ -563,64 +563,6 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus) } } -static bool build_append_notification_callback (Aml *parent_scope, -const PCIBus *bus) -{ -Aml *method; -PCIBus *sec; -QObject *bsel; -int nr_notifiers =0 ; -GQueue *pcnt_bus_list =g_queue_new (); - - QLIST_FOREACH(sec, &bus->child, sibling) { -Aml *br_scope =aml_scope ("S%.02X" , sec->parent_dev->devfn); -if (pci_bus_is_root (sec)) { -continue ; - } - nr_notifiers = nr_notifiers + -build_append_notification_callback (br_scope, sec); -/* -* add new child scope to parent -* and keep track of bus that have PCNT, -* bus list is used later to call children PCNTs from this level PCNT -*/ -if (nr_notifiers) { -g_queue_push_tail (pcnt_bus_list, sec); -aml_append (parent_scope, br_scope); - } - } - -/* -* Append PCNT method to notify about events on local and child buses. -* ps: hostbridge might not have hotplug (bsel) enabled but might have -* child bridges that do have bsel. -*/ - method =aml_method ("PCNT" ,0 ,AML_NOTSERIALIZED ); - -/* If bus supports hotplug select it and notify about local events */ - bsel =object_property_get_qobject (OBJECT (bus),ACPI_PCIHP_PROP_BSEL ,NULL ); -if (bsel) { -uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); - -aml_append (method,aml_store (aml_int (bsel_val),aml_name ("BNUM" ))); -aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCIU" ), -aml_int (1 )));/* Device Check */ -aml_append (method,aml_call2 ("DVNT" ,aml_name ("PCID" ), -aml_int (3 )));/* Eject Request */ - nr_notifiers++; - } - -/* Notify about child bus events in any case */ -while ((sec =g_queue_pop_head (pcnt_bus_list))) { -aml_append (method,aml_name ("^S%.02X.PCNT" , sec->parent_dev->devfn)); - } - -aml_append (parent_scope, method); -qobject_unref (bsel); -g_queue_free (pcnt_bus_list); -return !!nr_notifiers; -} -/* * build_prt - Define interrupt routing rules *
Re: [PATCH v2 13/25] hw/i386/acpi-build: Move build_append_notification_callback to pcihp
In reply to Eric AugerQuoted 7 lines · On Tue, 27 May 2025 09:40:15 +0200 Eric Auger <[email protected]> wrote:
We plan to reuse
build_append_notification_callback()on ARM so let's move it topcihp.c.No functional change intended.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
FWIW given it's just a move.
PATCH v2 14/25 hw/i386/acpi-build: Move build_append_pci_bus_devices/pcihp_slots 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 all 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
@@ -80,6 +80,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
Re: [PATCH v2 14/25] hw/i386/acpi-build: Move build_append_pci_bus_devices/pcihp_slots to pcihp
Quoted 9 lines · On Tue, 27 May 2025 09:40:16 +0200 Eric Auger <[email protected]> wrote:
We intend to reuse
build_append_pci_bus_devicesandbuild_append_pcihp_slotson ARM. So let's move them tohw/acpi/pcihp.cas well as all static helpers they use.No functional change intended.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>
Quoted 413 lines
--- 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@@ -80,6 +80,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@@ -27,6 +27,7 @@#include "qemu/osdep.h" #include "hw/acpi/pcihp.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi_aml_interface.h" #include "hw/pci-host/i440fx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" @@ -763,6 +764,178 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)return !!nr_notifiers; } +static void build_append_pcihp_notify_entry (Aml *method,int slot) +{ +Aml *if_ctx; +int32_t devfn =PCI_DEVFN (slot,0 ); + + if_ctx =aml_if (aml_and (aml_arg (0 ),aml_int (0x1U << slot),NULL )); +aml_append (if_ctx,aml_notify (aml_name ("S%.02X" , devfn),aml_arg (1 ))); +aml_append (method, if_ctx); +} + +static bool is_devfn_ignored_generic (const int devfn,const PCIBus *bus) +{ +const PCIDevice *pdev = bus->devices[devfn]; + +if (PCI_FUNC (devfn)) { +if (IS_PCI_BRIDGE (pdev)) { +/* +* Ignore only hotplugged PCI bridges on !0 functions, but +* allow describing cold plugged bridges on all functions +*/ +if (DEVICE (pdev)->hotplugged) { +return true; + } + } + } +return false; +} + +static bool is_devfn_ignored_hotplug (const int devfn,const PCIBus *bus) +{ +PCIDevice *pdev = bus->devices[devfn]; +if (pdev) { +return is_devfn_ignored_generic (devfn, bus) || + !DEVICE_GET_CLASS (pdev)->hotpluggable || +/* Cold plugged bridges aren't themselves hot-pluggable */ + (IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged); + }else {/* non populated slots */ +/* +* hotplug is supported only for non-multifunction device +* so generate device description only for function 0 +*/ +if (PCI_FUNC (devfn) || + (pci_bus_is_express (bus) &&PCI_SLOT (devfn) >0 )) { +return true; + } + } +return false; +} + +static Aml *aml_pci_static_endpoint_dsm (PCIDevice *pdev) +{ +Aml *method; + +g_assert (pdev->acpi_index !=0 ); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (1 ); +aml_append (pkg,aml_int (pdev->acpi_index)); +aml_append (method,aml_store (pkg, params)); +aml_append (method, +aml_return (aml_call5 ("EDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), params)) + ); + } +return method; +} + +static Aml *aml_pci_device_dsm (void ) +{ +Aml *method; + + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (2 ); +aml_append (pkg,aml_int (0 )); +aml_append (pkg,aml_int (0 )); +aml_append (method,aml_store (pkg, params)); +aml_append (method, +aml_store (aml_name ("BSEL" ),aml_index (params,aml_int (0 )))); +aml_append (method, +aml_store (aml_name ("ASUN" ),aml_index (params,aml_int (1 )))); +aml_append (method, +aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), params)) + ); + } +return method; +} + +void build_append_pcihp_slots (Aml *parent_scope,PCIBus *bus) +{ +int devfn; +Aml *dev, *notify_method =NULL , *method; +QObject *bsel =object_property_get_qobject (OBJECT (bus), +ACPI_PCIHP_PROP_BSEL ,NULL ); +uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); +qobject_unref (bsel); + +aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); + notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED ); + +for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { +int slot =PCI_SLOT (devfn); +int adr = slot <<16 |PCI_FUNC (devfn); + +if (is_devfn_ignored_hotplug (devfn, bus)) { +continue ; + } + +if (bus->devices[devfn]) { + dev =aml_scope ("S%.02X" , devfn); + }else { + dev =aml_device ("S%.02X" , devfn); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); + } + +/* +* Can't declare _SUN here for every device as it changes 'slot' +* enumeration order in linux kernel, so use another variable for it +*/ +aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); +aml_append (dev,aml_pci_device_dsm ()); + +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); +/* add _EJ0 to make slot hotpluggable */ + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) + ); +aml_append (dev, method); + +build_append_pcihp_notify_entry (notify_method, slot); + +/* device descriptor has been composed, add it into parent context */ +aml_append (parent_scope, dev); + } +aml_append (parent_scope, notify_method); +} + +void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) +{ +int devfn; +Aml *dev; + +for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { +/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ +int adr =PCI_SLOT (devfn) <<16 |PCI_FUNC (devfn); +PCIDevice *pdev = bus->devices[devfn]; + +if (!pdev ||is_devfn_ignored_generic (devfn, bus)) { +continue ; + } + +/* start to compose PCI device descriptor */ + dev =aml_device ("S%.02X" , devfn); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); + +call_dev_aml_func (DEVICE (bus->devices[devfn]), dev); +/* add _DSM if device has acpi-index set */ +if (pdev->acpi_index && + !object_property_get_bool (OBJECT (pdev),"hotpluggable" , + &error_abort)) { +aml_append (dev,aml_pci_static_endpoint_dsm (pdev)); + } + +/* device descriptor has been composed, add it into parent context */ +aml_append (parent_scope, dev); + } +} +const VMStateDescription vmstate_acpi_pcihp_pci_status = { .name ="acpi_pcihp_pci_status" , .version_id =1 ,hw/i386/acpi-build.c +0
-172@@ -338,29 +338,6 @@ build_facs(GArray *table_data)g_array_append_vals (table_data, reserved,40 );/* Reserved */ } -static Aml *aml_pci_device_dsm (void ) -{ -Aml *method; - - method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); - { -Aml *params =aml_local (0 ); -Aml *pkg =aml_package (2 ); -aml_append (pkg,aml_int (0 )); -aml_append (pkg,aml_int (0 )); -aml_append (method,aml_store (pkg, params)); -aml_append (method, -aml_store (aml_name ("BSEL" ),aml_index (params,aml_int (0 )))); -aml_append (method, -aml_store (aml_name ("ASUN" ),aml_index (params,aml_int (1 )))); -aml_append (method, -aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), -aml_arg (2 ),aml_arg (3 ), params)) - ); - } -return method; -} -static Aml *aml_pci_edsm (void ) {Aml *method, *ifctx;@@ -414,155 +391,6 @@ static Aml *aml_pci_edsm(void)return method; } -static Aml *aml_pci_static_endpoint_dsm (PCIDevice *pdev) -{ -Aml *method; - -g_assert (pdev->acpi_index !=0 ); - method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); - { -Aml *params =aml_local (0 ); -Aml *pkg =aml_package (1 ); -aml_append (pkg,aml_int (pdev->acpi_index)); -aml_append (method,aml_store (pkg, params)); -aml_append (method, -aml_return (aml_call5 ("EDSM" ,aml_arg (0 ),aml_arg (1 ), -aml_arg (2 ),aml_arg (3 ), params)) - ); - } -return method; -} - -static void build_append_pcihp_notify_entry (Aml *method,int slot) -{ -Aml *if_ctx; -int32_t devfn =PCI_DEVFN (slot,0 ); - - if_ctx =aml_if (aml_and (aml_arg (0 ),aml_int (0x1U << slot),NULL )); -aml_append (if_ctx,aml_notify (aml_name ("S%.02X" , devfn),aml_arg (1 ))); -aml_append (method, if_ctx); -} - -static bool is_devfn_ignored_generic (const int devfn,const PCIBus *bus) -{ -const PCIDevice *pdev = bus->devices[devfn]; - -if (PCI_FUNC (devfn)) { -if (IS_PCI_BRIDGE (pdev)) { -/* -* Ignore only hotplugged PCI bridges on !0 functions, but -* allow describing cold plugged bridges on all functions -*/ -if (DEVICE (pdev)->hotplugged) { -return true; - } - } - } -return false; -} - -static bool is_devfn_ignored_hotplug (const int devfn,const PCIBus *bus) -{ -PCIDevice *pdev = bus->devices[devfn]; -if (pdev) { -return is_devfn_ignored_generic (devfn, bus) || - !DEVICE_GET_CLASS (pdev)->hotpluggable || -/* Cold plugged bridges aren't themselves hot-pluggable */ - (IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged); - }else {/* non populated slots */ -/* -* hotplug is supported only for non-multifunction device -* so generate device description only for function 0 -*/ -if (PCI_FUNC (devfn) || - (pci_bus_is_express (bus) &&PCI_SLOT (devfn) >0 )) { -return true; - } - } -return false; -} - -void build_append_pcihp_slots (Aml *parent_scope,PCIBus *bus) -{ -int devfn; -Aml *dev, *notify_method =NULL , *method; -QObject *bsel =object_property_get_qobject (OBJECT (bus), -ACPI_PCIHP_PROP_BSEL ,NULL ); -uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); -qobject_unref (bsel); - -aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); - notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED ); - -for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { -int slot =PCI_SLOT (devfn); -int adr = slot <<16 |PCI_FUNC (devfn); - -if (is_devfn_ignored_hotplug (devfn, bus)) { -continue ; - } - -if (bus->devices[devfn]) { - dev =aml_scope ("S%.02X" , devfn); - }else { - dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); - } - -/* -* Can't declare _SUN here for every device as it changes 'slot' -* enumeration order in linux kernel, so use another variable for it -*/ -aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); -aml_append (dev,aml_pci_device_dsm ()); - -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); -/* add _EJ0 to make slot hotpluggable */ - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) - ); -aml_append (dev, method); - -build_append_pcihp_notify_entry (notify_method, slot); - -/* device descriptor has been composed, add it into parent context */ -aml_append (parent_scope, dev); - } -aml_append (parent_scope, notify_method); -} - -void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) -{ -int devfn; -Aml *dev; - -for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { -/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ -int adr =PCI_SLOT (devfn) <<16 |PCI_FUNC (devfn); -PCIDevice *pdev = bus->devices[devfn]; - -if (!pdev ||is_devfn_ignored_generic (devfn, bus)) { -continue ; - } - -/* start to compose PCI device descriptor */ - dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); - -call_dev_aml_func (DEVICE (bus->devices[devfn]), dev); -/* add _DSM if device has acpi-index set */ -if (pdev->acpi_index && - !object_property_get_bool (OBJECT (pdev),"hotpluggable" , - &error_abort)) { -aml_append (dev,aml_pci_static_endpoint_dsm (pdev)); - } - -/* device descriptor has been composed, add it into parent context */ -aml_append (parent_scope, dev); - } -} -/* * build_prt - Define interrupt routing rules *
Re: [PATCH v2 14/25] hw/i386/acpi-build: Move build_append_pci_bus_devices/pcihp_slots to pcihp
In reply to Eric AugerQuoted 4 lines · On Tue, 27 May 2025 09:40:16 +0200 Eric Auger <[email protected]> wrote:
We intend to reuse
build_append_pci_bus_devicesandbuild_append_pcihp_slotson ARM. So let's move them tohw/acpi/pcihp.cas well as all static helpers they use.
Oddly short wrap. I guess it kind of looks prettier than ...
We 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 all static helpers they use.
... so I'm not that fussed.
I don't really mind, but maybe a short statement of why you put the functions in a different order in the destination would be a good thing to add to this description?
Either way
Quoted 418 lines
No functional change intended.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>--- 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@@ -80,6 +80,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@@ -27,6 +27,7 @@#include "qemu/osdep.h" #include "hw/acpi/pcihp.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi_aml_interface.h" #include "hw/pci-host/i440fx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" @@ -763,6 +764,178 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)return !!nr_notifiers; } +static void build_append_pcihp_notify_entry (Aml *method,int slot) +{ +Aml *if_ctx; +int32_t devfn =PCI_DEVFN (slot,0 ); + + if_ctx =aml_if (aml_and (aml_arg (0 ),aml_int (0x1U << slot),NULL )); +aml_append (if_ctx,aml_notify (aml_name ("S%.02X" , devfn),aml_arg (1 ))); +aml_append (method, if_ctx); +} + +static bool is_devfn_ignored_generic (const int devfn,const PCIBus *bus) +{ +const PCIDevice *pdev = bus->devices[devfn]; + +if (PCI_FUNC (devfn)) { +if (IS_PCI_BRIDGE (pdev)) { +/* +* Ignore only hotplugged PCI bridges on !0 functions, but +* allow describing cold plugged bridges on all functions +*/ +if (DEVICE (pdev)->hotplugged) { +return true; + } + } + } +return false; +} + +static bool is_devfn_ignored_hotplug (const int devfn,const PCIBus *bus) +{ +PCIDevice *pdev = bus->devices[devfn]; +if (pdev) { +return is_devfn_ignored_generic (devfn, bus) || + !DEVICE_GET_CLASS (pdev)->hotpluggable || +/* Cold plugged bridges aren't themselves hot-pluggable */ + (IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged); + }else {/* non populated slots */ +/* +* hotplug is supported only for non-multifunction device +* so generate device description only for function 0 +*/ +if (PCI_FUNC (devfn) || + (pci_bus_is_express (bus) &&PCI_SLOT (devfn) >0 )) { +return true; + } + } +return false; +} + +static Aml *aml_pci_static_endpoint_dsm (PCIDevice *pdev) +{ +Aml *method; + +g_assert (pdev->acpi_index !=0 ); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (1 ); +aml_append (pkg,aml_int (pdev->acpi_index)); +aml_append (method,aml_store (pkg, params)); +aml_append (method, +aml_return (aml_call5 ("EDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), params)) + ); + } +return method; +} + +static Aml *aml_pci_device_dsm (void ) +{ +Aml *method; + + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (2 ); +aml_append (pkg,aml_int (0 )); +aml_append (pkg,aml_int (0 )); +aml_append (method,aml_store (pkg, params)); +aml_append (method, +aml_store (aml_name ("BSEL" ),aml_index (params,aml_int (0 )))); +aml_append (method, +aml_store (aml_name ("ASUN" ),aml_index (params,aml_int (1 )))); +aml_append (method, +aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), params)) + ); + } +return method; +} + +void build_append_pcihp_slots (Aml *parent_scope,PCIBus *bus) +{ +int devfn; +Aml *dev, *notify_method =NULL , *method; +QObject *bsel =object_property_get_qobject (OBJECT (bus), +ACPI_PCIHP_PROP_BSEL ,NULL ); +uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); +qobject_unref (bsel); + +aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); + notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED ); + +for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { +int slot =PCI_SLOT (devfn); +int adr = slot <<16 |PCI_FUNC (devfn); + +if (is_devfn_ignored_hotplug (devfn, bus)) { +continue ; + } + +if (bus->devices[devfn]) { + dev =aml_scope ("S%.02X" , devfn); + }else { + dev =aml_device ("S%.02X" , devfn); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); + } + +/* +* Can't declare _SUN here for every device as it changes 'slot' +* enumeration order in linux kernel, so use another variable for it +*/ +aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); +aml_append (dev,aml_pci_device_dsm ()); + +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); +/* add _EJ0 to make slot hotpluggable */ + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) + ); +aml_append (dev, method); + +build_append_pcihp_notify_entry (notify_method, slot); + +/* device descriptor has been composed, add it into parent context */ +aml_append (parent_scope, dev); + } +aml_append (parent_scope, notify_method); +} + +void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) +{ +int devfn; +Aml *dev; + +for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { +/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ +int adr =PCI_SLOT (devfn) <<16 |PCI_FUNC (devfn); +PCIDevice *pdev = bus->devices[devfn]; + +if (!pdev ||is_devfn_ignored_generic (devfn, bus)) { +continue ; + } + +/* start to compose PCI device descriptor */ + dev =aml_device ("S%.02X" , devfn); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); + +call_dev_aml_func (DEVICE (bus->devices[devfn]), dev); +/* add _DSM if device has acpi-index set */ +if (pdev->acpi_index && + !object_property_get_bool (OBJECT (pdev),"hotpluggable" , + &error_abort)) { +aml_append (dev,aml_pci_static_endpoint_dsm (pdev)); + } + +/* device descriptor has been composed, add it into parent context */ +aml_append (parent_scope, dev); + } +} +const VMStateDescription vmstate_acpi_pcihp_pci_status = { .name ="acpi_pcihp_pci_status" , .version_id =1 ,hw/i386/acpi-build.c +0
-172@@ -338,29 +338,6 @@ build_facs(GArray *table_data)g_array_append_vals (table_data, reserved,40 );/* Reserved */ } -static Aml *aml_pci_device_dsm (void ) -{ -Aml *method; - - method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); - { -Aml *params =aml_local (0 ); -Aml *pkg =aml_package (2 ); -aml_append (pkg,aml_int (0 )); -aml_append (pkg,aml_int (0 )); -aml_append (method,aml_store (pkg, params)); -aml_append (method, -aml_store (aml_name ("BSEL" ),aml_index (params,aml_int (0 )))); -aml_append (method, -aml_store (aml_name ("ASUN" ),aml_index (params,aml_int (1 )))); -aml_append (method, -aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), -aml_arg (2 ),aml_arg (3 ), params)) - ); - } -return method; -} -static Aml *aml_pci_edsm (void ) {Aml *method, *ifctx;@@ -414,155 +391,6 @@ static Aml *aml_pci_edsm(void)return method; } -static Aml *aml_pci_static_endpoint_dsm (PCIDevice *pdev) -{ -Aml *method; - -g_assert (pdev->acpi_index !=0 ); - method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); - { -Aml *params =aml_local (0 ); -Aml *pkg =aml_package (1 ); -aml_append (pkg,aml_int (pdev->acpi_index)); -aml_append (method,aml_store (pkg, params)); -aml_append (method, -aml_return (aml_call5 ("EDSM" ,aml_arg (0 ),aml_arg (1 ), -aml_arg (2 ),aml_arg (3 ), params)) - ); - } -return method; -} - -static void build_append_pcihp_notify_entry (Aml *method,int slot) -{ -Aml *if_ctx; -int32_t devfn =PCI_DEVFN (slot,0 ); - - if_ctx =aml_if (aml_and (aml_arg (0 ),aml_int (0x1U << slot),NULL )); -aml_append (if_ctx,aml_notify (aml_name ("S%.02X" , devfn),aml_arg (1 ))); -aml_append (method, if_ctx); -} - -static bool is_devfn_ignored_generic (const int devfn,const PCIBus *bus) -{ -const PCIDevice *pdev = bus->devices[devfn]; - -if (PCI_FUNC (devfn)) { -if (IS_PCI_BRIDGE (pdev)) { -/* -* Ignore only hotplugged PCI bridges on !0 functions, but -* allow describing cold plugged bridges on all functions -*/ -if (DEVICE (pdev)->hotplugged) { -return true; - } - } - } -return false; -} - -static bool is_devfn_ignored_hotplug (const int devfn,const PCIBus *bus) -{ -PCIDevice *pdev = bus->devices[devfn]; -if (pdev) { -return is_devfn_ignored_generic (devfn, bus) || - !DEVICE_GET_CLASS (pdev)->hotpluggable || -/* Cold plugged bridges aren't themselves hot-pluggable */ - (IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged); - }else {/* non populated slots */ -/* -* hotplug is supported only for non-multifunction device -* so generate device description only for function 0 -*/ -if (PCI_FUNC (devfn) || - (pci_bus_is_express (bus) &&PCI_SLOT (devfn) >0 )) { -return true; - } - } -return false; -} - -void build_append_pcihp_slots (Aml *parent_scope,PCIBus *bus) -{ -int devfn; -Aml *dev, *notify_method =NULL , *method; -QObject *bsel =object_property_get_qobject (OBJECT (bus), -ACPI_PCIHP_PROP_BSEL ,NULL ); -uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); -qobject_unref (bsel); - -aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); - notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED ); - -for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { -int slot =PCI_SLOT (devfn); -int adr = slot <<16 |PCI_FUNC (devfn); - -if (is_devfn_ignored_hotplug (devfn, bus)) { -continue ; - } - -if (bus->devices[devfn]) { - dev =aml_scope ("S%.02X" , devfn); - }else { - dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); - } - -/* -* Can't declare _SUN here for every device as it changes 'slot' -* enumeration order in linux kernel, so use another variable for it -*/ -aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); -aml_append (dev,aml_pci_device_dsm ()); - -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); -/* add _EJ0 to make slot hotpluggable */ - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) - ); -aml_append (dev, method); - -build_append_pcihp_notify_entry (notify_method, slot); - -/* device descriptor has been composed, add it into parent context */ -aml_append (parent_scope, dev); - } -aml_append (parent_scope, notify_method); -} - -void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) -{ -int devfn; -Aml *dev; - -for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { -/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ -int adr =PCI_SLOT (devfn) <<16 |PCI_FUNC (devfn); -PCIDevice *pdev = bus->devices[devfn]; - -if (!pdev ||is_devfn_ignored_generic (devfn, bus)) { -continue ; - } - -/* start to compose PCI device descriptor */ - dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); - -call_dev_aml_func (DEVICE (bus->devices[devfn]), dev); -/* add _DSM if device has acpi-index set */ -if (pdev->acpi_index && - !object_property_get_bool (OBJECT (pdev),"hotpluggable" , - &error_abort)) { -aml_append (dev,aml_pci_static_endpoint_dsm (pdev)); - } - -/* device descriptor has been composed, add it into parent context */ -aml_append (parent_scope, dev); - } -} -/* * build_prt - Define interrupt routing rules *
Re: [PATCH v2 14/25] hw/i386/acpi-build: Move build_append_pci_bus_devices/pcihp_slots to pcihp
Hi Jonathan,
Quoted 7 lines · Jonathan Cameron
Quoted 4 lines · On Tue, 27 May 2025 09:40:16 +0200 Eric Auger <[email protected]> wrote:
We intend to reuse
build_append_pci_bus_devicesandbuild_append_pcihp_slotson ARM. So let's move them tohw/acpi/pcihp.cas well as all static helpers they use.
Quoted 8 lines
Oddly short wrap. I guess it kind of looks prettier than ...
We intend to reuse
build_append_pci_bus_devicesandbuild_append_pcihp_slotson ARM. So let's move them tohw/acpi/pcihp.cas well as all static helpers they use.... so I'm not that fussed.
Effectively I can change this layout.
Quoted 4 lines
I don't really mind, but maybe a short statement of why you put the functions in a different order in the destination would be a good thing to add to this description?
My bad, there is no need to change the order of functions when moving. I guess I noticed incrementally which ones were needed and I did not pay attention to their original order. Now fixed.
Thanks!
Eric
Quoted 421 lines
Either way
Reviewed-by Jonathan Cameron <[email protected]>Quoted 417 lines
No functional change intended.
Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>--- 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@@ -80,6 +80,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@@ -27,6 +27,7 @@#include "qemu/osdep.h" #include "hw/acpi/pcihp.h" #include "hw/acpi/aml-build.h" +#include "hw/acpi/acpi_aml_interface.h" #include "hw/pci-host/i440fx.h" #include "hw/pci/pci.h" #include "hw/pci/pci_bridge.h" @@ -763,6 +764,178 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus)return !!nr_notifiers; } +static void build_append_pcihp_notify_entry (Aml *method,int slot) +{ +Aml *if_ctx; +int32_t devfn =PCI_DEVFN (slot,0 ); + + if_ctx =aml_if (aml_and (aml_arg (0 ),aml_int (0x1U << slot),NULL )); +aml_append (if_ctx,aml_notify (aml_name ("S%.02X" , devfn),aml_arg (1 ))); +aml_append (method, if_ctx); +} + +static bool is_devfn_ignored_generic (const int devfn,const PCIBus *bus) +{ +const PCIDevice *pdev = bus->devices[devfn]; + +if (PCI_FUNC (devfn)) { +if (IS_PCI_BRIDGE (pdev)) { +/* +* Ignore only hotplugged PCI bridges on !0 functions, but +* allow describing cold plugged bridges on all functions +*/ +if (DEVICE (pdev)->hotplugged) { +return true; + } + } + } +return false; +} + +static bool is_devfn_ignored_hotplug (const int devfn,const PCIBus *bus) +{ +PCIDevice *pdev = bus->devices[devfn]; +if (pdev) { +return is_devfn_ignored_generic (devfn, bus) || + !DEVICE_GET_CLASS (pdev)->hotpluggable || +/* Cold plugged bridges aren't themselves hot-pluggable */ + (IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged); + }else {/* non populated slots */ +/* +* hotplug is supported only for non-multifunction device +* so generate device description only for function 0 +*/ +if (PCI_FUNC (devfn) || + (pci_bus_is_express (bus) &&PCI_SLOT (devfn) >0 )) { +return true; + } + } +return false; +} + +static Aml *aml_pci_static_endpoint_dsm (PCIDevice *pdev) +{ +Aml *method; + +g_assert (pdev->acpi_index !=0 ); + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (1 ); +aml_append (pkg,aml_int (pdev->acpi_index)); +aml_append (method,aml_store (pkg, params)); +aml_append (method, +aml_return (aml_call5 ("EDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), params)) + ); + } +return method; +} + +static Aml *aml_pci_device_dsm (void ) +{ +Aml *method; + + method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); + { +Aml *params =aml_local (0 ); +Aml *pkg =aml_package (2 ); +aml_append (pkg,aml_int (0 )); +aml_append (pkg,aml_int (0 )); +aml_append (method,aml_store (pkg, params)); +aml_append (method, +aml_store (aml_name ("BSEL" ),aml_index (params,aml_int (0 )))); +aml_append (method, +aml_store (aml_name ("ASUN" ),aml_index (params,aml_int (1 )))); +aml_append (method, +aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), +aml_arg (2 ),aml_arg (3 ), params)) + ); + } +return method; +} + +void build_append_pcihp_slots (Aml *parent_scope,PCIBus *bus) +{ +int devfn; +Aml *dev, *notify_method =NULL , *method; +QObject *bsel =object_property_get_qobject (OBJECT (bus), +ACPI_PCIHP_PROP_BSEL ,NULL ); +uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); +qobject_unref (bsel); + +aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); + notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED ); + +for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { +int slot =PCI_SLOT (devfn); +int adr = slot <<16 |PCI_FUNC (devfn); + +if (is_devfn_ignored_hotplug (devfn, bus)) { +continue ; + } + +if (bus->devices[devfn]) { + dev =aml_scope ("S%.02X" , devfn); + }else { + dev =aml_device ("S%.02X" , devfn); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); + } + +/* +* Can't declare _SUN here for every device as it changes 'slot' +* enumeration order in linux kernel, so use another variable for it +*/ +aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); +aml_append (dev,aml_pci_device_dsm ()); + +aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); +/* add _EJ0 to make slot hotpluggable */ + method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); +aml_append (method, +aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) + ); +aml_append (dev, method); + +build_append_pcihp_notify_entry (notify_method, slot); + +/* device descriptor has been composed, add it into parent context */ +aml_append (parent_scope, dev); + } +aml_append (parent_scope, notify_method); +} + +void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) +{ +int devfn; +Aml *dev; + +for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { +/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ +int adr =PCI_SLOT (devfn) <<16 |PCI_FUNC (devfn); +PCIDevice *pdev = bus->devices[devfn]; + +if (!pdev ||is_devfn_ignored_generic (devfn, bus)) { +continue ; + } + +/* start to compose PCI device descriptor */ + dev =aml_device ("S%.02X" , devfn); +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); + +call_dev_aml_func (DEVICE (bus->devices[devfn]), dev); +/* add _DSM if device has acpi-index set */ +if (pdev->acpi_index && + !object_property_get_bool (OBJECT (pdev),"hotpluggable" , + &error_abort)) { +aml_append (dev,aml_pci_static_endpoint_dsm (pdev)); + } + +/* device descriptor has been composed, add it into parent context */ +aml_append (parent_scope, dev); + } +} +const VMStateDescription vmstate_acpi_pcihp_pci_status = { .name ="acpi_pcihp_pci_status" , .version_id =1 ,hw/i386/acpi-build.c +0
-172@@ -338,29 +338,6 @@ build_facs(GArray *table_data)g_array_append_vals (table_data, reserved,40 );/* Reserved */ } -static Aml *aml_pci_device_dsm (void ) -{ -Aml *method; - - method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); - { -Aml *params =aml_local (0 ); -Aml *pkg =aml_package (2 ); -aml_append (pkg,aml_int (0 )); -aml_append (pkg,aml_int (0 )); -aml_append (method,aml_store (pkg, params)); -aml_append (method, -aml_store (aml_name ("BSEL" ),aml_index (params,aml_int (0 )))); -aml_append (method, -aml_store (aml_name ("ASUN" ),aml_index (params,aml_int (1 )))); -aml_append (method, -aml_return (aml_call5 ("PDSM" ,aml_arg (0 ),aml_arg (1 ), -aml_arg (2 ),aml_arg (3 ), params)) - ); - } -return method; -} -static Aml *aml_pci_edsm (void ) {Aml *method, *ifctx;@@ -414,155 +391,6 @@ static Aml *aml_pci_edsm(void)return method; } -static Aml *aml_pci_static_endpoint_dsm (PCIDevice *pdev) -{ -Aml *method; - -g_assert (pdev->acpi_index !=0 ); - method =aml_method ("_DSM" ,4 ,AML_SERIALIZED ); - { -Aml *params =aml_local (0 ); -Aml *pkg =aml_package (1 ); -aml_append (pkg,aml_int (pdev->acpi_index)); -aml_append (method,aml_store (pkg, params)); -aml_append (method, -aml_return (aml_call5 ("EDSM" ,aml_arg (0 ),aml_arg (1 ), -aml_arg (2 ),aml_arg (3 ), params)) - ); - } -return method; -} - -static void build_append_pcihp_notify_entry (Aml *method,int slot) -{ -Aml *if_ctx; -int32_t devfn =PCI_DEVFN (slot,0 ); - - if_ctx =aml_if (aml_and (aml_arg (0 ),aml_int (0x1U << slot),NULL )); -aml_append (if_ctx,aml_notify (aml_name ("S%.02X" , devfn),aml_arg (1 ))); -aml_append (method, if_ctx); -} - -static bool is_devfn_ignored_generic (const int devfn,const PCIBus *bus) -{ -const PCIDevice *pdev = bus->devices[devfn]; - -if (PCI_FUNC (devfn)) { -if (IS_PCI_BRIDGE (pdev)) { -/* -* Ignore only hotplugged PCI bridges on !0 functions, but -* allow describing cold plugged bridges on all functions -*/ -if (DEVICE (pdev)->hotplugged) { -return true; - } - } - } -return false; -} - -static bool is_devfn_ignored_hotplug (const int devfn,const PCIBus *bus) -{ -PCIDevice *pdev = bus->devices[devfn]; -if (pdev) { -return is_devfn_ignored_generic (devfn, bus) || - !DEVICE_GET_CLASS (pdev)->hotpluggable || -/* Cold plugged bridges aren't themselves hot-pluggable */ - (IS_PCI_BRIDGE (pdev) && !DEVICE (pdev)->hotplugged); - }else {/* non populated slots */ -/* -* hotplug is supported only for non-multifunction device -* so generate device description only for function 0 -*/ -if (PCI_FUNC (devfn) || - (pci_bus_is_express (bus) &&PCI_SLOT (devfn) >0 )) { -return true; - } - } -return false; -} - -void build_append_pcihp_slots (Aml *parent_scope,PCIBus *bus) -{ -int devfn; -Aml *dev, *notify_method =NULL , *method; -QObject *bsel =object_property_get_qobject (OBJECT (bus), -ACPI_PCIHP_PROP_BSEL ,NULL ); -uint64_t bsel_val =qnum_get_uint (qobject_to (QNum, bsel)); -qobject_unref (bsel); - -aml_append (parent_scope,aml_name_decl ("BSEL" ,aml_int (bsel_val))); - notify_method =aml_method ("DVNT" ,2 ,AML_NOTSERIALIZED ); - -for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { -int slot =PCI_SLOT (devfn); -int adr = slot <<16 |PCI_FUNC (devfn); - -if (is_devfn_ignored_hotplug (devfn, bus)) { -continue ; - } - -if (bus->devices[devfn]) { - dev =aml_scope ("S%.02X" , devfn); - }else { - dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); - } - -/* -* Can't declare _SUN here for every device as it changes 'slot' -* enumeration order in linux kernel, so use another variable for it -*/ -aml_append (dev,aml_name_decl ("ASUN" ,aml_int (slot))); -aml_append (dev,aml_pci_device_dsm ()); - -aml_append (dev,aml_name_decl ("_SUN" ,aml_int (slot))); -/* add _EJ0 to make slot hotpluggable */ - method =aml_method ("_EJ0" ,1 ,AML_NOTSERIALIZED ); -aml_append (method, -aml_call2 ("PCEJ" ,aml_name ("BSEL" ),aml_name ("_SUN" )) - ); -aml_append (dev, method); - -build_append_pcihp_notify_entry (notify_method, slot); - -/* device descriptor has been composed, add it into parent context */ -aml_append (parent_scope, dev); - } -aml_append (parent_scope, notify_method); -} - -void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus) -{ -int devfn; -Aml *dev; - -for (devfn =0 ; devfn <ARRAY_SIZE (bus->devices); devfn++) { -/* ACPI spec: 1.0b: Table 6-2 _ADR Object Bus Types, PCI type */ -int adr =PCI_SLOT (devfn) <<16 |PCI_FUNC (devfn); -PCIDevice *pdev = bus->devices[devfn]; - -if (!pdev ||is_devfn_ignored_generic (devfn, bus)) { -continue ; - } - -/* start to compose PCI device descriptor */ - dev =aml_device ("S%.02X" , devfn); -aml_append (dev,aml_name_decl ("_ADR" ,aml_int (adr))); - -call_dev_aml_func (DEVICE (bus->devices[devfn]), dev); -/* add _DSM if device has acpi-index set */ -if (pdev->acpi_index && - !object_property_get_bool (OBJECT (pdev),"hotpluggable" , - &error_abort)) { -aml_append (dev,aml_pci_static_endpoint_dsm (pdev)); - } - -/* device descriptor has been composed, add it into parent context */ -aml_append (parent_scope, dev); - } -} -/* * build_prt - Define interrupt routing rules *
PATCH v2 15/25 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.
Also instead of using the machine child property to retrieve the PCI host bridge, we search for the actual object type using object_resolve_type_unambiguous().
---
v1 -> v2
- described the fact we changed the implementation of acpi_get_pci_host() in the commit msg.
--- 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 ;
@@ -1245,7 +1229,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;
@@ -1306,7 +1290,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" );
@@ -1946,7 +1930,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
Re: [PATCH v2 15/25] hw/i386/acpi-build: Introduce and use acpi_get_pci_host
Quoted 69 lines · On Tue, 27 May 2025 09:40:17 +0200 Eric Auger <[email protected]> wrote:
pcihp
acpi_set_pci_info()generic code currently usesacpi_get_i386_pci_host()to retrieve the pci host bridge.Let's rename
acpi_get_i386_pci_hostintoacpi_get_pci_hostand move it in pci generic code.The helper is augmented with the support of ARM GPEX.
Also instead of using the machine child property to retrieve the PCI host bridge, we search for the actual object type using
object_resolve_type_unambiguous().Signed-off-by Eric Auger <[email protected]>Reviewed-by Gustavo Romero <[email protected]>---
v1 -> v2
- described the fact we changed the implementation ofacpi_get_pci_host()in the commit msg.--- 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 +9
-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; +
hw/acpi/pci.c void build_srat_generic_affinity_structures(GArray *table_data) · line 322
Quoted 10 lines
hw/acpi/pci.c +10
-0+ 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;
while it will work, it's getting ridiculous.
(it's not likely to affect performance but if it can be helped, I'd rather avoid searching)
Can we just reuse host bridge bus in stored in pcihp state? aka we do pass root_bus to acpi_pcihp_init() and then there is AcpiPciHpState::root
then there are other places that call acpi_get_i386_pci_host() to get root bus, can't we just get it from machine state that callers get and pass it down as an argument?
Quoted 82 lines
hw/acpi/pci.c +1
-0+}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 ;@@ -1245,7 +1229,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;@@ -1306,7 +1290,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" );@@ -1946,7 +1930,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; }
PATCH v2 16/25 hw/i386/acpi-build: Move aml_pci_edsm to a generic place
In reply to Eric AugerMove aml_pci_edsm to pcihp since we want to reuse that for ARM and acpi-index support.
--- include/hw/acpi/pcihp.h | 2 ++ hw/acpi/pcihp.c | 53 +++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 53 ----------------------------------------- 3 files changed, 55 insertions(+), 53 deletions(-)
include/hw/acpi/pcihp.h +2 -0
@@ -82,6 +82,8 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus);void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus); +Aml *aml_pci_edsm (void ); +/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);
hw/acpi/pcihp.c +53 -0
59 lines not on this page · raw message
hw/i386/acpi-build.c +0 -53
59 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH v2 16/25] hw/i386/acpi-build: Move aml_pci_edsm to a generic place
Quoted 7 lines · On Tue, 27 May 2025 09:40:18 +0200 Eric Auger <[email protected]> wrote:
Move
aml_pci_edsmto pcihp since we want to reuse that for ARM and acpi-index support.Signed-off-by Eric Auger <[email protected]>--- include/hw/acpi/pcihp.h | 2 ++ hw/acpi/pcihp.c | 53 +++++++++++++++++++++++++++++++++++++++++
edsm is for un-pluggable ports,
a more suitable place for it would be hw/acpi/pci.c
Quoted 144 lines
hw/i386/acpi-build.c | 53 ----------------------------------------- 3 files changed, 55 insertions(+), 53 deletions(-)include/hw/acpi/pcihp.h +2
-0@@ -82,6 +82,8 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus);void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus); +Aml *aml_pci_edsm (void ); +/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);hw/acpi/pcihp.c +53
-0@@ -937,6 +937,59 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus) } } +Aml *aml_pci_edsm (void ) +{ +Aml *method, *ifctx; +Aml *zero =aml_int (0 ); +Aml *func =aml_arg (2 ); +Aml *ret =aml_local (0 ); +Aml *aidx =aml_local (1 ); +Aml *params =aml_arg (4 ); + + method =aml_method ("EDSM" ,5 ,AML_SERIALIZED ); + +/* get supported functions */ + ifctx =aml_if (aml_equal (func, zero)); + { +/* 1: have supported functions */ +/* 7: support for function 7 */ +const uint8_t caps =1 |BIT (7 ); +build_append_pci_dsm_func0_common (ifctx, ret); +aml_append (ifctx,aml_store (aml_int (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 (pkg, zero); +/* optional, if not impl. should return null string */ +aml_append (pkg,aml_string ("%s" ,"" )); +aml_append (ifctx,aml_store (pkg, ret)); + +/* +* IASL is fine when initializing Package with computational data, +* however it makes guest unhappy /it fails to process such AML/. +* So use runtime assignment to set acpi-index after initializer +* to make OSPM happy. +*/ +aml_append (ifctx, +aml_store (aml_derefof (aml_index (params,aml_int (0 ))), aidx)); +aml_append (ifctx,aml_store (aidx,aml_index (ret, zero))); +aml_append (ifctx,aml_return (ret)); + } +aml_append (method, ifctx); + +return method; +} +const VMStateDescription vmstate_acpi_pcihp_pci_status = { .name ="acpi_pcihp_pci_status" , .version_id =1 ,hw/i386/acpi-build.c +0
-53@@ -322,59 +322,6 @@ build_facs(GArray *table_data)g_array_append_vals (table_data, reserved,40 );/* Reserved */ } -static Aml *aml_pci_edsm (void ) -{ -Aml *method, *ifctx; -Aml *zero =aml_int (0 ); -Aml *func =aml_arg (2 ); -Aml *ret =aml_local (0 ); -Aml *aidx =aml_local (1 ); -Aml *params =aml_arg (4 ); - - method =aml_method ("EDSM" ,5 ,AML_SERIALIZED ); - -/* get supported functions */ - ifctx =aml_if (aml_equal (func, zero)); - { -/* 1: have supported functions */ -/* 7: support for function 7 */ -const uint8_t caps =1 |BIT (7 ); -build_append_pci_dsm_func0_common (ifctx, ret); -aml_append (ifctx,aml_store (aml_int (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 (pkg, zero); -/* optional, if not impl. should return null string */ -aml_append (pkg,aml_string ("%s" ,"" )); -aml_append (ifctx,aml_store (pkg, ret)); - -/* -* IASL is fine when initializing Package with computational data, -* however it makes guest unhappy /it fails to process such AML/. -* So use runtime assignment to set acpi-index after initializer -* to make OSPM happy. -*/ -aml_append (ifctx, -aml_store (aml_derefof (aml_index (params,aml_int (0 ))), aidx)); -aml_append (ifctx,aml_store (aidx,aml_index (ret, zero))); -aml_append (ifctx,aml_return (ret)); - } -aml_append (method, ifctx); - -return method; -} -/* * build_prt - Define interrupt routing rules *
Re: [PATCH v2 16/25] hw/i386/acpi-build: Move aml_pci_edsm to a generic place
Quoted 6 lines · On Tue, 27 May 2025 16:00:40 +0200 Igor Mammedov <[email protected]> wrote:
Quoted 3 lines · On Tue, 27 May 2025 09:40:18 +0200 Eric Auger <[email protected]> wrote:
Move
aml_pci_edsmto pcihp since we want to reuse that for ARM and acpi-index support.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Eric Auger <[email protected]>--- include/hw/acpi/pcihp.h | 2 ++ hw/acpi/pcihp.c | 53 +++++++++++++++++++++++++++++++++++++++++edsm is for un-pluggable ports,
a more suitable place for it would behw/acpi/pci.c
or maybe hw/acpi/pci-bridge.c as its owner/call is a bridge
Quoted 147 lines
Quoted 146 lines
hw/i386/acpi-build.c | 53 ----------------------------------------- 3 files changed, 55 insertions(+), 53 deletions(-)include/hw/acpi/pcihp.h +2
-0@@ -82,6 +82,8 @@ bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus);void build_append_pci_bus_devices (Aml *parent_scope,PCIBus *bus); +Aml *aml_pci_edsm (void ); +/* Called on reset */ void acpi_pcihp_reset (AcpiPciHpState *s);hw/acpi/pcihp.c +53
-0@@ -937,6 +937,59 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus) } } +Aml *aml_pci_edsm (void ) +{ +Aml *method, *ifctx; +Aml *zero =aml_int (0 ); +Aml *func =aml_arg (2 ); +Aml *ret =aml_local (0 ); +Aml *aidx =aml_local (1 ); +Aml *params =aml_arg (4 ); + + method =aml_method ("EDSM" ,5 ,AML_SERIALIZED ); + +/* get supported functions */ + ifctx =aml_if (aml_equal (func, zero)); + { +/* 1: have supported functions */ +/* 7: support for function 7 */ +const uint8_t caps =1 |BIT (7 ); +build_append_pci_dsm_func0_common (ifctx, ret); +aml_append (ifctx,aml_store (aml_int (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 (pkg, zero); +/* optional, if not impl. should return null string */ +aml_append (pkg,aml_string ("%s" ,"" )); +aml_append (ifctx,aml_store (pkg, ret)); + +/* +* IASL is fine when initializing Package with computational data, +* however it makes guest unhappy /it fails to process such AML/. +* So use runtime assignment to set acpi-index after initializer +* to make OSPM happy. +*/ +aml_append (ifctx, +aml_store (aml_derefof (aml_index (params,aml_int (0 ))), aidx)); +aml_append (ifctx,aml_store (aidx,aml_index (ret, zero))); +aml_append (ifctx,aml_return (ret)); + } +aml_append (method, ifctx); + +return method; +} +const VMStateDescription vmstate_acpi_pcihp_pci_status = { .name ="acpi_pcihp_pci_status" , .version_id =1 ,hw/i386/acpi-build.c +0
-53@@ -322,59 +322,6 @@ build_facs(GArray *table_data)g_array_append_vals (table_data, reserved,40 );/* Reserved */ } -static Aml *aml_pci_edsm (void ) -{ -Aml *method, *ifctx; -Aml *zero =aml_int (0 ); -Aml *func =aml_arg (2 ); -Aml *ret =aml_local (0 ); -Aml *aidx =aml_local (1 ); -Aml *params =aml_arg (4 ); - - method =aml_method ("EDSM" ,5 ,AML_SERIALIZED ); - -/* get supported functions */ - ifctx =aml_if (aml_equal (func, zero)); - { -/* 1: have supported functions */ -/* 7: support for function 7 */ -const uint8_t caps =1 |BIT (7 ); -build_append_pci_dsm_func0_common (ifctx, ret); -aml_append (ifctx,aml_store (aml_int (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 (pkg, zero); -/* optional, if not impl. should return null string */ -aml_append (pkg,aml_string ("%s" ,"" )); -aml_append (ifctx,aml_store (pkg, ret)); - -/* -* IASL is fine when initializing Package with computational data, -* however it makes guest unhappy /it fails to process such AML/. -* So use runtime assignment to set acpi-index after initializer -* to make OSPM happy. -*/ -aml_append (ifctx, -aml_store (aml_derefof (aml_index (params,aml_int (0 ))), aidx)); -aml_append (ifctx,aml_store (aidx,aml_index (ret, zero))); -aml_append (ifctx,aml_return (ret)); - } -aml_append (method, ifctx); - -return method; -} -/* * build_prt - Define interrupt routing rules *
PATCH v2 17/25 hw/arm/virt-acpi-build: Modify the DSDT ACPI table to enable ACPI PCI hotplug
In reply to Eric AugerModify the DSDT ACPI table to enable ACPI PCI hotplug.
--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 21 +++++++++++++++++++++ hw/arm/virt.c | 1 + hw/arm/Kconfig | 2 ++ 4 files changed, 25 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 +21 -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"
@@ -836,6 +837,7 @@ 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); +if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(vms->acpi_dev),
@@ -864,6 +866,25 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)aml_append (dsdt, scope); +if (vms->acpi_pcihp) { +Aml *pci0_scope =aml_scope ("\\_SB.PCI0" ); + +aml_append (pci0_scope,aml_pci_edsm ()); +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); + } +/* copy AML table into ACPI tables blob */ g_array_append_vals (table_data, dsdt->buf->data, dsdt->buf->len);
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
Re: [PATCH v2 17/25] hw/arm/virt-acpi-build: Modify the DSDT ACPI table to enable ACPI PCI hotplug
Quoted 73 lines · On Tue, 27 May 2025 09:40:19 +0200 Eric Auger <[email protected]> wrote:
Modify the DSDT ACPI table to enable ACPI PCI hotplug.
Signed-off-by Eric Auger <[email protected]>--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 21 +++++++++++++++++++++ hw/arm/virt.c | 1 + hw/arm/Kconfig | 2 ++ 4 files changed, 25 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 +21
-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" @@ -836,6 +837,7 @@ 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); +if (vms->acpi_dev) { build_ged_aml(scope, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(vms->acpi_dev),@@ -864,6 +866,25 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)aml_append (dsdt, scope); +if (vms->acpi_pcihp) { +Aml *pci0_scope =aml_scope ("\\_SB.PCI0" ); + +aml_append (pci0_scope,aml_pci_edsm ()); +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); + } +/* copy AML table into ACPI tables blob */ g_array_append_vals (table_data, dsdt->buf->data, dsdt->buf->len);hw/arm/virt.c +0
-0
hw/arm/virt.c static const MemMapEntry base_memmap[] = { · line 186
Quoted 4 lines
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 },
^^^^^
why not use actual len define here?
Quoted 16 lines
hw/arm/virt.c +0
-0[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
PATCH v2 18/25 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 occurrence 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.
---
v1 -> v2:
- Introduce ACPI_PCIHP_REGION_NAME
--- include/hw/acpi/generic_event_device.h | 7 +++++++ include/hw/acpi/pcihp.h | 2 ++ hw/acpi/generic_event_device.c | 14 ++++++++++++++ hw/acpi/pcihp.c | 1 - 4 files changed, 23 insertions(+), 1 deletion(-)
include/hw/acpi/generic_event_device.h +7 -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;
@@ -108,12 +110,17 @@ typedef struct GEDState {uint32_t sel; } GEDState; +#define ACPI_PCIHP_REGION_NAME "pcihp container" +struct AcpiGedState {SysBusDevice parent_obj;MemHotplugState memhp_state;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_PCIHP_SIZE 0x0018 + typedef struct AcpiPciHpPciStatus { uint32_t up; uint32_t down;
hw/acpi/generic_event_device.c +14 -0
@@ -12,6 +12,7 @@#include "qemu/osdep.h" #include "qapi/error.h" #include "hw/acpi/acpi.h" +#include "hw/acpi/pcihp.h" #include "hw/acpi/generic_event_device.h" #include "hw/irq.h" #include "hw/mem/pc-dimm.h"
@@ -26,6 +27,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 +123,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 +307,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 +438,10 @@ 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), +ACPI_PCIHP_REGION_NAME ,ACPI_PCIHP_SIZE ); +sysbus_init_mmio (sbd, &s->container_pcihp); } ged_events--; }
hw/acpi/pcihp.c +0 -1
@@ -44,7 +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
Signature · 1 line
2.49.0
PATCH v2 19/25 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
@@ -17,6 +17,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"
@@ -235,6 +236,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) {
@@ -248,6 +260,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)));
@@ -264,6 +278,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)));
@@ -279,6 +296,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, const 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
Re: [PATCH v2 19/25] hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation
Quoted 26 lines · On Tue, 27 May 2025 09:40:21 +0200 Eric Auger <[email protected]> wrote:
Add PCI device related code in the
TYPE_HOTPLUG_HANDLERimplementation.For a PCI device hotplug/hotunplug event, the code routes to
acpi_pcihp_devicecallbacks (pre_plug_cb,plug_cb,unplug_request_cb,unplug_cb).Signed-off-by Eric Auger <[email protected]>--- hw/acpi/generic_event_device.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)hw/acpi/generic_event_device.c +1
-0@@ -17,6 +17,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" @@ -235,6 +236,17 @@ static const MemoryRegionOps ged_regs_ops = { },
hw/acpi/generic_event_device.c static const MemoryRegionOps ged_regs_ops = { · line 246
Quoted 10 lines
hw/acpi/generic_event_device.c +8
-0}; +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)));
does memory hotplug still work after that?
why?
Quoted 42 lines
hw/acpi/generic_event_device.c +11
-0+ } +} +static void acpi_ged_device_plug_cb (HotplugHandler *hotplug_dev,DeviceState *dev,Error **errp) {@@ -248,6 +260,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)));@@ -264,6 +278,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)));@@ -279,6 +296,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, const 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;
PATCH v2 20/25 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
@@ -415,6 +415,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 ,
@@ -427,6 +446,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
Re: [PATCH v2 20/25] hw/acpi/ged: Support migration of AcpiPciHpState
Quoted 3 lines · On Tue, 27 May 2025 09:40:22 +0200 Eric Auger <[email protected]> wrote:
Add a subsection to migrate the AcpiPciHpState state.
Signed-off-by Eric Auger <[email protected]>
Quoted 42 lines
--- hw/acpi/generic_event_device.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)hw/acpi/generic_event_device.c +20
-0@@ -415,6 +415,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 ,@@ -427,6 +446,7 @@ static const VMStateDescription vmstate_acpi_ged = { &vmstate_memhp_state, &vmstate_cpuhp_state, &vmstate_ghes_state, + &vmstate_pcihp_state, NULL } };
PATCH v2 21/25 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
PATCH v2 22/25 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 hotplug callbacks will soon be called on gpex realize and will require the acpi pcihp state to be initialized.
The hacky thing is the root bus has not yet been created on acpi_pcihp_init() call so it is set later after the gpex realize.
How to fix this chicken & egg issue?
---
v1 -> v2:
- use ACPI_PCIHP_REGION_NAME
--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 42 +++++++++++++++++++++++++++++++++++----- 3 files changed, 39 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 +37 -5
75 lines not on this page · raw message
Signature · 1 line
2.49.0
Re: [PATCH v2 22/25] hw/arm/virt: Let virt support pci hotplug/unplug GED event
Hi Eric,
Quoted 11 lines · Eric Auger
Set 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 hotplug callbacks will soon be called on gpex realize and will require the acpi pcihp state to be initialized.The hacky thing is the root bus has not yet been created on
acpi_pcihp_init()call so it is set later after the gpex realize.How to fix this chicken & egg issue?
FYI I have this question tagged since v1, I will try to look at it in some days...
Quoted 12 lines
Signed-off-by Eric Auger <[email protected]>---
v1 -> v2:
- useACPI_PCIHP_REGION_NAME--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 42 +++++++++++++++++++++++++++++++++++----- 3 files changed, 39 insertions(+), 5 deletions(-)
Re: [PATCH v2 22/25] hw/arm/virt: Let virt support pci hotplug/unplug GED event
In reply to Eric AugerQuoted 11 lines · On Tue, 27 May 2025 09:40:24 +0200 Eric Auger <[email protected]> wrote:
Set 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 hotplug callbacks will soon be called on gpex realize and will require the acpi pcihp state to be initialized.The hacky thing is the root bus has not yet been created on
acpi_pcihp_init()call so it is set later after the gpex realize.
can you elaborate on this, preferably with call expected call flows?
Quoted 59 lines
How to fix this chicken & egg issue?
Signed-off-by Eric Auger <[email protected]>---
v1 -> v2:
- useACPI_PCIHP_REGION_NAME--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 42 +++++++++++++++++++++++++++++++++++----- 3 files changed, 39 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 +6
-0@@ -682,6 +682,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 ;@@ -693,12 +695,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 ; + } +
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 708
Quoted 10 lines
hw/arm/virt.c +4
-3dev =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);
Perhaps move out sbdev renaming into a separate patch, as it's not really related.
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 714
Quoted 6 lines
hw/arm/virt.c +6
-0+if (vms->acpi_pcihp) { +AcpiGedState *acpi_ged_state =ACPI_GED (dev); +int i; + + i =sysbus_mmio_map_name (sbdev,ACPI_PCIHP_REGION_NAME , + vms->memmap[VIRT_ACPI_PCIHP ].base);
I don't like mix of old way (index based) above and new name based mapping, can we use the same, please?
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 715
Quoted 1 line
hw/arm/virt.c +1
-0+assert (i >=0 );
g_assert(sysbus_mmio_map_name...) to get more meaning-full crash that is not compiled out.
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 717
Quoted 2 lines
hw/arm/virt.c +2
-0+acpi_pcihp_init (OBJECT (dev), &acpi_ged_state->pcihp_state, + vms->bus,sysbus_mmio_get_region (sbdev, i),0 );
hmm, looks broken..
region mapping must happen after acpi_pcihp_init().
if we after making sysbus_mmio_map() sane and easier to use (which is a bit on tangent to this series).
We could feed sysbus owner device a memory map (ex: name based), and then use [pre_]plug handlers on sysbus to map children automatically.
That will alleviate need to do all mapping manually in every board. (frankly speaking it deserves its own series, with tree wide cleanup).
As it is I'd use old index based approach like the rest. (unless you feel adventurous about sysbus refactoring)
Quoted 35 lines
hw/arm/virt.c +9
-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;@@ -1758,6 +1776,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);}
hw/arm/virt.c +2
-2@@ -2395,8 +2420,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);@@ -2405,6 +2428,15 @@ static void machvirt_init(MachineState *machine)create_gpio_devices (vms,VIRT_GPIO , sysmem); } +create_pcie (vms); +
hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2442
Quoted 10 lines
hw/arm/virt.c +7
-0+if (vms->acpi_dev) { +AcpiGedState *acpi_ged_state =ACPI_GED (vms->acpi_dev); + + acpi_ged_state =ACPI_GED (vms->acpi_dev); + acpi_ged_state->pcihp_state.root = vms->bus; + } +if (vms->secure && !vmc->no_secure_gpio) {create_gpio_devices (vms,VIRT_SECURE_GPIO , secure_sysmem); }
I don't like pulling acpi_pcihp_init()/reset (and issues it causes) into board code, on x86 it's a part of host bridge device model.
The same should apply to GED device.
The only thing board has to do is map regions into IO space like we do everywhere else.
with current code, may be add link<pci_bus> property to GED, and set it before GED realize in create_acpi_ged(), then just follow existing sysbus_mmio_map() pattern.
Re: [PATCH v2 22/25] hw/arm/virt: Let virt support pci hotplug/unplug GED event
Hi folks,
Quoted 8 lines · Igor Mammedov
Quoted 2 lines · On Tue, 27 May 2025 09:40:24 +0200 Eric Auger <[email protected]> wrote:
Set up the IO registers used to communicate between QEMU and ACPI.
Quoted 8 lines
Quoted 6 lines
Move the
create_pcie()call after the creation of the acpi ged device since hotplug callbacks will soon be called on gpex realize and will require the acpi pcihp state to be initialized.The hacky thing is the root bus has not yet been created on
acpi_pcihp_init()call so it is set later after the gpex realize.can you elaborate on this, preferably with call expected call flows?
The way I'm understanding it is: because the GED and GPEX are created in virt.c, so at the machine "level" (and so a machine hotplug handler is used instead of a device hotplug handler, like it's done in PIIX4 and ICH9 controller in the x86 machines), and they need to be created in that order because of dependecy of GPEX of GED, the flow is:
1) create_acpi_ged() -> calls acpi_pcihp_init(), which by its turn will inspect the root bus to generate the ACPI code
2) create_pcie() -> just in realize the root bus will be created
and the sequence has to be 1 -> 2, because GED will be used in the GPEX callbacks on hotplug.
So here we're following a different design from the current one in x86, which handles the hotplug at the PCI controller "level".
Cheers,
Gustavo
Quoted 162 lines
Quoted 59 lines
How to fix this chicken & egg issue?
Signed-off-by Eric Auger <[email protected]>---
v1 -> v2:
- useACPI_PCIHP_REGION_NAME--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 42 +++++++++++++++++++++++++++++++++++----- 3 files changed, 39 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 +6
-0@@ -682,6 +682,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 ;@@ -693,12 +695,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 ; + } +hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 708
Quoted 10 lines
hw/arm/virt.c +4
-3dev =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);Perhaps move out sbdev renaming into a separate patch, as it's not really related.
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 714
Quoted 6 lines
hw/arm/virt.c +6
-0+if (vms->acpi_pcihp) { +AcpiGedState *acpi_ged_state =ACPI_GED (dev); +int i; + + i =sysbus_mmio_map_name (sbdev,ACPI_PCIHP_REGION_NAME , + vms->memmap[VIRT_ACPI_PCIHP ].base);I don't like mix of old way (index based) above and new name based mapping, can we use the same, please?
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 715
Quoted 1 line
hw/arm/virt.c +1
-0+assert (i >=0 );
g_assert(sysbus_mmio_map_name...)to get more meaning-full crash that is not compiled out.hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 717
Quoted 2 lines
hw/arm/virt.c +2
-0+acpi_pcihp_init (OBJECT (dev), &acpi_ged_state->pcihp_state, + vms->bus,sysbus_mmio_get_region (sbdev, i),0 );hmm, looks broken..
region mapping must happen afteracpi_pcihp_init().if we after making
sysbus_mmio_map()sane and easier to use (which is a bit on tangent to this series).
We could feed sysbus owner device a memory map (ex: name based), and then use [pre_]plug handlers on sysbus to map children automatically.
That will alleviate need to do all mapping manually in every board. (frankly speaking it deserves its own series, with tree wide cleanup).As it is I'd use old index based approach like the rest. (unless you feel adventurous about sysbus refactoring)
Quoted 35 lines
hw/arm/virt.c +9
-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;@@ -1758,6 +1776,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);}hw/arm/virt.c +2
-2@@ -2395,8 +2420,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);@@ -2405,6 +2428,15 @@ static void machvirt_init(MachineState *machine)create_gpio_devices (vms,VIRT_GPIO , sysmem); } +create_pcie (vms); +hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2442
Quoted 10 lines
hw/arm/virt.c +7
-0+if (vms->acpi_dev) { +AcpiGedState *acpi_ged_state =ACPI_GED (vms->acpi_dev); + + acpi_ged_state =ACPI_GED (vms->acpi_dev); + acpi_ged_state->pcihp_state.root = vms->bus; + } +if (vms->secure && !vmc->no_secure_gpio) {create_gpio_devices (vms,VIRT_SECURE_GPIO , secure_sysmem); }I don't like pulling acpi_pcihp_init()/reset (and issues it causes) into board code, on x86 it's a part of host bridge device model.
The same should apply to GED device.The only thing board has to do is map regions into IO space like we do everywhere else.
with current code, may be add link<pci_bus> property to GED, and set it before GED realize in
create_acpi_ged(), then just follow existingsysbus_mmio_map()pattern.
Re: [PATCH v2 22/25] hw/arm/virt: Let virt support pci hotplug/unplug GED event
Quoted 26 lines · Gustavo Romero
Hi folks,
Quoted 8 lines · Igor Mammedov
Quoted 2 lines · On Tue, 27 May 2025 09:40:24 +0200 Eric Auger <[email protected]> wrote:
Set up the IO registers used to communicate between QEMU and ACPI.
Quoted 8 lines
Quoted 6 lines
Move the
create_pcie()call after the creation of the acpi ged device since hotplug callbacks will soon be called on gpex realize and will require the acpi pcihp state to be initialized.The hacky thing is the root bus has not yet been created on
acpi_pcihp_init()call so it is set later after the gpex realize.can you elaborate on this, preferably with call expected call flows?
The way I'm understanding it is: because the GED and GPEX are created in
virt.c, so at the machine "level" (and so a machine hotplug handler is used instead of a device hotplug handler, like it's done in PIIX4 and ICH9 controller in the x86 machines), and they need to be created in that order because of dependecy of GPEX of GED, the flow is:
Quoted 7 lines
1)
create_acpi_ged()-> callsacpi_pcihp_init(), which by its turn will inspect the root bus to generate the ACPI code
2)create_pcie()-> just in realize the root bus will be createdand the sequence has to be 1 -> 2, because GED will be used in the GPEX callbacks on hotplug.
So here we're following a different design from the current one in x86, which handles the hotplug at the PCI controller "level".
... where this chicken & egg doesn't exist, I meant.
So one option would be follow the ICH9 design, i.e.,
the call to acpi_pcihp_init() would be from a gpex_root_class_realize() (to be created) and set in gpex_root_class_init(), like k->realize = gpex_root_class_realize. AcpiPciHpState would then be part of GPEXRootState struct. TYPE_GPEX_ROOT_DEVICE would also define the interfaces TYPE_HOTPLUG_HANDLER and TYPE_ACPI_DEVICE_IF, and gpex_root_class_init() will set callbacks on these interfaces, for instance:
hc->pre_plug = gpex_device_pre_plug_cb; hc->plug = gpex_device_plug_cb; hc->unplug_request = gpex_device_unplug_request_cb; hc->unplug = gpex_device_unplug_cb; hc->is_hotpluggable_bus = gpex_is_hotpluggable_bus;
adevc->send_event = gpex_root_acpi_send_event;
Cheers,
Gustavo
Quoted 160 lines
Cheers,
GustavoQuoted 155 lines
Quoted 56 lines
How to fix this chicken & egg issue?
Signed-off-by Eric Auger <[email protected]>---
v1 -> v2:
- useACPI_PCIHP_REGION_NAME
---
include/hw/arm/virt.h | 1 +
hw/arm/virt-acpi-build.c| 1 +
hw/arm/virt.c | 42 +++++++++++++++++++++++++++++++++++-----3 files changed, 39 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 +5
-0@@ -682,6 +682,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;@@ -693,12 +695,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; + }hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 706
Quoted 10 lines
hw/arm/virt.c +5
-3+ 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);Perhaps move out sbdev renaming into a separate patch, as it's not really related.
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 714
Quoted 6 lines
hw/arm/virt.c +6
-0+ if (vms->acpi_pcihp) { + AcpiGedState *acpi_ged_state = ACPI_GED(dev); + int i; + + i = sysbus_mmio_map_name(sbdev, ACPI_PCIHP_REGION_NAME, + vms->memmap[VIRT_ACPI_PCIHP].base);I don't like mix of old way (index based) above and new name based mapping, can we use the same, please?
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 715
Quoted 1 line
hw/arm/virt.c +1
-0+ assert(i >= 0);
g_assert(sysbus_mmio_map_name...)to get more meaning-full crash that is not compiled out.hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 717
Quoted 2 lines
hw/arm/virt.c +2
-0+ acpi_pcihp_init(OBJECT(dev), &acpi_ged_state->pcihp_state, + vms->bus, sysbus_mmio_get_region(sbdev, i), 0);hmm, looks broken..
region mapping must happen afteracpi_pcihp_init().if we after making
sysbus_mmio_map()sane and easier to use (which is a bit on tangent to this series).
We could feed sysbus owner device a memory map (ex: name based), and then use [pre_]plug handlers on sysbus to map children automatically.
That will alleviate need to do all mapping manually in every board. (frankly speaking it deserves its own series, with tree wide cleanup).As it is I'd use old index based approach like the rest. (unless you feel adventurous about sysbus refactoring)
Quoted 31 lines
hw/arm/virt.c +9
-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;@@ -1758,6 +1776,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);}
hw/arm/virt.c +2
-2@@ -2395,8 +2420,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);@@ -2405,6 +2428,15 @@ static void machvirt_init(MachineState *machine) create_gpio_devices(vms, VIRT_GPIO, sysmem); } + create_pcie(vms); +hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2441
Quoted 10 lines
hw/arm/virt.c +7
-0+ if (vms->acpi_dev) { + AcpiGedState *acpi_ged_state = ACPI_GED(vms->acpi_dev); + + acpi_ged_state = ACPI_GED(vms->acpi_dev); + acpi_ged_state->pcihp_state.root = vms->bus; + } + if (vms->secure && !vmc->no_secure_gpio) { create_gpio_devices(vms, VIRT_SECURE_GPIO, secure_sysmem); }I don't like pulling acpi_pcihp_init()/reset (and issues it causes) into board code, on x86 it's a part of host bridge device model.
The same should apply to GED device.The only thing board has to do is map regions into IO space like we do everywhere else.
with current code, may be add link<pci_bus> property to GED, and set it before GED realize in
create_acpi_ged(), then just follow existingsysbus_mmio_map()pattern.
Re: [PATCH v2 22/25] hw/arm/virt: Let virt support pci hotplug/unplug GED event
In reply to Gustavo RomeroQuoted 26 lines · On Tue, 27 May 2025 13:44:35 -0300 Gustavo Romero <[email protected]>…
Hi folks,
Quoted 8 lines · Igor Mammedov
Quoted 2 lines · On Tue, 27 May 2025 09:40:24 +0200 Eric Auger <[email protected]> wrote:
Set up the IO registers used to communicate between QEMU and ACPI.
Quoted 8 lines
Quoted 6 lines
Move the
create_pcie()call after the creation of the acpi ged device since hotplug callbacks will soon be called on gpex realize and will require the acpi pcihp state to be initialized.The hacky thing is the root bus has not yet been created on
acpi_pcihp_init()call so it is set later after the gpex realize.can you elaborate on this, preferably with call expected call flows?
The way I'm understanding it is: because the GED and GPEX are created in
virt.c, so at the machine "level" (and so a machine hotplug handler is used instead of a device hotplug handler, like it's done in PIIX4 and ICH9 controller in the x86 machines), and they need to be created in that order because of dependecy of GPEX of GED, the flow is:
Quoted 7 lines
1)
create_acpi_ged()-> callsacpi_pcihp_init(), which by its turn will inspect the root bus to generate the ACPI code
2)create_pcie()-> just in realize the root bus will be createdand the sequence has to be 1 -> 2, because GED will be used in the GPEX callbacks on hotplug.
So here we're following a different design from the current one in x86, which handles the hotplug at the PCI controller "level".
It should be fine to keep x86 design instead of making up a new one (unless we have to).
The difference between x86 and ARM is that acpi device happens to part of host bridge or its children. While in ARM virt, its separate devices (GPEX & GED).
From quick glance at the code, It should be fine to keep pcihp hw as part of GED. All it needs from host-bridge is root bus, the rest is paravirt ACPI magic wand.
Also we typically handle hotplug for devices that have parent bus we are using bus hotplug handler.
Only bus-less or complicated cases are orchestrated by machine. That's what is not this series, it probably has been overlooked since it's not in pcihp.c, so kinda not obvious.
for example see:
ich9_pm_init()
qbus_set_hotplug_handler()
where default native hotplug handler is overridden with ACPI one, and then later on, all coldplug bridges are picked up by acpi_pcihp_device_plug_cb() and got the same treatment.
So I'd suggest to try keeping current order with few changes
create pci
create ged (bus)
acpidev = object_new(GED) object_property_set_link(acpidev, 'pci_root_bus', bus) realize(acpidev)
and then in
ged_realize(dev)
acpi_pcihp_init()
qbus_set_hotplug_handler(root_bus, dev)
that's likely would do the job.
Quoted 167 lines
Cheers,
GustavoQuoted 162 lines
Quoted 59 lines
How to fix this chicken & egg issue?
Signed-off-by Eric Auger <[email protected]>---
v1 -> v2:
- useACPI_PCIHP_REGION_NAME--- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 1 + hw/arm/virt.c | 42 +++++++++++++++++++++++++++++++++++----- 3 files changed, 39 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 +6
-0@@ -682,6 +682,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 ;@@ -693,12 +695,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 ; + } +hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 708
Quoted 10 lines
hw/arm/virt.c +4
-3dev =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);Perhaps move out sbdev renaming into a separate patch, as it's not really related.
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 714
Quoted 6 lines
hw/arm/virt.c +6
-0+if (vms->acpi_pcihp) { +AcpiGedState *acpi_ged_state =ACPI_GED (dev); +int i; + + i =sysbus_mmio_map_name (sbdev,ACPI_PCIHP_REGION_NAME , + vms->memmap[VIRT_ACPI_PCIHP ].base);I don't like mix of old way (index based) above and new name based mapping, can we use the same, please?
hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 715
Quoted 1 line
hw/arm/virt.c +1
-0+assert (i >=0 );
g_assert(sysbus_mmio_map_name...)to get more meaning-full crash that is not compiled out.hw/arm/virt.c static inline DeviceState *create_acpi_ged(VirtMachineState *vms) · line 717
Quoted 2 lines
hw/arm/virt.c +2
-0+acpi_pcihp_init (OBJECT (dev), &acpi_ged_state->pcihp_state, + vms->bus,sysbus_mmio_get_region (sbdev, i),0 );hmm, looks broken..
region mapping must happen afteracpi_pcihp_init().if we after making
sysbus_mmio_map()sane and easier to use (which is a bit on tangent to this series).
We could feed sysbus owner device a memory map (ex: name based), and then use [pre_]plug handlers on sysbus to map children automatically.
That will alleviate need to do all mapping manually in every board. (frankly speaking it deserves its own series, with tree wide cleanup).As it is I'd use old index based approach like the rest. (unless you feel adventurous about sysbus refactoring)
Quoted 35 lines
hw/arm/virt.c +9
-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;@@ -1758,6 +1776,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);}hw/arm/virt.c +2
-2@@ -2395,8 +2420,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);@@ -2405,6 +2428,15 @@ static void machvirt_init(MachineState *machine)create_gpio_devices (vms,VIRT_GPIO , sysmem); } +create_pcie (vms); +hw/arm/virt.c static void machvirt_init(MachineState *machine) · line 2442
Quoted 10 lines
hw/arm/virt.c +7
-0+if (vms->acpi_dev) { +AcpiGedState *acpi_ged_state =ACPI_GED (vms->acpi_dev); + + acpi_ged_state =ACPI_GED (vms->acpi_dev); + acpi_ged_state->pcihp_state.root = vms->bus; + } +if (vms->secure && !vmc->no_secure_gpio) {create_gpio_devices (vms,VIRT_SECURE_GPIO , secure_sysmem); }I don't like pulling acpi_pcihp_init()/reset (and issues it causes) into board code, on x86 it's a part of host bridge device model.
The same should apply to GED device.The only thing board has to do is map regions into IO space like we do everywhere else.
with current code, may be add link<pci_bus> property to GED, and set it before GED realize in
create_acpi_ged(), then just follow existingsysbus_mmio_map()pattern.
PATCH v2 23/25 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" },
@@ -2973,6 +2974,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); + } } }
@@ -3002,6 +3008,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); + } } }
@@ -3051,6 +3065,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)));
@@ -3064,6 +3087,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)));
@@ -3074,11 +3106,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
PATCH v2 24/25 tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
In reply to Eric AugerFrom: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the _OSC method was modified, hence in the next patch of this series the blobs are updated accordingly.
---
[Eric] also added acpi-pcihp=off to test_acpi_aarch64_virt_tcg_numamem
--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
tests/qtest/bios-tables-test.c +9 -4
@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"
@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);
@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"
@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"
@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }
@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }
@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Signature · 1 line
2.49.0
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
Quoted 10 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>
it would be better to test whatever default we end up with. (like x86)
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
Hi Igor,
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.
Quoted 4 lines
Quoted 2 lines
Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>it would be better to test whatever default we end up with. (like x86)
See my question on patch 2's comment. We intended to have tests for both modes (legacy and acpi pcihp). Gustavo added some new tests for the new default, namely acpi pcihp. Now I did not really understand your point about keeping legacy mode as a default.
Thanks
Eric
Quoted 74 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
Quoted 16 lines · On Wed, 28 May 2025 11:48:20 +0200 Eric Auger <[email protected]> wrote:
Hi Igor,
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>
Quoted 7 lines
Quoted 2 lines
it would be better to test whatever default we end up with. (like x86)
See my question on patch 2's comment. We intended to have tests for both modes (legacy and acpi pcihp). Gustavo added some new tests for the new default, namely acpi pcihp. Now I did not really understand your point about keeping legacy mode as a default.
default legacy wrt tests are orthogonal things.
Just decide what default should be in #2 and then make sure existing tests work with that.
Default (majority) tests shouldn't include CLI option a for a feature 'acpi-pcihp', only legacy tests should have it.
Given bios-tables-test is heavy load on CI for x86 we have only few test cases to check no pcihp (legacy), the same should be done for ARM.
Then on top add a few acpi hotplug tests to snapshot DSDT with hotplug hierarchy built in.
ex: test_acpi_piix4_tcg_bridge or test_acpi_piix4_no_acpi_pci_hotplug.
Quoted 79 lines
Thanks
Eric
Quoted 74 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
In reply to Eric AugerHi Eric,
Quoted 16 lines · Eric Auger
Hi Igor,
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>
Quoted 7 lines
Quoted 2 lines
it would be better to test whatever default we end up with. (like x86)
See my question on patch 2's comment. We intended to have tests for both modes (legacy and acpi pcihp). Gustavo added some new tests for the new default, namely acpi pcihp. Now I did not really understand your point about keeping legacy mode as a default.
I _think_ I understood what Igor is suggesting. In a separate series, that I've kept in a github branch to not add noise here, I removed the test for acpi-pcihp=on and just added one for acpi-pcihp=off after we adjust the blobs for the _OSC change. I added the test before acpi-pcihp=on becomes the default, since if everything is ok the native test must continue to work after acpi-pcihp=on becomes the default, as Igor said.
Anyways, please see my last reply to Igor in this thread (for some reason I can't find the reply either in qemu-devel@ or qemu-arm@)... I'm pasting below the main part just in case (the branch and the overview for the tests location in the series):
https://github.com/gromero/qemu/commits/v2_20250527_eric_auger_redhat_com/
3c302f7222 tests/qtest/bios-tables-test: Update DSDT blobs #1c (update blob) \ 671f15f470 hw/arm/virt: Use ACPI PCI hotplug by default #1b (modify default) | acpi-pcihp=on 9468f730e1 tests/qtest/bios-tables-test: Prepare for changes in the DSDT table #1a (whitelist) /
c9ec0e0226 hw/arm/virt: Plug pcihp hotplug/hotunplug callbacksdc44749a34 hw/arm/virt: Let virt support pci hotplug/unplug GED event f667079260 hw/core/sysbus: Introduce sysbus_mmio_map_name() helper 46731e563b hw/acpi/ged: Support migration of AcpiPciHpState4fa7b0e0f6 hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation 587b001876 hw/acpi/ged: Prepare the device to react to PCI hotplug events b55183d128 hw/arm/virt-acpi-build: Modify the DSDT ACPI table to enable ACPI PCI hotplug fe4c96b384 hw/i386/acpi-build: Move aml_pci_edsm to a generic place 010c50dbc7 hw/i386/acpi-build: Introduce and use acpi_get_pci_host 5a1be727e6 hw/i386/acpi-build: Move build_append_pci_bus_devices/pcihp_slots to pcihp 14a172e192 hw/i386/acpi-build: Move build_append_notification_callback to pcihp 5110ae8874 hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug 82c2aef672 hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
6372fe7eef qtest/bios-tables-test: Update DSDT 'noacpipcihp' variant blob #2 (blob update for test), part 2 of 2 (update blob) ] New PCIe native test 6fb29ba18d tests/qtest/bios-tables-test: Add aarch64 PCIe native hotplug test #2 (pcie native hp test), part 1 of 2 (whitelist) / 12c63a505e tests/qtest/bios-tables-test: Update DSDT blobs after GPEX _OSC change Patch 10/25 in this series (update blob) \ 779bd47749 hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method Patch 9/25 in this series (modify default) | _OSC change f260fd59c1 tests/qtest/bios-tables-test: Prepare for changes in the DSDT table Patch 8/25 in this series (whitelist) /
b000677fd9 hw/i386/acpi-build: Turn build_q35_osc_method into a generic method a72f87b634 hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex 77a87b6ba3 hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation 67e4dc2e7b hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc b89e69da54 hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp 74f1080a74 hw/arm/virt: Introduce machine state acpi pcihp flags and props 1048082f33 hw/i386/acpi-build: Make aml_pci_device_dsm() static
Feel free to cherry-pick the tests and adjust them as you did before.
I'll be off this week returning on June 9.
Cheers,
Gustavo
Quoted 78 lines
Thanks
Eric
Quoted 74 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
In reply to Igor MammedovHi Igor,
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>it would be better to test whatever default we end up with. (like x86)
hmm maybe there is a confusion here, Igor. We are actually planning what you said. This patch and the other two in this series related to the bios-tables-test (i.e., patches 8/25 and 10/25) are for actually making the current (legacy) test pass, since the new default as per this series will be acpi-pcihp=on. That's why here we're adapting the current test here to have acpi-pcihp=off.
The new test that will test for acpi-pcihp=on (the new default) is not in this series and we decided to merge it separate. It's in the patch 4/5 and 5/5 of the follow series:
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05828.html 4/5
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05827.html 5/5
Cheers,
Gustavo
Quoted 75 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
Quoted 14 lines · On Wed, 28 May 2025 09:41:15 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 11 lines · Igor Mammedov
Quoted 8 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>it would be better to test whatever default we end up with. (like x86)
hmm maybe there is a confusion here, Igor. We are actually planning what you
perhaps, see my reply to Eric about my expectations wrt tests.
(i.e. default tests shouldn't have any explicit CLI options,
instead it should follow whitelist blobs/set new default patch/update blobs pattern)
Quoted 91 lines
said. This patch and the other two in this series related to the bios-tables-test (i.e., patches 8/25 and 10/25) are for actually making the current (legacy) test pass, since the new default as per this series will be acpi-pcihp=on. That's why here we're adapting the current test here to have acpi-pcihp=off.
The new test that will test for acpi-pcihp=on (the new default) is not in this series and we decided to merge it separate. It's in the patch 4/5 and 5/5 of the follow series:
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05828.html 4/5
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05827.html 5/5Cheers,
GustavoQuoted 75 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
Hi Igor,
Quoted 20 lines · Igor Mammedov
Quoted 17 lines · On Wed, 28 May 2025 09:41:15 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 14 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
it would be better to test whatever default we end up with. (like x86)
hmm maybe there is a confusion here, Igor. We are actually planning what you
perhaps, see my reply to Eric about my expectations wrt tests.
Yip, I read it before my reply here.
Quoted 2 lines
(i.e. default tests shouldn't have any explicit CLI options,
instead it should follow whitelist blobs/set new default patch/update blobs pattern)
I see. I agree with that. But this patch is not about the new test. The new test is _not_ in this series. Patches 8/25, 10/25, and 24/25 are _not_ about the new test but about adapting the _legacy tests_ (native acpi) to the situation when ACPI HP becomes the default, because this series makes acpi-pcihp=on the default, hence the CLI option "acpi-pcihp=off" added to them. An update to the blobs are also necessary because of the change in _OSC method, even when acpi-pcihp=off.
Quoted 7 lines
Quoted 7 lines
said. This patch and the other two in this series related to the bios-tables-test (i.e., patches 8/25 and 10/25) are for actually making the current (legacy) test pass, since the new default as per this series will be acpi-pcihp=on. That's why here we're adapting the current test here to have acpi-pcihp=off.
The new test that will test for acpi-pcihp=on (the new default) is not in this series and we decided to merge it separate. It's in the patch 4/5 and 5/5 of the follow series:
We're doing the "blobs/set new default patch/update blobs pattern" in the new test, which we can merge later, once this series is merged, no? The step "set new default" then will not be necessary because the new test will be merged separate, after this series, so when acpi-pcihp=on is already the default.
Please note that although we're using acpi-pcihp=on in the new test, it's not necessary, we can dropped this option, making it implicit as you say, and it will work. This is the new test:
Quoted 2 lines
Thus, there are to "acts" of modifying the bios-tables-test:
1) Adapt the current tests to when acpi-pcihp=on becomes the default (hence the addition to them of "acpi-pcihp=off". There is also the need to update the blobs, but it's because of the _OSC method change in DSDT table, which will change anyways, even with "acpi-pcihp=off¨, hence the need for patch 10/25 in this series. This is _done is this series_.
2) Add a new test for testing the default (i.e. acpi-pcihp-on). It follows what you're saying above: "follow whitelist blobs/set new default patch/update blobs pattern", because we can drop the acpi-pcihp-on option from the CLI in this test without any prejudice to test. While the step "set new default patch" was actually done in 1).
Cheers,
Gustavo
Quoted 84 lines
Quoted 83 lines
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05828.html 4/5
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05827.html 5/5Cheers,
GustavoQuoted 75 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
Quoted 61 lines · On Wed, 28 May 2025 12:04:26 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 20 lines · Igor Mammedov
Quoted 17 lines · On Wed, 28 May 2025 09:41:15 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 14 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
it would be better to test whatever default we end up with. (like x86)
hmm maybe there is a confusion here, Igor. We are actually planning what you
perhaps, see my reply to Eric about my expectations wrt tests.
Yip, I read it before my reply here.
Quoted 2 lines
(i.e. default tests shouldn't have any explicit CLI options,
instead it should follow whitelist blobs/set new default patch/update blobs pattern)I see. I agree with that. But this patch is not about the new test. The new test is _not_ in this series. Patches 8/25, 10/25, and 24/25 are _not_ about the new test but about adapting the
_legacytests_(native acpi) to the situation when ACPI HP becomes the default, because this series makes acpi-pcihp=on the default, hence the CLI option "acpi-pcihp=off" added to them. An update to the blobs are also necessary because of the change in_OSCmethod, even when acpi-pcihp=off.Quoted 7 lines
Quoted 7 lines
said. This patch and the other two in this series related to the bios-tables-test (i.e., patches 8/25 and 10/25) are for actually making the current (legacy) test pass, since the new default as per this series will be acpi-pcihp=on. That's why here we're adapting the current test here to have acpi-pcihp=off.
The new test that will test for acpi-pcihp=on (the new default) is not in this series and we decided to merge it separate. It's in the patch 4/5 and 5/5 of the follow series:
We're doing the "blobs/set new default patch/update blobs pattern" in the new test, which we can merge later, once this series is merged, no? The step "set new default" then will not be necessary because the new test will be merged separate, after this series, so when acpi-pcihp=on is already the default.
Please note that although we're using acpi-pcihp=on in the new test, it's not necessary, we can dropped this option, making it implicit as you say, and it will work. This is the new test:
Quoted 8 lines
Quoted 2 lines
Thus, there are to "acts" of modifying the bios-tables-test:
1) Adapt the current tests to when acpi-pcihp=on becomes the default (hence the addition to them of "acpi-pcihp=off".
that's what I disagree with.
1) Instead adapting majority of tests to legacy before switching defaults, just do whitelist/modify default/update so all of tests run with new default.
and then
Quoted 10 lines
There is also the need to update the blobs, but it's because
of the_OSCmethod change in DSDT table, which will change anyways, even with "acpi-pcihp=off¨, hence the need for patch 10/25 in this series. This is_doneis thisseries_.2) Add a new test for testing the default (i.e. acpi-pcihp-on). It follows what you're saying above: "follow whitelist blobs/set new default patch/update blobs pattern", because we can drop the acpi-pcihp-on option from the CLI in this test without any prejudice to test. While the step "set new default patch" was actually done in 1).
2) add a separate test case for native pcie hoplug (preferably within this series)
3) even better would be to add #2 before #1 (right after 10/25), this way will guarantee that old native hotplug tables stay the same regardless of followup patches that add ACPI pcihp aml.
Quoted 88 lines
Cheers,
GustavoQuoted 84 lines
Quoted 83 lines
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05828.html 4/5
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05827.html 5/5Cheers,
GustavoQuoted 75 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
Hi Igor and Eric,
Quoted 92 lines · Igor Mammedov
Quoted 61 lines · On Wed, 28 May 2025 12:04:26 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 20 lines · Igor Mammedov
Quoted 17 lines · On Wed, 28 May 2025 09:41:15 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 14 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
it would be better to test whatever default we end up with. (like x86)
hmm maybe there is a confusion here, Igor. We are actually planning what you
perhaps, see my reply to Eric about my expectations wrt tests.
Yip, I read it before my reply here.
Quoted 2 lines
(i.e. default tests shouldn't have any explicit CLI options,
instead it should follow whitelist blobs/set new default patch/update blobs pattern)I see. I agree with that. But this patch is not about the new test. The new test is _not_ in this series. Patches 8/25, 10/25, and 24/25 are _not_ about the new test but about adapting the
_legacytests_(native acpi) to the situation when ACPI HP becomes the default, because this series makes acpi-pcihp=on the default, hence the CLI option "acpi-pcihp=off" added to them. An update to the blobs are also necessary because of the change in_OSCmethod, even when acpi-pcihp=off.Quoted 7 lines
Quoted 7 lines
said. This patch and the other two in this series related to the bios-tables-test (i.e., patches 8/25 and 10/25) are for actually making the current (legacy) test pass, since the new default as per this series will be acpi-pcihp=on. That's why here we're adapting the current test here to have acpi-pcihp=off.
The new test that will test for acpi-pcihp=on (the new default) is not in this series and we decided to merge it separate. It's in the patch 4/5 and 5/5 of the follow series:
We're doing the "blobs/set new default patch/update blobs pattern" in the new test, which we can merge later, once this series is merged, no? The step "set new default" then will not be necessary because the new test will be merged separate, after this series, so when acpi-pcihp=on is already the default.
Please note that although we're using acpi-pcihp=on in the new test, it's not necessary, we can dropped this option, making it implicit as you say, and it will work. This is the new test:
Quoted 8 lines
Quoted 2 lines
Thus, there are to "acts" of modifying the bios-tables-test:
1) Adapt the current tests to when acpi-pcihp=on becomes the default (hence the addition to them of "acpi-pcihp=off".
that's what I disagree with.
1) Instead adapting majority of tests to legacy before switching defaults, just do whitelist/modify default/update so all of tests run with new default.
and then
Quoted 10 lines
There is also the need to update the blobs, but it's because
of the_OSCmethod change in DSDT table, which will change anyways, even with "acpi-pcihp=off¨, hence the need for patch 10/25 in this series. This is_doneis thisseries_.2) Add a new test for testing the default (i.e. acpi-pcihp-on). It follows what you're saying above: "follow whitelist blobs/set new default patch/update blobs pattern", because we can drop the acpi-pcihp-on option from the CLI in this test without any prejudice to test. While the step "set new default patch" was actually done in 1).
Quoted 5 lines
2) add a separate test case for native pcie hoplug (preferably within this series)
3) even better would be to add #2 before #1 (right after 10/25), this way will guarantee that old native hotplug tables stay the same regardless of followup patches that add ACPI pcihp aml.
Got it now, hopefully... :)
OK, I'm trying to follow what you recommended in 3). I've pushed a series to:
https://github.com/gromero/qemu/commits/v2_20250527_eric_auger_redhat_com/
So, I understand we will need to add/update the blobs at three times, 2 times because of the changes in the DSDT generation (_OSC changes and when acpi-pci=on) and an additional one because of the new PCIe native hotplug test.
I dropped this patch (Patch 24/25) from the series.
So the overview of the organization would be the following:
3c302f7222 tests/qtest/bios-tables-test: Update DSDT blobs #1c (update blob) \ 671f15f470 hw/arm/virt: Use ACPI PCI hotplug by default #1b (modify default) |--- acpi-pcihp=on 9468f730e1 tests/qtest/bios-tables-test: Prepare for changes in the DSDT table #1a (whitelist) /
c9ec0e0226 hw/arm/virt: Plug pcihp hotplug/hotunplug callbacksdc44749a34 hw/arm/virt: Let virt support pci hotplug/unplug GED event f667079260 hw/core/sysbus: Introduce sysbus_mmio_map_name() helper 46731e563b hw/acpi/ged: Support migration of AcpiPciHpState4fa7b0e0f6 hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation 587b001876 hw/acpi/ged: Prepare the device to react to PCI hotplug events b55183d128 hw/arm/virt-acpi-build: Modify the DSDT ACPI table to enable ACPI PCI hotplug fe4c96b384 hw/i386/acpi-build: Move aml_pci_edsm to a generic place 010c50dbc7 hw/i386/acpi-build: Introduce and use acpi_get_pci_host 5a1be727e6 hw/i386/acpi-build: Move build_append_pci_bus_devices/pcihp_slots to pcihp 14a172e192 hw/i386/acpi-build: Move build_append_notification_callback to pcihp 5110ae8874 hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug 82c2aef672 hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
6372fe7eef qtest/bios-tables-test: Update DSDT 'noacpipcihp' variant blob #2 (blob update for test), part 2 of 2 (update blob) ]--- New PCIe native test 6fb29ba18d tests/qtest/bios-tables-test: Add aarch64 PCIe native hotplug test #2 (pcie native hp test), part 1 of 2 (whitelist) / 12c63a505e tests/qtest/bios-tables-test: Update DSDT blobs after GPEX _OSC change Patch 10/25 in this series (update blob) \ 779bd47749 hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method Patch 9/25 in this series (modify default) |--- _OSC change f260fd59c1 tests/qtest/bios-tables-test: Prepare for changes in the DSDT table Patch 8/25 in this series (whitelist) /
b000677fd9 hw/i386/acpi-build: Turn build_q35_osc_method into a generic method a72f87b634 hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex 77a87b6ba3 hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation 67e4dc2e7b hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc b89e69da54 hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp 74f1080a74 hw/arm/virt: Introduce machine state acpi pcihp flags and props 1048082f33 hw/i386/acpi-build: Make aml_pci_device_dsm() static
See notes on the right for when the blobs are updated or added in the series. The new test for PCIe native hotplug (I prefer not calling it legacy, since it's not really legacy; it's just an alternative better in some scenarios, specially in virtualization) is now in the series (#2), "right after 10/25".
Is something like that that you want?
Cheers,
Gustavo
Quoted 90 lines
Quoted 89 lines
Cheers,
GustavoQuoted 84 lines
Quoted 83 lines
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05828.html 4/5
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05827.html 5/5Cheers,
GustavoQuoted 75 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
In reply to Igor MammedovHi Igor and Eric,
I'm sending again this to the mailing list since it seems the first one got lost... I can't find it either in qemu-devel@ or in qemu-arm@ :(
Quoted 92 lines · Igor Mammedov
Quoted 61 lines · On Wed, 28 May 2025 12:04:26 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 20 lines · Igor Mammedov
Quoted 17 lines · On Wed, 28 May 2025 09:41:15 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 14 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
it would be better to test whatever default we end up with. (like x86)
hmm maybe there is a confusion here, Igor. We are actually planning what you
perhaps, see my reply to Eric about my expectations wrt tests.
Yip, I read it before my reply here.
Quoted 2 lines
(i.e. default tests shouldn't have any explicit CLI options,
instead it should follow whitelist blobs/set new default patch/update blobs pattern)I see. I agree with that. But this patch is not about the new test. The new test is _not_ in this series. Patches 8/25, 10/25, and 24/25 are _not_ about the new test but about adapting the
_legacytests_(native acpi) to the situation when ACPI HP becomes the default, because this series makes acpi-pcihp=on the default, hence the CLI option "acpi-pcihp=off" added to them. An update to the blobs are also necessary because of the change in_OSCmethod, even when acpi-pcihp=off.Quoted 7 lines
Quoted 7 lines
said. This patch and the other two in this series related to the bios-tables-test (i.e., patches 8/25 and 10/25) are for actually making the current (legacy) test pass, since the new default as per this series will be acpi-pcihp=on. That's why here we're adapting the current test here to have acpi-pcihp=off.
The new test that will test for acpi-pcihp=on (the new default) is not in this series and we decided to merge it separate. It's in the patch 4/5 and 5/5 of the follow series:
We're doing the "blobs/set new default patch/update blobs pattern" in the new test, which we can merge later, once this series is merged, no? The step "set new default" then will not be necessary because the new test will be merged separate, after this series, so when acpi-pcihp=on is already the default.
Please note that although we're using acpi-pcihp=on in the new test, it's not necessary, we can dropped this option, making it implicit as you say, and it will work. This is the new test:
Quoted 8 lines
Quoted 2 lines
Thus, there are to "acts" of modifying the bios-tables-test:
1) Adapt the current tests to when acpi-pcihp=on becomes the default (hence the addition to them of "acpi-pcihp=off".
that's what I disagree with.
1) Instead adapting majority of tests to legacy before switching defaults, just do whitelist/modify default/update so all of tests run with new default.
and then
Quoted 10 lines
There is also the need to update the blobs, but it's because
of the_OSCmethod change in DSDT table, which will change anyways, even with "acpi-pcihp=off¨, hence the need for patch 10/25 in this series. This is_doneis thisseries_.2) Add a new test for testing the default (i.e. acpi-pcihp-on). It follows what you're saying above: "follow whitelist blobs/set new default patch/update blobs pattern", because we can drop the acpi-pcihp-on option from the CLI in this test without any prejudice to test. While the step "set new default patch" was actually done in 1).
Quoted 5 lines
2) add a separate test case for native pcie hoplug (preferably within this series)
3) even better would be to add #2 before #1 (right after 10/25), this way will guarantee that old native hotplug tables stay the same regardless of followup patches that add ACPI pcihp aml.
Got it now, hopefully... 🙂
OK, I'm trying to follow what you recommended in 3). I've pushed a series to:
https://github.com/gromero/qemu/commits/v2_20250527_eric_auger_redhat_com/
So, I understand we will need to add/update the blobs at three times, 2 times because of the changes in the DSDT generation (_OSC changes and when acpi-pci=on) and an additional one because of the new PCIe native hotplug test.
I dropped this patch (Patch 24/25) from the series.
So the overview of the organization would be the following:
3c302f7222 tests/qtest/bios-tables-test: Update DSDT blobs #1c (update blob) \ 671f15f470 hw/arm/virt: Use ACPI PCI hotplug by default #1b (modify default) |--- acpi-pcihp=on 9468f730e1 tests/qtest/bios-tables-test: Prepare for changes in the DSDT table #1a (whitelist) /
c9ec0e0226 hw/arm/virt: Plug pcihp hotplug/hotunplug callbacksdc44749a34 hw/arm/virt: Let virt support pci hotplug/unplug GED event f667079260 hw/core/sysbus: Introduce sysbus_mmio_map_name() helper 46731e563b hw/acpi/ged: Support migration of AcpiPciHpState4fa7b0e0f6 hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation 587b001876 hw/acpi/ged: Prepare the device to react to PCI hotplug events b55183d128 hw/arm/virt-acpi-build: Modify the DSDT ACPI table to enable ACPI PCI hotplug fe4c96b384 hw/i386/acpi-build: Move aml_pci_edsm to a generic place 010c50dbc7 hw/i386/acpi-build: Introduce and use acpi_get_pci_host 5a1be727e6 hw/i386/acpi-build: Move build_append_pci_bus_devices/pcihp_slots to pcihp 14a172e192 hw/i386/acpi-build: Move build_append_notification_callback to pcihp 5110ae8874 hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug 82c2aef672 hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
6372fe7eef qtest/bios-tables-test: Update DSDT 'noacpipcihp' variant blob #2 (blob update for test), part 2 of 2 (update blob) ]--- New PCIe native test 6fb29ba18d tests/qtest/bios-tables-test: Add aarch64 PCIe native hotplug test #2 (pcie native hp test), part 1 of 2 (whitelist) / 12c63a505e tests/qtest/bios-tables-test: Update DSDT blobs after GPEX _OSC change Patch 10/25 in this series (update blob) \ 779bd47749 hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method Patch 9/25 in this series (modify default) |--- _OSC change f260fd59c1 tests/qtest/bios-tables-test: Prepare for changes in the DSDT table Patch 8/25 in this series (whitelist) /
b000677fd9 hw/i386/acpi-build: Turn build_q35_osc_method into a generic method a72f87b634 hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex 77a87b6ba3 hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation 67e4dc2e7b hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc b89e69da54 hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp 74f1080a74 hw/arm/virt: Introduce machine state acpi pcihp flags and props 1048082f33 hw/i386/acpi-build: Make aml_pci_device_dsm() static
See notes on the right for when the blobs are updated or added in the series. The new test for PCIe native hotplug (I prefer not calling it legacy, since it's not really legacy; it's just an alternative better in some scenarios, specially in virtualization) is now in the series (#2), "right after 10/25".
Is something like that that you want?
Cheers,
Gustavo
Quoted 90 lines
Quoted 89 lines
Cheers,
GustavoQuoted 84 lines
Quoted 83 lines
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05828.html 4/5
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05827.html 5/5Cheers,
GustavoQuoted 75 lines
Quoted 74 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem--- tests/qtest/bios-tables-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +9
-4@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant =".memhp" ; -test_acpi_one (" -machine nvdimm=on" +test_acpi_one (" -machine nvdimm=on,acpi-pcihp=off" " -cpu cortex-a57" " -m 256M,slots=3,maxmem=1G" " -object memory-backend-ram,id=ram0,size=128M"@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant =".numamem" ; -test_acpi_one (" -cpu cortex-a57" +test_acpi_one (" -machine acpi-pcihp=off" +" -cpu cortex-a57" " -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0" , &data);@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant =".pxb" ; -test_acpi_one (" -device pcie-root-port,chassis=1,id=pci.1" +test_acpi_one (" -machine acpi-pcihp=off" +" -device pcie-root-port,chassis=1,id=pci.1" " -device virtio-scsi-pci,id=scsi0,bus=pci.1" " -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant =".acpihmatvirt" ; -test_acpi_one (" -machine hmat=on" +test_acpi_one (" -machine hmat=on,acpi-pcihp=off" " -cpu cortex-a57" " -smp 4,sockets=2" " -m 384M"@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed =2900 ; data.smbios_cpu_curr_speed =2700 ;test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smbios type=4,max-speed=2900,current-speed=2700" , &data);free_test_data (&data); }@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-smp sockets=1,clusters=2,cores=2,threads=2" , &data);free_test_data (&data); }@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one ("-cpu cortex-a57 " +"-machine acpi-pcihp=off " "-device virtio-iommu-pci" , &data);free_test_data (&data); }
Re: [PATCH v2 24/25] tests/qtest/bios-tables-test: Keep ACPI PCI hotplug off
Hi Igor,
Quoted 145 lines · Gustavo Romero
Hi Igor and Eric,
I'm sending again this to the mailing list since it seems the first one got lost... I can't find it either in qemu-devel@ or in qemu-arm@ :(
Quoted 89 lines · Igor Mammedov
Quoted 59 lines · On Wed, 28 May 2025 12:04:26 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 18 lines · Igor Mammedov
Quoted 16 lines · On Wed, 28 May 2025 09:41:15 -0300 Gustavo Romero <[email protected]>…
Hi Igor,
Quoted 13 lines · Igor Mammedov
Quoted 10 lines · On Tue, 27 May 2025 09:40:26 +0200 Eric Auger <[email protected]> wrote:
From: Gustavo Romero <[email protected]>
ACPI PCI hotplug is now turned on by default so we need to change the existing tests to keep it off. However, even setting the ACPI PCI hotplug off in the existing tests, there will be changes in the ACPI tables because the
_OSCmethod was modified, hence in the next patch of this series the blobs are updated accordingly.Signed-off-by Gustavo Romero <[email protected]>Signed-off-by Eric Auger <[email protected]>Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
it would be better to test whatever default we end up with. (like x86)
hmm maybe there is a confusion here, Igor. We are actually planning what you
perhaps, see my reply to Eric about my expectations wrt tests.
Yip, I read it before my reply here.
Quoted 2 lines
(i.e. default tests shouldn't have any explicit CLI options,
instead it should follow whitelist blobs/set new default patch/update blobs pattern)I see. I agree with that. But this patch is not about the new test. The new test is _not_ in this series. Patches 8/25, 10/25, and 24/25 are _not_ about the new test but about adapting the
_legacytests_(native acpi) to the situation when ACPI HP becomes the default, because this series makes acpi-pcihp=on the default, hence the CLI option "acpi-pcihp=off" added to them. An update to the blobs are also necessary because of the change in_OSCmethod, even when acpi-pcihp=off.Quoted 7 lines
Quoted 7 lines
said. This patch and the other two in this series related to the bios-tables-test (i.e., patches 8/25 and 10/25) are for actually making the current (legacy) test pass, since the new default as per this series will be acpi-pcihp=on. That's why here we're adapting the current test here to have acpi-pcihp=off.
The new test that will test for acpi-pcihp=on (the new default) is not in this series and we decided to merge it separate. It's in the patch 4/5 and 5/5 of the follow series:
We're doing the "blobs/set new default patch/update blobs pattern" in the new test, which we can merge later, once this series is merged, no? The step "set new default" then will not be necessary because the new test will be merged separate, after this series, so when acpi-pcihp=on is already the default.
Please note that although we're using acpi-pcihp=on in the new test, it's not necessary, we can dropped this option, making it implicit as you say, and it will work. This is the new test:
Quoted 8 lines
Quoted 2 lines
Thus, there are to "acts" of modifying the bios-tables-test:
1) Adapt the current tests to when acpi-pcihp=on becomes the default (hence the addition to them of "acpi-pcihp=off".
that's what I disagree with.
1) Instead adapting majority of tests to legacy before switching defaults, just do whitelist/modify default/update so all of tests run with new default.
and then
Quoted 9 lines
There is also the need to update the blobs, but it's because
of the_OSCmethod change in DSDT table, which will change anyways, even with "acpi-pcihp=off¨, hence the need for patch 10/25 in this series. This is_doneis thisseries_.2) Add a new test for testing the default (i.e. acpi-pcihp-on). It follows what you're saying above: "follow whitelist blobs/set new default patch/update blobs pattern", because we can drop the acpi-pcihp-on option from the CLI in this test without any prejudice to test. While the step "set new default patch" was actually done in 1).
Quoted 5 lines
2) add a separate test case for native pcie hoplug (preferably within this series)
3) even better would be to add #2 before #1 (right after 10/25), this way will guarantee that old native hotplug tables stay the same regardless of followup patches that add ACPI pcihp aml.
Got it now, hopefully... 🙂
OK, I'm trying to follow what you recommended in 3). I've pushed a series to:
https://github.com/gromero/qemu/commits/v2_20250527_eric_auger_redhat_com/
So, I understand we will need to add/update the blobs at three times, 2 times because of the changes in the DSDT generation (
_OSCchanges and when acpi-pci=on) and an additional one because of the new PCIe native hotplug test.I dropped this patch (Patch 24/25) from the series.
So the overview of the organization would be the following:
3c302f7222tests/qtest/bios-tables-test: Update DSDT blobs #1c (update blob) \671f15f470hw/arm/virt: Use ACPI PCI hotplug by default #1b (modify default) |--- acpi-pcihp=on9468f730e1tests/qtest/bios-tables-test: Prepare for changes in the DSDT table #1a (whitelist) /c9ec0e0226hw/arm/virt: Plug pcihp hotplug/hotunplug callbacksdc44749a34hw/arm/virt: Let virt support pci hotplug/unplug GED eventf667079260hw/core/sysbus: Introducesysbus_mmio_map_name()helper46731e563bhw/acpi/ged: Support migration of AcpiPciHpState4fa7b0e0f6hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation587b001876hw/acpi/ged: Prepare the device to react to PCI hotplug eventsb55183d128hw/arm/virt-acpi-build: Modify the DSDT ACPI table to enable ACPI PCI hotplugfe4c96b384hw/i386/acpi-build: Moveaml_pci_edsmto a generic place010c50dbc7hw/i386/acpi-build: Introduce and useacpi_get_pci_host5a1be727e6hw/i386/acpi-build: Move build_append_pci_bus_devices/pcihp_slots to pcihp14a172e192hw/i386/acpi-build: Movebuild_append_notification_callbackto pcihp5110ae8874hw/acpi/pcihp: Add an AmlRegionSpace arg tobuild_acpi_pci_hotplug82c2aef672hw/i386/acpi-build: Introducebuild_append_pcihp_resources()helper6372fe7eefqtest/bios-tables-test: Update DSDT 'noacpipcihp' variant blob #2 (blob update for test), part 2 of 2 (update blob) ]--- New PCIe native test6fb29ba18dtests/qtest/bios-tables-test: Add aarch64 PCIe native hotplug test #2 (pcie native hp test), part 1 of 2 (whitelist) /12c63a505etests/qtest/bios-tables-test: Update DSDT blobs after GPEX_OSCchange Patch 10/25 in this series (update blob) \779bd47749hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method Patch 9/25 in this series (modify default) |---_OSCchangef260fd59c1tests/qtest/bios-tables-test: Prepare for changes in the DSDT table Patch 8/25 in this series (whitelist) /b000677fd9hw/i386/acpi-build: Turnbuild_q35_osc_methodinto a generic methoda72f87b634hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex77a87b6ba3hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation67e4dc2e7bhw/pci-host/gpex-acpi: Addnative_pci_hotplugarg toacpi_dsdt_add_pci_oscb89e69da54hw/acpi: Rename and movebuild_x86_acpi_pci_hotplugto pcihp74f1080a74hw/arm/virt: Introduce machine state acpi pcihp flags and props1048082f33hw/i386/acpi-build: Makeaml_pci_device_dsm()static
Quoted 6 lines
See notes on the right for when the blobs are updated or added in the series. The new test for PCIe native hotplug (I prefer not calling it legacy, since it's not really legacy; it's just an alternative better in some scenarios, specially in virtualization) is now in the series (#2), "right after 10/25".
Is something like that that you want?
Igor, just a friendly ping on it. It would be quite helpful for us if you could confirm I'm following what you recommended regarding the tests for this series.
Thanks,
Gustavo
Quoted 85 lines
Cheers,
GustavoQuoted 80 lines
Quoted 79 lines
Cheers,
GustavoQuoted 74 lines
Quoted 74 lines
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05828.html 4/5
https://mail.gnu.org/archive/html/qemu-devel/2025-05/msg05827.html 5/5Cheers,
GustavoQuoted 68 lines
Quoted 68 lines
---
[Eric] also added acpi-pcihp=off to
test_acpi_aarch64_virt_tcg_numamem
---
tests/qtest/bios-tables-test.c| 13 +++++++++----1 file changed, 9 insertions(+), 4 deletions(-)tests/qtest/bios-tables-test.c +1
-1@@ -1626,7 +1626,7 @@ static void test_acpi_aarch64_virt_tcg_memhp(void) }; data.variant = ".memhp"; - test_acpi_one(" -machine nvdimm=on" + test_acpi_one(" -machine nvdimm=on,acpi-pcihp=off"" -cpu cortex-a57"
" -m 256M,slots=3,maxmem=1G"
" -object memory-backend-ram,id=ram0,size=128M"tests/qtest/bios-tables-test.c +2
-1@@ -1747,7 +1747,8 @@ static void test_acpi_aarch64_virt_tcg_numamem(void) }; data.variant = ".numamem"; - test_acpi_one(" -cpu cortex-a57" + test_acpi_one(" -machine acpi-pcihp=off" + " -cpu cortex-a57"" -object memory-backend-ram,id=ram0,size=128M" " -numa node,memdev=ram0",
&data);tests/qtest/bios-tables-test.c +2
-1@@ -1775,7 +1776,8 @@ static void test_acpi_aarch64_virt_tcg_pxb(void)* to solve the conflicts. */ data.variant = ".pxb"; - test_acpi_one(" -device pcie-root-port,chassis=1,id=pci.1" + test_acpi_one(" -machine acpi-pcihp=off" + " -device pcie-root-port,chassis=1,id=pci.1"" -device virtio-scsi-pci,id=scsi0,bus=pci.1"
" -drive file=" "tests/data/uefi-boot-images/bios-tables-test.aarch64.iso.qcow2,"tests/qtest/bios-tables-test.c +1
-1@@ -1846,7 +1848,7 @@ static void test_acpi_aarch64_virt_tcg_acpi_hmat(void) data.variant = ".acpihmatvirt"; - test_acpi_one(" -machine hmat=on" + test_acpi_one(" -machine hmat=on,acpi-pcihp=off"" -cpu cortex-a57"
" -smp 4,sockets=2"
" -m 384M"tests/qtest/bios-tables-test.c +0
-0@@ -2123,6 +2125,7 @@ static void test_acpi_aarch64_virt_tcg(void) data.smbios_cpu_max_speed = 2900; data.smbios_cpu_curr_speed = 2700;test_acpi_one("-cpu cortex-a57 "
+ "-machine acpi-pcihp=off "
"-smbios type=4,max-speed=2900,current-speed=2700", &data);free_test_data(&data);
}tests/qtest/bios-tables-test.c +0
-0@@ -2142,6 +2145,7 @@ static void test_acpi_aarch64_virt_tcg_topology(void) };test_acpi_one("-cpu cortex-a57 "
+ "-machine acpi-pcihp=off "
"-smp sockets=1,clusters=2,cores=2,threads=2", &data);free_test_data(&data);
}tests/qtest/bios-tables-test.c +0
-0@@ -2227,6 +2231,7 @@ static void test_acpi_aarch64_virt_viot(void) };test_acpi_one("-cpu cortex-a57 "
+ "-machine acpi-pcihp=off " "-device virtio-iommu-pci", &data);free_test_data(&data);
}