* [RFC 00/24] APCI PCI Hotplug support on ARM
@ 2025-04-28 10:25 Eric Auger
2025-04-28 10:25 ` [RFC 01/24] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo Eric Auger
` (24 more replies)
0 siblings, 25 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
This series enables APCI PCI hotplug/hotunplug on ARM
and makes it default for 10.1 machine type. This aligns with
x86 q35 machine. Expected benefits should be similar to
those listed in [1].
The infrastructure used in x86 is heavily reused and a
huge part of the series consists in moving code from
hw/i386/acpi-build.c to a generic place and slightly
adapting it to make it usable on ARM. The DSDT table is
augmented to support ACPI PCI hotplug elements.
On ARM we use use a GED event to notify the OS about
hotplug events.
I have not noticed any tests/qtest/bios-tables-test failures
neither on x86 nor ARM. x86 DSDT table has not changed.
ARM DSDT table definitively has but there are no tests
impacted. ARM misses hotplug tests that do exist on x86. This
most probably should be considered in the future.
Best Regards
Eric
This series can be found at:
https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
[1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
Eric Auger (24):
hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
hw/acpi/ged: Fix wrong identation
hw/i386/acpi-build: Fix build_append_notfication_callback typo
hw/i386/acpi-build: Make aml_pci_device_dsm() static
hw/arm/virt: Introduce machine state acpi pcihp flags and props
hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to
acpi_dsdt_add_pci_osc
hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine
downto gpex
hw/i386/acpi-build: Turn build_q35_osc_method into a generic method
hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
hw/i386/acpi-build: Move build_append_notification_callback to pcihp
hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp
hw/i386/acpi-build: Introduce and use acpi_get_pci_host
hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug
hw/acpi/ged: Prepare the device to react to PCI hotplug events
hw/acpi/ged: Call pcihp plug callbacks in hotplug handler
implementation
hw/acpi/ged: Support migration of AcpiPciHpState
hw/core/sysbus: Introduce sysbus_mmio_map_name() helper
hw/arm/virt: Let virt support pci hotplug/unplug GED event
hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks
hw/arm/virt: Use ACPI PCI hotplug by default
hw/i386/acpi-build.h | 4 -
include/hw/acpi/aml-build.h | 2 +
include/hw/acpi/generic_event_device.h | 5 +
include/hw/acpi/pci.h | 4 +-
include/hw/acpi/pcihp.h | 14 +
include/hw/arm/virt.h | 4 +
include/hw/pci-host/gpex.h | 1 +
include/hw/sysbus.h | 1 +
hw/acpi/aml-build.c | 50 +++
hw/acpi/generic_event_device.c | 64 +++-
hw/acpi/pci.c | 20 ++
hw/acpi/pcihp.c | 428 +++++++++++++++++++++-
hw/arm/virt-acpi-build.c | 26 ++
hw/arm/virt.c | 100 +++++-
hw/core/sysbus.c | 11 +
hw/i386/acpi-build.c | 475 +------------------------
hw/pci-host/gpex-acpi.c | 75 +---
hw/pci/pcie_port.c | 4 +-
hw/arm/Kconfig | 2 +
19 files changed, 748 insertions(+), 542 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 46+ messages in thread
* [RFC 01/24] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-06 0:11 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 02/24] hw/acpi/ged: Fix wrong identation Eric Auger
` (23 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/pci/pcie_port.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c
index c73db30e98..072500ed34 100644
--- a/hw/pci/pcie_port.c
+++ b/hw/pci/pcie_port.c
@@ -188,7 +188,7 @@ int pcie_count_ds_ports(PCIBus *bus)
return dsp_count;
}
-static bool pcie_slot_is_hotpluggbale_bus(HotplugHandler *plug_handler,
+static bool pcie_slot_is_hotpluggable_bus(HotplugHandler *plug_handler,
BusState *bus)
{
PCIESlot *s = PCIE_SLOT(bus->parent);
@@ -221,7 +221,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data)
hc->plug = pcie_cap_slot_plug_cb;
hc->unplug = pcie_cap_slot_unplug_cb;
hc->unplug_request = pcie_cap_slot_unplug_request_cb;
- hc->is_hotpluggable_bus = pcie_slot_is_hotpluggbale_bus;
+ hc->is_hotpluggable_bus = pcie_slot_is_hotpluggable_bus;
}
static const TypeInfo pcie_slot_type_info = {
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 02/24] hw/acpi/ged: Fix wrong identation
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
2025-04-28 10:25 ` [RFC 01/24] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-06 0:11 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 03/24] hw/i386/acpi-build: Fix build_append_notfication_callback typo Eric Auger
` (22 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/acpi/generic_event_device.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
index c85d97ca37..7b2d582fff 100644
--- a/hw/acpi/generic_event_device.c
+++ b/hw/acpi/generic_event_device.c
@@ -458,11 +458,11 @@ static void acpi_ged_initfn(Object *obj)
* container for memory hotplug IO and expose it as GED sysbus
* MMIO so that boards can map it separately.
*/
- memory_region_init(&s->container_memhp, OBJECT(dev), "memhp container",
- MEMORY_HOTPLUG_IO_LEN);
- sysbus_init_mmio(sbd, &s->container_memhp);
- acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
- &s->memhp_state, 0);
+ memory_region_init(&s->container_memhp, OBJECT(dev), "memhp container",
+ MEMORY_HOTPLUG_IO_LEN);
+ sysbus_init_mmio(sbd, &s->container_memhp);
+ acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
+ &s->memhp_state, 0);
memory_region_init_io(&ged_st->regs, obj, &ged_regs_ops, ged_st,
TYPE_ACPI_GED "-regs", ACPI_GED_REG_COUNT);
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 03/24] hw/i386/acpi-build: Fix build_append_notfication_callback typo
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
2025-04-28 10:25 ` [RFC 01/24] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo Eric Auger
2025-04-28 10:25 ` [RFC 02/24] hw/acpi/ged: Fix wrong identation Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-06 0:11 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 04/24] hw/i386/acpi-build: Make aml_pci_device_dsm() static Eric Auger
` (21 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Rename build_append_notfication_callback into
build_append_notification_callback
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/i386/acpi-build.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 3fffa4a332..85c8a8566b 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -589,8 +589,8 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus)
}
}
-static bool build_append_notfication_callback(Aml *parent_scope,
- const PCIBus *bus)
+static bool build_append_notification_callback(Aml *parent_scope,
+ const PCIBus *bus)
{
Aml *method;
PCIBus *sec;
@@ -604,7 +604,7 @@ static bool build_append_notfication_callback(Aml *parent_scope,
continue;
}
nr_notifiers = nr_notifiers +
- build_append_notfication_callback(br_scope, sec);
+ build_append_notification_callback(br_scope, sec);
/*
* add new child scope to parent
* and keep track of bus that have PCNT,
@@ -1773,7 +1773,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
PCIBus *b = PCI_HOST_BRIDGE(pci_host)->bus;
scope = aml_scope("\\_SB.PCI0");
- has_pcnt = build_append_notfication_callback(scope, b);
+ has_pcnt = build_append_notification_callback(scope, b);
if (has_pcnt) {
aml_append(dsdt, scope);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 04/24] hw/i386/acpi-build: Make aml_pci_device_dsm() static
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (2 preceding siblings ...)
2025-04-28 10:25 ` [RFC 03/24] hw/i386/acpi-build: Fix build_append_notfication_callback typo Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props Eric Auger
` (20 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
No need to export aml_pci_device_dsm() as it is only used
in hw/i386/acpi-build.c.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/acpi/pci.h | 1 -
hw/i386/acpi-build.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
index 6359d574fd..ab0187a894 100644
--- a/include/hw/acpi/pci.h
+++ b/include/hw/acpi/pci.h
@@ -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);
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 85c8a8566b..864f6b5bf8 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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;
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (3 preceding siblings ...)
2025-04-28 10:25 ` [RFC 04/24] hw/i386/acpi-build: Make aml_pci_device_dsm() static Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-06 0:12 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp Eric Auger
` (19 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
acpi_pcihp VirtMachineClass state flag will allow
to opt in for acpi pci hotplug. This is guarded by a
class no_acpi_pcihp flag to manage compats (<= 10.0
machine types will not support ACPI PCI hotplug).
Machine state acpi_pcihp flag msu be set before the creation
of the GED device which will use it.
Currently the ACPI PCI HP is turned off by default. This will
change later on for 10.1 machine type.
We also introduce properties to allow disabling it.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/arm/virt.h | 2 ++
hw/arm/virt.c | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index c8e94e6aed..1e9d002880 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -135,6 +135,7 @@ struct VirtMachineClass {
bool no_tcg_lpa2;
bool no_ns_el2_virt_timer_irq;
bool no_nested_smmu;
+ bool no_acpi_pcihp;
};
struct VirtMachineState {
@@ -156,6 +157,7 @@ struct VirtMachineState {
bool mte;
bool dtb_randomness;
bool second_ns_uart_present;
+ bool acpi_pcihp;
OnOffAuto acpi;
VirtGICType gic_version;
VirtIOMMUType iommu;
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 3e72adaa91..1601750913 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine)
create_pcie(vms);
if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) {
+ vms->acpi_pcihp &= !vmc->no_acpi_pcihp;
vms->acpi_dev = create_acpi_ged(vms);
} else {
+ vms->acpi_pcihp = false;
create_gpio_devices(vms, VIRT_GPIO, sysmem);
}
@@ -2610,6 +2612,20 @@ static void virt_set_its(Object *obj, bool value, Error **errp)
vms->its = value;
}
+static bool virt_get_acpi_pcihp(Object *obj, Error **errp)
+{
+ VirtMachineState *vms = VIRT_MACHINE(obj);
+
+ return vms->acpi_pcihp;
+}
+
+static void virt_set_acpi_pcihp(Object *obj, bool value, Error **errp)
+{
+ VirtMachineState *vms = VIRT_MACHINE(obj);
+
+ vms->acpi_pcihp = value;
+}
+
static bool virt_get_dtb_randomness(Object *obj, Error **errp)
{
VirtMachineState *vms = VIRT_MACHINE(obj);
@@ -3327,6 +3343,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
"in ACPI table header."
"The string may be up to 8 bytes in size");
+ object_class_property_add_bool(oc, "acpi-pcihp",
+ virt_get_acpi_pcihp, virt_set_acpi_pcihp);
+ object_class_property_set_description(oc, "acpi-pcihp",
+ "Force acpi pci hotplug");
}
static void virt_instance_init(Object *obj)
@@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj)
}
}
+ /* default disallows ACPI PCI hotplug */
+ vms->acpi_pcihp = false;
+
/* Default disallows iommu instantiation */
vms->iommu = VIRT_IOMMU_NONE;
@@ -3415,8 +3438,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)
static void virt_machine_10_0_options(MachineClass *mc)
{
+ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
+
virt_machine_10_1_options(mc);
compat_props_add(mc->compat_props, hw_compat_10_0, hw_compat_10_0_len);
+ /* 10.0 and earlier do not support ACPI PCI hotplug */
+ vmc->no_acpi_pcihp = true;
}
DEFINE_VIRT_MACHINE(10, 0)
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (4 preceding siblings ...)
2025-04-28 10:25 ` [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-06 0:12 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc Eric Auger
` (18 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
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_hotplug is renamed into build_acpi_pci_hotplug().
No code change intended.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/i386/acpi-build.h | 4 -
include/hw/acpi/pcihp.h | 6 ++
hw/acpi/pcihp.c | 174 +++++++++++++++++++++++++++++++++++++++-
hw/i386/acpi-build.c | 150 +---------------------------------
4 files changed, 181 insertions(+), 153 deletions(-)
diff --git a/hw/i386/acpi-build.h b/hw/i386/acpi-build.h
index 0dce155c8c..8ba3c33e48 100644
--- a/hw/i386/acpi-build.h
+++ b/hw/i386/acpi-build.h
@@ -5,10 +5,6 @@
extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
-/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */
-#define ACPI_PCIHP_SEJ_BASE 0x8
-#define ACPI_PCIHP_BNMR_BASE 0x10
-
void acpi_setup(void);
Object *acpi_get_i386_pci_host(void);
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index ac21a95913..2da0bc45c9 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -33,6 +33,10 @@
#define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"
#define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len"
+/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */
+#define ACPI_PCIHP_SEJ_BASE 0x8
+#define ACPI_PCIHP_BNMR_BASE 0x10
+
typedef struct AcpiPciHpPciStatus {
uint32_t up;
uint32_t down;
@@ -69,6 +73,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
AcpiPciHpState *s, DeviceState *dev,
Error **errp);
+void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr);
+
/* Called on reset */
void acpi_pcihp_reset(AcpiPciHpState *s);
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 5f79c9016b..35d8c0bfd2 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -26,7 +26,7 @@
#include "qemu/osdep.h"
#include "hw/acpi/pcihp.h"
-
+#include "hw/acpi/aml-build.h"
#include "hw/pci-host/i440fx.h"
#include "hw/pci/pci.h"
#include "hw/pci/pci_bridge.h"
@@ -513,6 +513,178 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus,
OBJ_PROP_FLAG_READ);
}
+static void build_append_pci_dsm_func0_common(Aml *ctx, Aml *retvar)
+{
+ Aml *UUID, *ifctx1;
+ uint8_t byte_list[1] = { 0 }; /* nothing supported yet */
+
+ aml_append(ctx, aml_store(aml_buffer(1, byte_list), retvar));
+ /*
+ * PCI Firmware Specification 3.1
+ * 4.6. _DSM Definitions for PCI
+ */
+ UUID = aml_touuid("E5C937D0-3553-4D7A-9117-EA4D19C3434D");
+ ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(0), UUID)));
+ {
+ /* call is for unsupported UUID, bail out */
+ aml_append(ifctx1, aml_return(retvar));
+ }
+ aml_append(ctx, ifctx1);
+
+ ifctx1 = aml_if(aml_lless(aml_arg(1), aml_int(2)));
+ {
+ /* call is for unsupported REV, bail out */
+ aml_append(ifctx1, aml_return(retvar));
+ }
+ aml_append(ctx, ifctx1);
+}
+
+static Aml *aml_pci_pdsm(void)
+{
+ Aml *method, *ifctx, *ifctx1;
+ Aml *ret = aml_local(0);
+ Aml *caps = aml_local(1);
+ Aml *acpi_index = aml_local(2);
+ Aml *zero = aml_int(0);
+ Aml *one = aml_int(1);
+ Aml *not_supp = aml_int(0xFFFFFFFF);
+ Aml *func = aml_arg(2);
+ Aml *params = aml_arg(4);
+ Aml *bnum = aml_derefof(aml_index(params, aml_int(0)));
+ Aml *sunum = aml_derefof(aml_index(params, aml_int(1)));
+
+ method = aml_method("PDSM", 5, AML_SERIALIZED);
+
+ /* get supported functions */
+ ifctx = aml_if(aml_equal(func, zero));
+ {
+ build_append_pci_dsm_func0_common(ifctx, ret);
+
+ aml_append(ifctx, aml_store(zero, caps));
+ aml_append(ifctx,
+ aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
+ /*
+ * advertise function 7 if device has acpi-index
+ * acpi_index values:
+ * 0: not present (default value)
+ * FFFFFFFF: not supported (old QEMU without PIDX reg)
+ * other: device's acpi-index
+ */
+ ifctx1 = aml_if(aml_lnot(
+ aml_or(aml_equal(acpi_index, zero),
+ aml_equal(acpi_index, not_supp), NULL)
+ ));
+ {
+ /* have supported functions */
+ aml_append(ifctx1, aml_or(caps, one, caps));
+ /* support for function 7 */
+ aml_append(ifctx1,
+ aml_or(caps, aml_shiftleft(one, aml_int(7)), caps));
+ }
+ aml_append(ifctx, ifctx1);
+
+ aml_append(ifctx, aml_store(caps, aml_index(ret, zero)));
+ aml_append(ifctx, aml_return(ret));
+ }
+ aml_append(method, ifctx);
+
+ /* handle specific functions requests */
+ /*
+ * PCI Firmware Specification 3.1
+ * 4.6.7. _DSM for Naming a PCI or PCI Express Device Under
+ * Operating Systems
+ */
+ ifctx = aml_if(aml_equal(func, aml_int(7)));
+ {
+ Aml *pkg = aml_package(2);
+
+ aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
+ aml_append(ifctx, aml_store(pkg, ret));
+ /*
+ * Windows calls func=7 without checking if it's available,
+ * as workaround Microsoft has suggested to return invalid for func7
+ * Package, so return 2 elements package but only initialize elements
+ * when acpi_index is supported and leave them uninitialized, which
+ * leads elements to being Uninitialized ObjectType and should trip
+ * Windows into discarding result as an unexpected and prevent setting
+ * bogus 'PCI Label' on the device.
+ */
+ ifctx1 = aml_if(aml_lnot(aml_lor(
+ aml_equal(acpi_index, zero), aml_equal(acpi_index, not_supp)
+ )));
+ {
+ aml_append(ifctx1, aml_store(acpi_index, aml_index(ret, zero)));
+ /*
+ * optional, if not impl. should return null string
+ */
+ aml_append(ifctx1, aml_store(aml_string("%s", ""),
+ aml_index(ret, one)));
+ }
+ aml_append(ifctx, ifctx1);
+
+ aml_append(ifctx, aml_return(ret));
+ }
+
+ aml_append(method, ifctx);
+ return method;
+}
+
+void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr)
+{
+ Aml *scope;
+ Aml *field;
+ Aml *method;
+
+ scope = aml_scope("_SB.PCI0");
+
+ aml_append(scope,
+ aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(pcihp_addr), 0x08));
+ field = aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
+ aml_append(field, aml_named_field("PCIU", 32));
+ aml_append(field, aml_named_field("PCID", 32));
+ aml_append(scope, field);
+
+ aml_append(scope,
+ aml_operation_region("SEJ", AML_SYSTEM_IO,
+ aml_int(pcihp_addr + ACPI_PCIHP_SEJ_BASE), 0x04));
+ field = aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
+ aml_append(field, aml_named_field("B0EJ", 32));
+ aml_append(scope, field);
+
+ aml_append(scope,
+ aml_operation_region("BNMR", AML_SYSTEM_IO,
+ aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0x08));
+ field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
+ aml_append(field, aml_named_field("BNUM", 32));
+ aml_append(field, aml_named_field("PIDX", 32));
+ aml_append(scope, field);
+
+ aml_append(scope, aml_mutex("BLCK", 0));
+
+ method = aml_method("PCEJ", 2, AML_NOTSERIALIZED);
+ aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
+ aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
+ aml_append(method,
+ aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("B0EJ")));
+ aml_append(method, aml_release(aml_name("BLCK")));
+ aml_append(method, aml_return(aml_int(0)));
+ aml_append(scope, method);
+
+ method = aml_method("AIDX", 2, AML_NOTSERIALIZED);
+ aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
+ aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
+ aml_append(method,
+ aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("PIDX")));
+ aml_append(method, aml_store(aml_name("PIDX"), aml_local(0)));
+ aml_append(method, aml_release(aml_name("BLCK")));
+ aml_append(method, aml_return(aml_local(0)));
+ aml_append(scope, method);
+
+ aml_append(scope, aml_pci_pdsm());
+
+ aml_append(table, scope);
+}
+
const VMStateDescription vmstate_acpi_pcihp_pci_status = {
.name = "acpi_pcihp_pci_status",
.version_id = 1,
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 864f6b5bf8..2d1eea4a1a 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -647,96 +647,6 @@ static bool build_append_notification_callback(Aml *parent_scope,
return !!nr_notifiers;
}
-static Aml *aml_pci_pdsm(void)
-{
- Aml *method, *ifctx, *ifctx1;
- Aml *ret = aml_local(0);
- Aml *caps = aml_local(1);
- Aml *acpi_index = aml_local(2);
- Aml *zero = aml_int(0);
- Aml *one = aml_int(1);
- Aml *not_supp = aml_int(0xFFFFFFFF);
- Aml *func = aml_arg(2);
- Aml *params = aml_arg(4);
- Aml *bnum = aml_derefof(aml_index(params, aml_int(0)));
- Aml *sunum = aml_derefof(aml_index(params, aml_int(1)));
-
- method = aml_method("PDSM", 5, AML_SERIALIZED);
-
- /* get supported functions */
- ifctx = aml_if(aml_equal(func, zero));
- {
- build_append_pci_dsm_func0_common(ifctx, ret);
-
- aml_append(ifctx, aml_store(zero, caps));
- aml_append(ifctx,
- aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
- /*
- * advertise function 7 if device has acpi-index
- * acpi_index values:
- * 0: not present (default value)
- * FFFFFFFF: not supported (old QEMU without PIDX reg)
- * other: device's acpi-index
- */
- ifctx1 = aml_if(aml_lnot(
- aml_or(aml_equal(acpi_index, zero),
- aml_equal(acpi_index, not_supp), NULL)
- ));
- {
- /* have supported functions */
- aml_append(ifctx1, aml_or(caps, one, caps));
- /* support for function 7 */
- aml_append(ifctx1,
- aml_or(caps, aml_shiftleft(one, aml_int(7)), caps));
- }
- aml_append(ifctx, ifctx1);
-
- aml_append(ifctx, aml_store(caps, aml_index(ret, zero)));
- aml_append(ifctx, aml_return(ret));
- }
- aml_append(method, ifctx);
-
- /* handle specific functions requests */
- /*
- * PCI Firmware Specification 3.1
- * 4.6.7. _DSM for Naming a PCI or PCI Express Device Under
- * Operating Systems
- */
- ifctx = aml_if(aml_equal(func, aml_int(7)));
- {
- Aml *pkg = aml_package(2);
-
- aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
- aml_append(ifctx, aml_store(pkg, ret));
- /*
- * Windows calls func=7 without checking if it's available,
- * as workaround Microsoft has suggested to return invalid for func7
- * Package, so return 2 elements package but only initialize elements
- * when acpi_index is supported and leave them uninitialized, which
- * leads elements to being Uninitialized ObjectType and should trip
- * Windows into discarding result as an unexpected and prevent setting
- * bogus 'PCI Label' on the device.
- */
- ifctx1 = aml_if(aml_lnot(aml_lor(
- aml_equal(acpi_index, zero), aml_equal(acpi_index, not_supp)
- )));
- {
- aml_append(ifctx1, aml_store(acpi_index, aml_index(ret, zero)));
- /*
- * optional, if not impl. should return null string
- */
- aml_append(ifctx1, aml_store(aml_string("%s", ""),
- aml_index(ret, one)));
- }
- aml_append(ifctx, ifctx1);
-
- aml_append(ifctx, aml_return(ret));
- }
-
- aml_append(method, ifctx);
- return method;
-}
-
/*
* build_prt - Define interrupt routing rules
*
@@ -1227,62 +1137,6 @@ static Aml *build_q35_dram_controller(const AcpiMcfgInfo *mcfg)
return dev;
}
-static void build_x86_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr)
-{
- Aml *scope;
- Aml *field;
- Aml *method;
-
- scope = aml_scope("_SB.PCI0");
-
- aml_append(scope,
- aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(pcihp_addr), 0x08));
- field = aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
- aml_append(field, aml_named_field("PCIU", 32));
- aml_append(field, aml_named_field("PCID", 32));
- aml_append(scope, field);
-
- aml_append(scope,
- aml_operation_region("SEJ", AML_SYSTEM_IO,
- aml_int(pcihp_addr + ACPI_PCIHP_SEJ_BASE), 0x04));
- field = aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
- aml_append(field, aml_named_field("B0EJ", 32));
- aml_append(scope, field);
-
- aml_append(scope,
- aml_operation_region("BNMR", AML_SYSTEM_IO,
- aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0x08));
- field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
- aml_append(field, aml_named_field("BNUM", 32));
- aml_append(field, aml_named_field("PIDX", 32));
- aml_append(scope, field);
-
- aml_append(scope, aml_mutex("BLCK", 0));
-
- method = aml_method("PCEJ", 2, AML_NOTSERIALIZED);
- aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
- aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
- aml_append(method,
- aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("B0EJ")));
- aml_append(method, aml_release(aml_name("BLCK")));
- aml_append(method, aml_return(aml_int(0)));
- aml_append(scope, method);
-
- method = aml_method("AIDX", 2, AML_NOTSERIALIZED);
- aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
- aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
- aml_append(method,
- aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("PIDX")));
- aml_append(method, aml_store(aml_name("PIDX"), aml_local(0)));
- aml_append(method, aml_release(aml_name("BLCK")));
- aml_append(method, aml_return(aml_local(0)));
- aml_append(scope, method);
-
- aml_append(scope, aml_pci_pdsm());
-
- aml_append(table, scope);
-}
-
static Aml *build_q35_osc_method(bool enable_native_pcie_hotplug)
{
Aml *if_ctx;
@@ -1394,7 +1248,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
aml_append(dsdt, sb_scope);
if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
- build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
+ build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
}
build_piix4_pci0_int(dsdt);
} else if (q35) {
@@ -1438,7 +1292,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
aml_append(dsdt, sb_scope);
if (pm->pcihp_bridge_en) {
- build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
+ build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
}
build_q35_pci0_int(dsdt);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (5 preceding siblings ...)
2025-04-28 10:25 ` [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-06 0:13 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 08/24] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation Eric Auger
` (17 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Add a new argument to acpi_dsdt_add_pci_osc to be able to disable
native pci hotplug.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/pci-host/gpex-acpi.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
index e8b4c64c5f..4016089893 100644
--- a/hw/pci-host/gpex-acpi.c
+++ b/hw/pci-host/gpex-acpi.c
@@ -50,7 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq,
}
}
-static void acpi_dsdt_add_pci_osc(Aml *dev)
+static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug)
{
Aml *method, *UUID, *ifctx, *ifctx1, *elsectx, *buf;
@@ -80,8 +80,9 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)
* Allow OS control for all 5 features:
* PCIeHotplug SHPCHotplug PME AER PCIeCapability.
*/
- aml_append(ifctx, aml_and(aml_name("CTRL"), aml_int(0x1F),
- aml_name("CTRL")));
+ aml_append(ifctx, aml_and(aml_name("CTRL"),
+ aml_int(0x1E | (enable_native_pcie_hotplug ? 0x1 : 0x0)),
+ aml_name("CTRL")));
ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(0x1))));
aml_append(ifctx1, aml_or(aml_name("CDW1"), aml_int(0x08),
@@ -192,7 +193,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)
if (is_cxl) {
build_cxl_osc_method(dev);
} else {
- acpi_dsdt_add_pci_osc(dev);
+ acpi_dsdt_add_pci_osc(dev, true);
}
aml_append(scope, dev);
@@ -267,7 +268,7 @@ void acpi_dsdt_add_gpex(Aml *scope, struct GPEXConfig *cfg)
}
aml_append(dev, aml_name_decl("_CRS", rbuf));
- acpi_dsdt_add_pci_osc(dev);
+ acpi_dsdt_add_pci_osc(dev, true);
Aml *dev_res0 = aml_device("%s", "RES0");
aml_append(dev_res0, aml_name_decl("_HID", aml_string("PNP0C02")));
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 08/24] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (6 preceding siblings ...)
2025-04-28 10:25 ` [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-06 0:13 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 09/24] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex Eric Auger
` (16 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
acpi_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.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/pci-host/gpex-acpi.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
index 4016089893..9d9f5ed7c6 100644
--- a/hw/pci-host/gpex-acpi.c
+++ b/hw/pci-host/gpex-acpi.c
@@ -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")));
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 09/24] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (7 preceding siblings ...)
2025-04-28 10:25 ` [RFC 08/24] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-06 0:13 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 10/24] hw/i386/acpi-build: Turn build_q35_osc_method into a generic method Eric Auger
` (15 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Propagate 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.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
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(-)
diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h
index 84471533af..feaf827474 100644
--- a/include/hw/pci-host/gpex.h
+++ b/include/hw/pci-host/gpex.h
@@ -45,6 +45,7 @@ struct GPEXConfig {
MemMapEntry pio;
int irq;
PCIBus *bus;
+ bool pci_native_hotplug;
};
typedef struct GPEXIrq GPEXIrq;
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 3ac8f8e178..46c5a43d27 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -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) {
diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
index 9d9f5ed7c6..9a521145bd 100644
--- a/hw/pci-host/gpex-acpi.c
+++ b/hw/pci-host/gpex-acpi.c
@@ -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")));
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 10/24] hw/i386/acpi-build: Turn build_q35_osc_method into a generic method
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (8 preceding siblings ...)
2025-04-28 10:25 ` [RFC 09/24] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 11/24] hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method Eric Auger
` (14 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
GPEX 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().
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
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(-)
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
index c18f681342..177d60b414 100644
--- a/include/hw/acpi/aml-build.h
+++ b/include/hw/acpi/aml-build.h
@@ -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
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
index f8f93a9f66..ba1dfe0b52 100644
--- a/hw/acpi/aml-build.c
+++ b/hw/acpi/aml-build.c
@@ -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;
+}
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 2d1eea4a1a..a3065a94d1 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1137,56 +1137,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;
@@ -1257,7 +1207,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) {
@@ -1379,7 +1329,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")));
}
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 11/24] hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (9 preceding siblings ...)
2025-04-28 10:25 ` [RFC 10/24] hw/i386/acpi-build: Turn build_q35_osc_method into a generic method Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 12/24] hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper Eric Auger
` (13 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
gpex 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().
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
The DSDT diff is given below:
diff --git a/dsdt.dsl_before b/dsdt.dsl_after_osc_change
index 3224a56..fa7558e 100644
--- a/dsdt.dsl_before
+++ b/dsdt.dsl_after_osc_change
@@ -5,13 +5,13 @@
*
* Disassembling to symbolic ASL+ operators
*
- * Disassembly of dsdt.dat, Mon Apr 7 05:33:06 2025
+ * Disassembly of dsdt.dat, Mon Apr 7 05:37:20 2025
*
* Original Table Header:
* Signature "DSDT"
- * Length 0x00001A4F (6735)
+ * Length 0x00001A35 (6709)
* Revision 0x02
- * Checksum 0xBF
+ * Checksum 0xDD
* OEM ID "BOCHS "
* OEM Table ID "BXPC "
* OEM Revision 0x00000001 (1)
@@ -1849,27 +1849,26 @@ DefinitionBlock ("", "DSDT", 2, "BOCHS ", "BXPC ", 0x00000001)
{
CreateDWordField (Arg3, 0x04, CDW2)
CreateDWordField (Arg3, 0x08, CDW3)
- SUPP = CDW2 /* \_SB_.PCI0._OSC.CDW2 */
- CTRL = CDW3 /* \_SB_.PCI0._OSC.CDW3 */
- CTRL &= 0x1F
+ Local0 = CDW3 /* \_SB_.PCI0._OSC.CDW3 */
+ Local0 &= 0x1F
If ((Arg1 != One))
{
CDW1 |= 0x08
}
- If ((CDW3 != CTRL))
+ If ((CDW3 != Local0))
{
CDW1 |= 0x10
}
- CDW3 = CTRL /* \_SB_.PCI0.CTRL */
- Return (Arg3)
+ CDW3 = Local0
}
Else
{
CDW1 |= 0x04
- Return (Arg3)
}
+
+ Return (Arg3)
}
Method (_DSM, 4, NotSerialized) // _DSM: Device-Specific Method
---
hw/pci-host/gpex-acpi.c | 60 +++--------------------------------------
1 file changed, 4 insertions(+), 56 deletions(-)
diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
index 9a521145bd..9e93c1d07b 100644
--- a/hw/pci-host/gpex-acpi.c
+++ b/hw/pci-host/gpex-acpi.c
@@ -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 all 5 features:
- * PCIeHotplug SHPCHotplug PME AER PCIeCapability.
- */
- 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)
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 12/24] hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (10 preceding siblings ...)
2025-04-28 10:25 ` [RFC 11/24] hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 13/24] hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug Eric Auger
` (12 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Extract 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.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/acpi/pcihp.h | 2 ++
hw/acpi/pcihp.c | 20 ++++++++++++++++++++
hw/i386/acpi-build.c | 15 ++-------------
3 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 2da0bc45c9..819e815acd 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -74,6 +74,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
Error **errp);
void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr);
+void build_append_pcihp_resources(Aml *table,
+ uint64_t io_addr, uint64_t io_len);
/* Called on reset */
void acpi_pcihp_reset(AcpiPciHpState *s);
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 35d8c0bfd2..6f9cd45b5f 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -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,
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a3065a94d1..4934d939f4 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1458,19 +1458,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
/* reserve PCIHP resources */
if (pm->pcihp_io_len && (pm->pcihp_bridge_en || pm->pcihp_root_en)) {
- dev = aml_device("PHPR");
- aml_append(dev, aml_name_decl("_HID", aml_string("PNP0A06")));
- aml_append(dev,
- aml_name_decl("_UID", aml_string("PCI Hotplug resources")));
- /* device present, functioning, decoding, not shown in UI */
- aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
- crs = aml_resource_template();
- aml_append(crs,
- aml_io(AML_DECODE16, pm->pcihp_io_base, pm->pcihp_io_base, 1,
- pm->pcihp_io_len)
- );
- aml_append(dev, aml_name_decl("_CRS", crs));
- aml_append(scope, dev);
+ build_append_pcihp_resources(scope,
+ pm->pcihp_io_base, pm->pcihp_io_len);
}
aml_append(dsdt, scope);
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 13/24] hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (11 preceding siblings ...)
2025-04-28 10:25 ` [RFC 12/24] hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 14/24] hw/i386/acpi-build: Move build_append_notification_callback to pcihp Eric Auger
` (11 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
On ARM we will put the operation regions in AML_SYSTEM_MEMORY.
So let's allow this configuration.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/acpi/pcihp.h | 3 ++-
hw/acpi/pcihp.c | 8 ++++----
hw/i386/acpi-build.c | 4 ++--
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 819e815acd..ab20fe7788 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -28,6 +28,7 @@
#define HW_ACPI_PCIHP_H
#include "hw/acpi/acpi.h"
+#include "hw/acpi/aml-build.h"
#include "hw/hotplug.h"
#define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"
@@ -73,7 +74,7 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
AcpiPciHpState *s, DeviceState *dev,
Error **errp);
-void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr);
+void build_acpi_pci_hotplug(Aml *table, AmlRegionSpace rs, uint64_t pcihp_addr);
void build_append_pcihp_resources(Aml *table,
uint64_t io_addr, uint64_t io_len);
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 6f9cd45b5f..3dcbc7683d 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -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));
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 4934d939f4..0cf372f9cb 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1198,7 +1198,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
aml_append(dsdt, sb_scope);
if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
- build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
+ build_acpi_pci_hotplug(dsdt, AML_SYSTEM_IO, pm->pcihp_io_base);
}
build_piix4_pci0_int(dsdt);
} else if (q35) {
@@ -1242,7 +1242,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
aml_append(dsdt, sb_scope);
if (pm->pcihp_bridge_en) {
- build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
+ build_acpi_pci_hotplug(dsdt, AML_SYSTEM_IO, pm->pcihp_io_base);
}
build_q35_pci0_int(dsdt);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 14/24] hw/i386/acpi-build: Move build_append_notification_callback to pcihp
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (12 preceding siblings ...)
2025-04-28 10:25 ` [RFC 13/24] hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 15/24] hw/i386/acpi-build: Move remaining pcihp generic functions " Eric Auger
` (10 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
We plan to reuse build_append_notification_callback() on ARM
so let's move it to pcihp.c.
No functional change intended.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/acpi/pcihp.h | 1 +
hw/acpi/pcihp.c | 58 +++++++++++++++++++++++++++++++++++++++++
hw/i386/acpi-build.c | 58 -----------------------------------------
3 files changed, 59 insertions(+), 58 deletions(-)
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index ab20fe7788..082c4e38b0 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -77,6 +77,7 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
void build_acpi_pci_hotplug(Aml *table, AmlRegionSpace rs, uint64_t pcihp_addr);
void build_append_pcihp_resources(Aml *table,
uint64_t io_addr, uint64_t io_len);
+bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus);
/* Called on reset */
void acpi_pcihp_reset(AcpiPciHpState *s);
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 3dcbc7683d..e629528256 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -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,
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 0cf372f9cb..a91bfc500e 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -589,64 +589,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
*
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 15/24] hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (13 preceding siblings ...)
2025-04-28 10:25 ` [RFC 14/24] hw/i386/acpi-build: Move build_append_notification_callback to pcihp Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 16/24] hw/i386/acpi-build: Introduce and use acpi_get_pci_host Eric Auger
` (9 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
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 small static helpers they
use.
No functional change intended.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
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(-)
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
index ab0187a894..4dca22c0e2 100644
--- a/include/hw/acpi/pci.h
+++ b/include/hw/acpi/pci.h
@@ -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);
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 082c4e38b0..451ef74284 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -79,6 +79,8 @@ void build_append_pcihp_resources(Aml *table,
uint64_t io_addr, uint64_t io_len);
bool build_append_notification_callback(Aml *parent_scope, const PCIBus *bus);
+void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus);
+
/* Called on reset */
void acpi_pcihp_reset(AcpiPciHpState *s);
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index e629528256..49da95e0dd 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -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,
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index a91bfc500e..3198d956b6 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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 void build_append_pci_dsm_func0_common(Aml *ctx, Aml *retvar)
{
Aml *UUID, *ifctx1;
@@ -440,155 +417,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
*
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 16/24] hw/i386/acpi-build: Introduce and use acpi_get_pci_host
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (14 preceding siblings ...)
2025-04-28 10:25 ` [RFC 15/24] hw/i386/acpi-build: Move remaining pcihp generic functions " Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 17/24] hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug Eric Auger
` (8 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
pcihp 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.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
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(-)
diff --git a/include/hw/acpi/pci.h b/include/hw/acpi/pci.h
index 4dca22c0e2..310cbd02db 100644
--- a/include/hw/acpi/pci.h
+++ b/include/hw/acpi/pci.h
@@ -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
diff --git a/hw/acpi/pci.c b/hw/acpi/pci.c
index f88f450af3..0b07b77586 100644
--- a/hw/acpi/pci.c
+++ b/hw/acpi/pci.c
@@ -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;
+}
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 49da95e0dd..82b8ea2811 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -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 };
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 3198d956b6..f9122e56e8 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -269,27 +269,11 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
#endif
}
-/*
- * Because of the PXB hosts we cannot simply query TYPE_PCI_HOST_BRIDGE.
- * On i386 arch we only have two pci hosts, so we can look only for them.
- */
-Object *acpi_get_i386_pci_host(void)
-{
- PCIHostState *host;
-
- host = PCI_HOST_BRIDGE(object_resolve_path("/machine/i440fx", NULL));
- if (!host) {
- host = PCI_HOST_BRIDGE(object_resolve_path("/machine/q35", NULL));
- }
-
- return OBJECT(host);
-}
-
static void acpi_get_pci_holes(Range *hole, Range *hole64)
{
Object *pci_host;
- pci_host = acpi_get_i386_pci_host();
+ pci_host = acpi_get_pci_host();
if (!pci_host) {
return;
@@ -1271,7 +1255,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
sb_scope = aml_scope("\\_SB");
{
- Object *pci_host = acpi_get_i386_pci_host();
+ Object *pci_host = acpi_get_pci_host();
if (pci_host) {
PCIBus *pbus = PCI_HOST_BRIDGE(pci_host)->bus;
@@ -1332,7 +1316,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
bool has_pcnt;
- Object *pci_host = acpi_get_i386_pci_host();
+ Object *pci_host = acpi_get_pci_host();
PCIBus *b = PCI_HOST_BRIDGE(pci_host)->bus;
scope = aml_scope("\\_SB.PCI0");
@@ -1972,7 +1956,7 @@ static bool acpi_get_mcfg(AcpiMcfgInfo *mcfg)
Object *pci_host;
QObject *o;
- pci_host = acpi_get_i386_pci_host();
+ pci_host = acpi_get_pci_host();
if (!pci_host) {
return false;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 17/24] hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (15 preceding siblings ...)
2025-04-28 10:25 ` [RFC 16/24] hw/i386/acpi-build: Introduce and use acpi_get_pci_host Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events Eric Auger
` (7 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Generate additional DSDT description for ACPI PCI hotplug
support.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/arm/virt.h | 1 +
hw/arm/virt-acpi-build.c | 24 ++++++++++++++++++++++++
hw/arm/virt.c | 1 +
hw/arm/Kconfig | 2 ++
4 files changed, 28 insertions(+)
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index 1e9d002880..b8ca753644 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -79,6 +79,7 @@ enum {
VIRT_ACPI_GED,
VIRT_NVDIMM_ACPI,
VIRT_PVTIME,
+ VIRT_ACPI_PCIHP,
VIRT_LOWMEMMAP_LAST,
};
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 46c5a43d27..7bee57d489 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -34,6 +34,7 @@
#include "hw/core/cpu.h"
#include "hw/acpi/acpi-defs.h"
#include "hw/acpi/acpi.h"
+#include "hw/acpi/pcihp.h"
#include "hw/nvram/fw_cfg_acpi.h"
#include "hw/acpi/bios-linker-loader.h"
#include "hw/acpi/aml-build.h"
@@ -840,6 +841,29 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
(irqmap[VIRT_MMIO] + ARM_SPI_BASE),
0, NUM_VIRTIO_TRANSPORTS);
acpi_dsdt_add_pci(scope, memmap, irqmap[VIRT_PCIE] + ARM_SPI_BASE, vms);
+
+ aml_append(dsdt, scope);
+
+ if (vms->acpi_pcihp) {
+ Aml *pci0_scope = aml_scope("\\_SB.PCI0");
+
+ build_acpi_pci_hotplug(dsdt, AML_SYSTEM_MEMORY,
+ memmap[VIRT_ACPI_PCIHP].base);
+ build_append_pcihp_resources(pci0_scope,
+ memmap[VIRT_ACPI_PCIHP].base,
+ memmap[VIRT_ACPI_PCIHP].size);
+
+ /* Scan all PCI buses. Generate tables to support hotplug. */
+ build_append_pci_bus_devices(pci0_scope, vms->bus);
+ if (object_property_find(OBJECT(vms->bus), ACPI_PCIHP_PROP_BSEL)) {
+ build_append_pcihp_slots(pci0_scope, vms->bus);
+ }
+ build_append_notification_callback(pci0_scope, vms->bus);
+ aml_append(dsdt, pci0_scope);
+ }
+
+ scope = aml_scope("\\_SB");
+
if (vms->acpi_dev) {
build_ged_aml(scope, "\\_SB."GED_DEVICE,
HOTPLUG_HANDLER(vms->acpi_dev),
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 1601750913..2790853927 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -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 },
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index a55b44d7bd..572b4dabd5 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -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
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (16 preceding siblings ...)
2025-04-28 10:25 ` [RFC 17/24] hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-14 16:20 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 19/24] hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation Eric Auger
` (6 subsequent siblings)
24 siblings, 1 reply; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
QEMU will notify the OS about PCI hotplug/hotunplug events through
GED interrupts. Let the GED device handle a new PCI hotplug event.
On its occurence it calls the \\_SB.PCI0.PCNT method with the BLCK
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
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/acpi/generic_event_device.h | 5 +++++
include/hw/acpi/pcihp.h | 2 ++
hw/acpi/generic_event_device.c | 14 ++++++++++++++
3 files changed, 21 insertions(+)
diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h
index d2dac87b4a..28be6c0582 100644
--- a/include/hw/acpi/generic_event_device.h
+++ b/include/hw/acpi/generic_event_device.h
@@ -63,6 +63,7 @@
#include "hw/acpi/memory_hotplug.h"
#include "hw/acpi/ghes.h"
#include "hw/acpi/cpu.h"
+#include "hw/acpi/pcihp.h"
#include "qom/object.h"
#define ACPI_POWER_BUTTON_DEVICE "PWRB"
@@ -101,6 +102,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)
#define ACPI_GED_PWR_DOWN_EVT 0x2
#define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4
#define ACPI_GED_CPU_HOTPLUG_EVT 0x8
+#define ACPI_GED_PCI_HOTPLUG_EVT 0x10
typedef struct GEDState {
MemoryRegion evt;
@@ -114,6 +116,9 @@ struct AcpiGedState {
MemoryRegion container_memhp;
CPUHotplugState cpuhp_state;
MemoryRegion container_cpuhp;
+ AcpiPciHpState pcihp_state;
+ MemoryRegion container_pcihp;
+
GEDState ged_state;
uint32_t ged_event_bitmap;
qemu_irq irq;
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index 451ef74284..abb6e14549 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -38,6 +38,8 @@
#define ACPI_PCIHP_SEJ_BASE 0x8
#define ACPI_PCIHP_BNMR_BASE 0x10
+#define ACPI_PCI_HOTPLUG_REG_LEN 0x14
+
typedef struct AcpiPciHpPciStatus {
uint32_t up;
uint32_t down;
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
index 7b2d582fff..0fd8baba97 100644
--- a/hw/acpi/generic_event_device.c
+++ b/hw/acpi/generic_event_device.c
@@ -26,6 +26,7 @@ static const uint32_t ged_supported_events[] = {
ACPI_GED_PWR_DOWN_EVT,
ACPI_GED_NVDIMM_HOTPLUG_EVT,
ACPI_GED_CPU_HOTPLUG_EVT,
+ ACPI_GED_PCI_HOTPLUG_EVT,
};
/*
@@ -121,6 +122,12 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
aml_notify(aml_name("\\_SB.NVDR"),
aml_int(0x80)));
break;
+ case ACPI_GED_PCI_HOTPLUG_EVT:
+ aml_append(if_ctx,
+ aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
+ aml_append(if_ctx, aml_call0("\\_SB.PCI0.PCNT"));
+ aml_append(if_ctx, aml_release(aml_name("\\_SB.PCI0.BLCK")));
+ break;
default:
/*
* Please make sure all the events in ged_supported_events[]
@@ -299,6 +306,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
sel = ACPI_GED_NVDIMM_HOTPLUG_EVT;
} else if (ev & ACPI_CPU_HOTPLUG_STATUS) {
sel = ACPI_GED_CPU_HOTPLUG_EVT;
+ } else if (ev & ACPI_PCI_HOTPLUG_STATUS) {
+ sel = ACPI_GED_PCI_HOTPLUG_EVT;
} else {
/* Unknown event. Return without generating interrupt. */
warn_report("GED: Unsupported event %d. No irq injected", ev);
@@ -428,6 +437,11 @@ static void acpi_ged_realize(DeviceState *dev, Error **errp)
cpu_hotplug_hw_init(&s->container_cpuhp, OBJECT(dev),
&s->cpuhp_state, 0);
break;
+ case ACPI_GED_PCI_HOTPLUG_EVT:
+ memory_region_init(&s->container_pcihp, OBJECT(dev),
+ "pcihp container",
+ ACPI_PCI_HOTPLUG_REG_LEN);
+ sysbus_init_mmio(sbd, &s->container_pcihp);
}
ged_events--;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 19/24] hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (17 preceding siblings ...)
2025-04-28 10:25 ` [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 20/24] hw/acpi/ged: Support migration of AcpiPciHpState Eric Auger
` (5 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Add 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).
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/acpi/generic_event_device.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
index 0fd8baba97..144c91ea4c 100644
--- a/hw/acpi/generic_event_device.c
+++ b/hw/acpi/generic_event_device.c
@@ -16,6 +16,7 @@
#include "hw/irq.h"
#include "hw/mem/pc-dimm.h"
#include "hw/mem/nvdimm.h"
+#include "hw/pci/pci_device.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
#include "qemu/error-report.h"
@@ -234,6 +235,17 @@ static const MemoryRegionOps ged_regs_ops = {
},
};
+static void acpi_ged_device_pre_plug_cb(HotplugHandler *hotplug_dev,
+ DeviceState *dev, Error **errp)
+{
+ if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ acpi_pcihp_device_pre_plug_cb(hotplug_dev, dev, errp);
+ } else {
+ error_setg(errp, "virt: device pre plug request for unsupported device"
+ " type: %s", object_get_typename(OBJECT(dev)));
+ }
+}
+
static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev, Error **errp)
{
@@ -247,6 +259,8 @@ static void acpi_ged_device_plug_cb(HotplugHandler *hotplug_dev,
}
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
acpi_cpu_plug_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ acpi_pcihp_device_plug_cb(hotplug_dev, &s->pcihp_state, dev, errp);
} else {
error_setg(errp, "virt: device plug request for unsupported device"
" type: %s", object_get_typename(OBJECT(dev)));
@@ -263,6 +277,9 @@ static void acpi_ged_unplug_request_cb(HotplugHandler *hotplug_dev,
acpi_memory_unplug_request_cb(hotplug_dev, &s->memhp_state, dev, errp);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp);
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ acpi_pcihp_device_unplug_request_cb(hotplug_dev, &s->pcihp_state,
+ dev, errp);
} else {
error_setg(errp, "acpi: device unplug request for unsupported device"
" type: %s", object_get_typename(OBJECT(dev)));
@@ -278,6 +295,8 @@ static void acpi_ged_unplug_cb(HotplugHandler *hotplug_dev,
acpi_memory_unplug_cb(&s->memhp_state, dev, errp);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
acpi_cpu_unplug_cb(&s->cpuhp_state, dev, errp);
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ acpi_pcihp_device_unplug_cb(hotplug_dev, &s->pcihp_state, dev, errp);
} else {
error_setg(errp, "acpi: device unplug for unsupported device"
" type: %s", object_get_typename(OBJECT(dev)));
@@ -494,6 +513,7 @@ static void acpi_ged_class_init(ObjectClass *class, void *data)
dc->vmsd = &vmstate_acpi_ged;
dc->realize = acpi_ged_realize;
+ hc->pre_plug = acpi_ged_device_pre_plug_cb;
hc->plug = acpi_ged_device_plug_cb;
hc->unplug_request = acpi_ged_unplug_request_cb;
hc->unplug = acpi_ged_unplug_cb;
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 20/24] hw/acpi/ged: Support migration of AcpiPciHpState
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (18 preceding siblings ...)
2025-04-28 10:25 ` [RFC 19/24] hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 21/24] hw/core/sysbus: Introduce sysbus_mmio_map_name() helper Eric Auger
` (4 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Add a subsection to migrate the AcpiPciHpState state.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/acpi/generic_event_device.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
index 144c91ea4c..a7438bf60a 100644
--- a/hw/acpi/generic_event_device.c
+++ b/hw/acpi/generic_event_device.c
@@ -414,6 +414,25 @@ static const VMStateDescription vmstate_ghes_state = {
}
};
+static bool pcihp_needed(void *opaque)
+{
+ AcpiGedState *s = opaque;
+ return s->pcihp_state.use_acpi_hotplug_bridge;
+}
+
+static const VMStateDescription vmstate_pcihp_state = {
+ .name = "acpi-ged/pcihp",
+ .version_id = 1,
+ .minimum_version_id = 1,
+ .needed = pcihp_needed,
+ .fields = (const VMStateField[]) {
+ VMSTATE_PCI_HOTPLUG(pcihp_state,
+ AcpiGedState,
+ NULL, NULL),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
static const VMStateDescription vmstate_acpi_ged = {
.name = "acpi-ged",
.version_id = 1,
@@ -426,6 +445,7 @@ static const VMStateDescription vmstate_acpi_ged = {
&vmstate_memhp_state,
&vmstate_cpuhp_state,
&vmstate_ghes_state,
+ &vmstate_pcihp_state,
NULL
}
};
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 21/24] hw/core/sysbus: Introduce sysbus_mmio_map_name() helper
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (19 preceding siblings ...)
2025-04-28 10:25 ` [RFC 20/24] hw/acpi/ged: Support migration of AcpiPciHpState Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 22/24] hw/arm/virt: Let virt support pci hotplug/unplug GED event Eric Auger
` (3 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Some 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.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/sysbus.h | 1 +
hw/core/sysbus.c | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/include/hw/sysbus.h b/include/hw/sysbus.h
index 7dc88aaa27..18fde8a7b4 100644
--- a/include/hw/sysbus.h
+++ b/include/hw/sysbus.h
@@ -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);
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 6eb4c0f15a..fe1abe589d 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -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)
{
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 22/24] hw/arm/virt: Let virt support pci hotplug/unplug GED event
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (20 preceding siblings ...)
2025-04-28 10:25 ` [RFC 21/24] hw/core/sysbus: Introduce sysbus_mmio_map_name() helper Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 23/24] hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks Eric Auger
` (2 subsequent siblings)
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
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 pcie coldplug will soon require the acpi pcihp
resources allocated and reset during the ged initialization.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
include/hw/arm/virt.h | 1 +
hw/arm/virt-acpi-build.c | 1 +
hw/arm/virt.c | 35 ++++++++++++++++++++++++++++++-----
3 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index b8ca753644..6a6a8be3ff 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -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"
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 7bee57d489..fce3ab9417 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -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"
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 2790853927..aaee5443bb 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -687,6 +687,8 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms)
{
DeviceState *dev;
MachineState *ms = MACHINE(vms);
+ SysBusDevice *sbdev;
+
int irq = vms->irqmap[VIRT_ACPI_GED];
uint32_t event = ACPI_GED_PWR_DOWN_EVT;
@@ -698,12 +700,28 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms)
event |= ACPI_GED_NVDIMM_HOTPLUG_EVT;
}
+ if (vms->acpi_pcihp) {
+ event |= ACPI_GED_PCI_HOTPLUG_EVT;
+ }
+
dev = qdev_new(TYPE_ACPI_GED);
qdev_prop_set_uint32(dev, "ged-event", event);
- sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+ sbdev = SYS_BUS_DEVICE(dev);
+ sysbus_realize_and_unref(sbdev, &error_fatal);
- sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base);
- sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base);
+ sysbus_mmio_map(sbdev, 0, vms->memmap[VIRT_ACPI_GED].base);
+ sysbus_mmio_map(sbdev, 1, vms->memmap[VIRT_PCDIMM_ACPI].base);
+ if (vms->acpi_pcihp) {
+ AcpiGedState *acpi_ged_state = ACPI_GED(dev);
+ int i;
+
+ i = sysbus_mmio_map_name(sbdev, "pcihp container",
+ vms->memmap[VIRT_ACPI_PCIHP].base);
+ assert(i >= 0);
+ acpi_pcihp_init(OBJECT(dev), &acpi_ged_state->pcihp_state,
+ vms->bus, sysbus_mmio_get_region(sbdev, i), 0);
+ acpi_ged_state->pcihp_state.use_acpi_hotplug_bridge = true;
+ }
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(vms->gic, irq));
return dev;
@@ -1765,6 +1783,13 @@ void virt_machine_done(Notifier *notifier, void *data)
pci_bus_add_fw_cfg_extra_pci_roots(vms->fw_cfg, vms->bus,
&error_abort);
+
+ if (vms->acpi_pcihp) {
+ AcpiGedState *acpi_ged_state = ACPI_GED(vms->acpi_dev);
+
+ acpi_pcihp_reset(&acpi_ged_state->pcihp_state);
+ }
+
virt_acpi_setup(vms);
virt_build_smbios(vms);
}
@@ -2412,8 +2437,6 @@ static void machvirt_init(MachineState *machine)
create_rtc(vms);
- create_pcie(vms);
-
if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) {
vms->acpi_pcihp &= !vmc->no_acpi_pcihp;
vms->acpi_dev = create_acpi_ged(vms);
@@ -2422,6 +2445,8 @@ static void machvirt_init(MachineState *machine)
create_gpio_devices(vms, VIRT_GPIO, sysmem);
}
+ create_pcie(vms);
+
if (vms->secure && !vmc->no_secure_gpio) {
create_gpio_devices(vms, VIRT_SECURE_GPIO, secure_sysmem);
}
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 23/24] hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (21 preceding siblings ...)
2025-04-28 10:25 ` [RFC 22/24] hw/arm/virt: Let virt support pci hotplug/unplug GED event Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-04-28 10:25 ` [RFC 24/24] hw/arm/virt: Use ACPI PCI hotplug by default Eric Auger
2025-05-05 13:26 ` [RFC 00/24] APCI PCI Hotplug support on ARM Gustavo Romero
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/arm/virt.c | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index aaee5443bb..5e6562e754 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -87,6 +87,7 @@
#include "hw/virtio/virtio-iommu.h"
#include "hw/char/pl011.h"
#include "qemu/guest-random.h"
+#include "hw/acpi/pcihp.h"
static GlobalProperty arm_virt_compat[] = {
{ TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "48" },
@@ -2983,6 +2984,11 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
qlist_append_str(reserved_regions, resv_prop_str);
qdev_prop_set_array(dev, "reserved-regions", reserved_regions);
g_free(resv_prop_str);
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ if (vms->acpi_pcihp) {
+ acpi_pcihp_device_pre_plug_cb(HOTPLUG_HANDLER(vms->acpi_dev),
+ dev, errp);
+ }
}
}
@@ -3012,6 +3018,14 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev,
vms->iommu = VIRT_IOMMU_VIRTIO;
vms->virtio_iommu_bdf = pci_get_bdf(pdev);
create_virtio_iommu_dt_bindings(vms);
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ AcpiGedState *acpi_ged_state = ACPI_GED(vms->acpi_dev);
+ AcpiPciHpState *acpi_pci_hotplug = &acpi_ged_state->pcihp_state;
+
+ if (vms->acpi_pcihp) {
+ acpi_pcihp_device_plug_cb(HOTPLUG_HANDLER(vms->acpi_dev),
+ acpi_pci_hotplug, dev, errp);
+ }
}
}
@@ -3061,6 +3075,15 @@ static void virt_machine_device_unplug_request_cb(HotplugHandler *hotplug_dev,
} else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) {
virtio_md_pci_unplug_request(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev),
errp);
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
+ AcpiGedState *acpi_ged_state = ACPI_GED(vms->acpi_dev);
+ AcpiPciHpState *acpi_pci_hotplug = &acpi_ged_state->pcihp_state;
+
+ if (vms->acpi_pcihp) {
+ acpi_pcihp_device_unplug_request_cb(HOTPLUG_HANDLER(vms->acpi_dev),
+ acpi_pci_hotplug, dev, errp);
+ }
} else {
error_setg(errp, "device unplug request for unsupported device"
" type: %s", object_get_typename(OBJECT(dev)));
@@ -3074,6 +3097,15 @@ static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev,
virt_dimm_unplug(hotplug_dev, dev, errp);
} else if (object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI)) {
virtio_md_pci_unplug(VIRTIO_MD_PCI(dev), MACHINE(hotplug_dev), errp);
+ } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) {
+ VirtMachineState *vms = VIRT_MACHINE(hotplug_dev);
+ AcpiGedState *acpi_ged_state = ACPI_GED(vms->acpi_dev);
+ AcpiPciHpState *acpi_pci_hotplug = &acpi_ged_state->pcihp_state;
+
+ if (vms->acpi_pcihp) {
+ acpi_pcihp_device_unplug_cb(HOTPLUG_HANDLER(vms->acpi_dev),
+ acpi_pci_hotplug, dev, errp);
+ }
} else {
error_setg(errp, "virt: device unplug for unsupported device"
" type: %s", object_get_typename(OBJECT(dev)));
@@ -3084,11 +3116,14 @@ static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine,
DeviceState *dev)
{
MachineClass *mc = MACHINE_GET_CLASS(machine);
+ VirtMachineState *vms = VIRT_MACHINE(machine);
if (device_is_dynamic_sysbus(mc, dev) ||
object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_MD_PCI) ||
- object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI)) {
+ object_dynamic_cast(OBJECT(dev), TYPE_VIRTIO_IOMMU_PCI) ||
+ (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE) &&
+ vms->acpi_pcihp)) {
return HOTPLUG_HANDLER(machine);
}
return NULL;
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* [RFC 24/24] hw/arm/virt: Use ACPI PCI hotplug by default
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (22 preceding siblings ...)
2025-04-28 10:25 ` [RFC 23/24] hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks Eric Auger
@ 2025-04-28 10:25 ` Eric Auger
2025-05-05 13:26 ` [RFC 00/24] APCI PCI Hotplug support on ARM Gustavo Romero
24 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-04-28 10:25 UTC (permalink / raw)
To: eric.auger.pro, eric.auger, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Now all the enablers are there for ACPI PCI hotplug support,
let's use it by default for 10.1 virt machine onwards.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/arm/virt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 5e6562e754..ecdc1fcfbb 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -3446,8 +3446,8 @@ static void virt_instance_init(Object *obj)
}
}
- /* default disallows ACPI PCI hotplug */
- vms->acpi_pcihp = false;
+ /* default allows ACPI PCI hotplug */
+ vms->acpi_pcihp = true;
/* Default disallows iommu instantiation */
vms->iommu = VIRT_IOMMU_NONE;
--
2.49.0
^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [RFC 00/24] APCI PCI Hotplug support on ARM
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
` (23 preceding siblings ...)
2025-04-28 10:25 ` [RFC 24/24] hw/arm/virt: Use ACPI PCI hotplug by default Eric Auger
@ 2025-05-05 13:26 ` Gustavo Romero
2025-05-05 14:23 ` Eric Auger
2025-05-06 15:58 ` Eric Auger
24 siblings, 2 replies; 46+ messages in thread
From: Gustavo Romero @ 2025-05-05 13:26 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> This series enables APCI PCI hotplug/hotunplug on ARM
> and makes it default for 10.1 machine type. This aligns with
> x86 q35 machine. Expected benefits should be similar to
> those listed in [1].
>
> The infrastructure used in x86 is heavily reused and a
> huge part of the series consists in moving code from
> hw/i386/acpi-build.c to a generic place and slightly
> adapting it to make it usable on ARM. The DSDT table is
> augmented to support ACPI PCI hotplug elements.
>
> On ARM we use use a GED event to notify the OS about
> hotplug events.
>
> I have not noticed any tests/qtest/bios-tables-test failures
> neither on x86 nor ARM. x86 DSDT table has not changed.
> ARM DSDT table definitively has but there are no tests
> impacted. ARM misses hotplug tests that do exist on x86. This
> most probably should be considered in the future.
>
> Best Regards
>
> Eric
>
> This series can be found at:
> https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
>
> [1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
> https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
I've just started to review your series and went to a quick smoke test
by hotplugging a net adapter and got the following kernel internal error:
(qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
(qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000
[ 64.165895] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
[ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]
[ 64.167153] pci 0000:01:00.0: enabling Extended Tags
[ 64.179972] Internal error: synchronous external abort: 0000000096000050 [#1] SMP
[ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi virtio_net scsi_mod net_failover failover virtio_blk scsi_common crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio
[ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted 6.1.0-30-arm64 #1 Debian 6.1.124-1
[ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
[ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300
[ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334
[ 64.186490] sp : ffff80000a6bb3b0
[ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27: 0000000000000000
[ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24: 0000000000000001
[ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21: ffff0000c206cb00
[ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000
[ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
[ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12: 4d7a3553e5c937d0
[ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 : ffff800008735b34
[ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 : 00000000000000f8
[ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 : 00000000090c0018
[ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 : 0000000000000001
[ 64.190734] Call trace:
[ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300
[ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334
[ 64.192042] acpi_ex_access_region+0xe4/0x2e0
[ 64.192287] acpi_ex_field_datum_io+0x88/0x200
[ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120
[ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0
[ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190
[ 64.193298] acpi_ex_store_object_to_node+0x150/0x240
[ 64.193527] acpi_ex_store+0x144/0x300
[ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0
[ 64.194227] acpi_ps_parse_loop+0x100/0x6a0
[ 64.194477] acpi_ps_parse_aml+0x94/0x3b0
[ 64.194674] acpi_ps_execute_method+0x128/0x25c
[ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0
[ 64.195148] acpi_evaluate_object+0x138/0x2d0
[ 64.195380] acpi_evaluate_dsm+0xb8/0x134
[ 64.195613] acpi_check_dsm+0x34/0xdc
[ 64.195822] smbios_attr_is_visible+0x5c/0xb0
[ 64.196089] internal_create_group+0xd0/0x3d0
[ 64.196335] internal_create_groups+0x58/0xe0
[ 64.196584] sysfs_create_groups+0x20/0x30
[ 64.196813] device_add_groups+0x18/0x2c
[ 64.197039] bus_add_device+0x48/0x160
[ 64.197260] device_add+0x3a4/0x85c
[ 64.197463] pci_device_add+0x308/0x660
[ 64.197680] pci_scan_single_device+0xe4/0x114
[ 64.197941] pci_scan_slot+0x70/0x1fc
[ 64.198155] acpiphp_rescan_slot+0x90/0xa4
[ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300
[ 64.198584] acpi_device_hotplug+0x138/0x4c0
[ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c
[ 64.199045] process_one_work+0x1f4/0x460
[ 64.199277] worker_thread+0x188/0x4e0
[ 64.199492] kthread+0xe0/0xe4
[ 64.199671] ret_from_fork+0x10/0x20
[ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
[ 64.200820] ---[ end trace 0000000000000000 ]---
(qemu)
This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH branch.
The machine was started with:
./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu cortex-a57 -initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device virtio-scsi-pci -device virtio-blk-pci,drive=root -drive if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios ./pc-bios/edk2-aarch64-code.fd
./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so nothing special.
It seems Linux acpi crashed when ingesting the _DSM method but I could not
figure out what exactly in it could cause it.
Cheers,
Gustavo
>
> Eric Auger (24):
> hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
> hw/acpi/ged: Fix wrong identation
> hw/i386/acpi-build: Fix build_append_notfication_callback typo
> hw/i386/acpi-build: Make aml_pci_device_dsm() static
> hw/arm/virt: Introduce machine state acpi pcihp flags and props
> hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
> hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to
> acpi_dsdt_add_pci_osc
> hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
> hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine
> downto gpex
> hw/i386/acpi-build: Turn build_q35_osc_method into a generic method
> hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
> hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
> hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
> hw/i386/acpi-build: Move build_append_notification_callback to pcihp
> hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp
> hw/i386/acpi-build: Introduce and use acpi_get_pci_host
> hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug
> hw/acpi/ged: Prepare the device to react to PCI hotplug events
> hw/acpi/ged: Call pcihp plug callbacks in hotplug handler
> implementation
> hw/acpi/ged: Support migration of AcpiPciHpState
> hw/core/sysbus: Introduce sysbus_mmio_map_name() helper
> hw/arm/virt: Let virt support pci hotplug/unplug GED event
> hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks
> hw/arm/virt: Use ACPI PCI hotplug by default
>
> hw/i386/acpi-build.h | 4 -
> include/hw/acpi/aml-build.h | 2 +
> include/hw/acpi/generic_event_device.h | 5 +
> include/hw/acpi/pci.h | 4 +-
> include/hw/acpi/pcihp.h | 14 +
> include/hw/arm/virt.h | 4 +
> include/hw/pci-host/gpex.h | 1 +
> include/hw/sysbus.h | 1 +
> hw/acpi/aml-build.c | 50 +++
> hw/acpi/generic_event_device.c | 64 +++-
> hw/acpi/pci.c | 20 ++
> hw/acpi/pcihp.c | 428 +++++++++++++++++++++-
> hw/arm/virt-acpi-build.c | 26 ++
> hw/arm/virt.c | 100 +++++-
> hw/core/sysbus.c | 11 +
> hw/i386/acpi-build.c | 475 +------------------------
> hw/pci-host/gpex-acpi.c | 75 +---
> hw/pci/pcie_port.c | 4 +-
> hw/arm/Kconfig | 2 +
> 19 files changed, 748 insertions(+), 542 deletions(-)
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 00/24] APCI PCI Hotplug support on ARM
2025-05-05 13:26 ` [RFC 00/24] APCI PCI Hotplug support on ARM Gustavo Romero
@ 2025-05-05 14:23 ` Eric Auger
2025-05-06 15:58 ` Eric Auger
1 sibling, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-05-05 14:23 UTC (permalink / raw)
To: Gustavo Romero, eric.auger.pro, qemu-devel, qemu-arm,
peter.maydell, imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Gustavo,
On 5/5/25 3:26 PM, Gustavo Romero wrote:
> Hi Eric,
>
> On 4/28/25 07:25, Eric Auger wrote:
>> This series enables APCI PCI hotplug/hotunplug on ARM
>> and makes it default for 10.1 machine type. This aligns with
>> x86 q35 machine. Expected benefits should be similar to
>> those listed in [1].
>>
>> The infrastructure used in x86 is heavily reused and a
>> huge part of the series consists in moving code from
>> hw/i386/acpi-build.c to a generic place and slightly
>> adapting it to make it usable on ARM. The DSDT table is
>> augmented to support ACPI PCI hotplug elements.
>>
>> On ARM we use use a GED event to notify the OS about
>> hotplug events.
>>
>> I have not noticed any tests/qtest/bios-tables-test failures
>> neither on x86 nor ARM. x86 DSDT table has not changed.
>> ARM DSDT table definitively has but there are no tests
>> impacted. ARM misses hotplug tests that do exist on x86. This
>> most probably should be considered in the future.
>>
>> Best Regards
>>
>> Eric
>>
>> This series can be found at:
>> https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
>>
>> [1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
>> https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
>
> I've just started to review your series and went to a quick smoke test
> by hotplugging a net adapter and got the following kernel internal error:
>
> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
> (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class
> 0x020000
> [ 64.165895] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
> [ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff
> 64bit pref]
> [ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff
> pref]
> [ 64.167153] pci 0000:01:00.0: enabling Extended Tags
> [ 64.179972] Internal error: synchronous external abort:
> 0000000096000050 [#1] SMP
> [ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce
> polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64
> sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse
> efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables
> x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi
> virtio_net scsi_mod net_failover failover virtio_blk scsi_common
> crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev
> virtio_pci_modern_dev virtio_mmio
> [ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted
> 6.1.0-30-arm64 #1 Debian 6.1.124-1
> [ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS
> edk2-stable202408-prebuilt.qemu.org 08/13/2024
> [ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
> [ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS
> BTYPE=--)
> [ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300
> [ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334
> [ 64.186490] sp : ffff80000a6bb3b0
> [ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27:
> 0000000000000000
> [ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24:
> 0000000000000001
> [ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21:
> ffff0000c206cb00
> [ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18:
> 0000000000000000
> [ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
> 0000000000000000
> [ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12:
> 4d7a3553e5c937d0
> [ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :
> ffff800008735b34
> [ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 :
> 00000000000000f8
> [ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 :
> 00000000090c0018
> [ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 :
> 0000000000000001
> [ 64.190734] Call trace:
> [ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300
> [ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334
> [ 64.192042] acpi_ex_access_region+0xe4/0x2e0
> [ 64.192287] acpi_ex_field_datum_io+0x88/0x200
> [ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120
> [ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0
> [ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190
> [ 64.193298] acpi_ex_store_object_to_node+0x150/0x240
> [ 64.193527] acpi_ex_store+0x144/0x300
> [ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580
> [ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0
> [ 64.194227] acpi_ps_parse_loop+0x100/0x6a0
> [ 64.194477] acpi_ps_parse_aml+0x94/0x3b0
> [ 64.194674] acpi_ps_execute_method+0x128/0x25c
> [ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0
> [ 64.195148] acpi_evaluate_object+0x138/0x2d0
> [ 64.195380] acpi_evaluate_dsm+0xb8/0x134
> [ 64.195613] acpi_check_dsm+0x34/0xdc
> [ 64.195822] smbios_attr_is_visible+0x5c/0xb0
> [ 64.196089] internal_create_group+0xd0/0x3d0
> [ 64.196335] internal_create_groups+0x58/0xe0
> [ 64.196584] sysfs_create_groups+0x20/0x30
> [ 64.196813] device_add_groups+0x18/0x2c
> [ 64.197039] bus_add_device+0x48/0x160
> [ 64.197260] device_add+0x3a4/0x85c
> [ 64.197463] pci_device_add+0x308/0x660
> [ 64.197680] pci_scan_single_device+0xe4/0x114
> [ 64.197941] pci_scan_slot+0x70/0x1fc
> [ 64.198155] acpiphp_rescan_slot+0x90/0xa4
> [ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300
> [ 64.198584] acpi_device_hotplug+0x138/0x4c0
> [ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c
> [ 64.199045] process_one_work+0x1f4/0x460
> [ 64.199277] worker_thread+0x188/0x4e0
> [ 64.199492] kthread+0xe0/0xe4
> [ 64.199671] ret_from_fork+0x10/0x20
> [ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
> [ 64.200820] ---[ end trace 0000000000000000 ]---
>
> (qemu)
>
> This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH
> branch.
>
> The machine was started with:
>
> ./qemu-system-aarch64 -m 16G -nographic -machine
> type=virt,gic-version=max -cpu cortex-a57 -initrd
> /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64
> -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device
> virtio-scsi-pci -device virtio-blk-pci,drive=root -drive
> if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device
> pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios
> ./pc-bios/edk2-aarch64-code.fd
>
> ./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so
> nothing special.
>
> It seems Linux acpi crashed when ingesting the _DSM method but I could
> not
> figure out what exactly in it could cause it.
Thank you for reporting this issue.
On my end I tested with rhel guest and recent EDK2 while
hotplugging/hot-unplugging VFIO devices.
I will try to reproduce
Eric
>
>
> Cheers,
> Gustavo
>
>>
>> Eric Auger (24):
>> hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
>> hw/acpi/ged: Fix wrong identation
>> hw/i386/acpi-build: Fix build_append_notfication_callback typo
>> hw/i386/acpi-build: Make aml_pci_device_dsm() static
>> hw/arm/virt: Introduce machine state acpi pcihp flags and props
>> hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
>> hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to
>> acpi_dsdt_add_pci_osc
>> hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
>> hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine
>> downto gpex
>> hw/i386/acpi-build: Turn build_q35_osc_method into a generic method
>> hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
>> hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
>> hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
>> hw/i386/acpi-build: Move build_append_notification_callback to pcihp
>> hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp
>> hw/i386/acpi-build: Introduce and use acpi_get_pci_host
>> hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug
>> hw/acpi/ged: Prepare the device to react to PCI hotplug events
>> hw/acpi/ged: Call pcihp plug callbacks in hotplug handler
>> implementation
>> hw/acpi/ged: Support migration of AcpiPciHpState
>> hw/core/sysbus: Introduce sysbus_mmio_map_name() helper
>> hw/arm/virt: Let virt support pci hotplug/unplug GED event
>> hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks
>> hw/arm/virt: Use ACPI PCI hotplug by default
>>
>> hw/i386/acpi-build.h | 4 -
>> include/hw/acpi/aml-build.h | 2 +
>> include/hw/acpi/generic_event_device.h | 5 +
>> include/hw/acpi/pci.h | 4 +-
>> include/hw/acpi/pcihp.h | 14 +
>> include/hw/arm/virt.h | 4 +
>> include/hw/pci-host/gpex.h | 1 +
>> include/hw/sysbus.h | 1 +
>> hw/acpi/aml-build.c | 50 +++
>> hw/acpi/generic_event_device.c | 64 +++-
>> hw/acpi/pci.c | 20 ++
>> hw/acpi/pcihp.c | 428 +++++++++++++++++++++-
>> hw/arm/virt-acpi-build.c | 26 ++
>> hw/arm/virt.c | 100 +++++-
>> hw/core/sysbus.c | 11 +
>> hw/i386/acpi-build.c | 475 +------------------------
>> hw/pci-host/gpex-acpi.c | 75 +---
>> hw/pci/pcie_port.c | 4 +-
>> hw/arm/Kconfig | 2 +
>> 19 files changed, 748 insertions(+), 542 deletions(-)
>>
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 01/24] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
2025-04-28 10:25 ` [RFC 01/24] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo Eric Auger
@ 2025-05-06 0:11 ` Gustavo Romero
0 siblings, 0 replies; 46+ messages in thread
From: Gustavo Romero @ 2025-05-06 0:11 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> hw/pci/pcie_port.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/pci/pcie_port.c b/hw/pci/pcie_port.c
> index c73db30e98..072500ed34 100644
> --- a/hw/pci/pcie_port.c
> +++ b/hw/pci/pcie_port.c
> @@ -188,7 +188,7 @@ int pcie_count_ds_ports(PCIBus *bus)
> return dsp_count;
> }
>
> -static bool pcie_slot_is_hotpluggbale_bus(HotplugHandler *plug_handler,
> +static bool pcie_slot_is_hotpluggable_bus(HotplugHandler *plug_handler,
> BusState *bus)
> {
> PCIESlot *s = PCIE_SLOT(bus->parent);
> @@ -221,7 +221,7 @@ static void pcie_slot_class_init(ObjectClass *oc, void *data)
> hc->plug = pcie_cap_slot_plug_cb;
> hc->unplug = pcie_cap_slot_unplug_cb;
> hc->unplug_request = pcie_cap_slot_unplug_request_cb;
> - hc->is_hotpluggable_bus = pcie_slot_is_hotpluggbale_bus;
> + hc->is_hotpluggable_bus = pcie_slot_is_hotpluggable_bus;
> }
>
> static const TypeInfo pcie_slot_type_info = {
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 02/24] hw/acpi/ged: Fix wrong identation
2025-04-28 10:25 ` [RFC 02/24] hw/acpi/ged: Fix wrong identation Eric Auger
@ 2025-05-06 0:11 ` Gustavo Romero
0 siblings, 0 replies; 46+ messages in thread
From: Gustavo Romero @ 2025-05-06 0:11 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> hw/acpi/generic_event_device.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
> index c85d97ca37..7b2d582fff 100644
> --- a/hw/acpi/generic_event_device.c
> +++ b/hw/acpi/generic_event_device.c
> @@ -458,11 +458,11 @@ static void acpi_ged_initfn(Object *obj)
> * container for memory hotplug IO and expose it as GED sysbus
> * MMIO so that boards can map it separately.
> */
> - memory_region_init(&s->container_memhp, OBJECT(dev), "memhp container",
> - MEMORY_HOTPLUG_IO_LEN);
> - sysbus_init_mmio(sbd, &s->container_memhp);
> - acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
> - &s->memhp_state, 0);
> + memory_region_init(&s->container_memhp, OBJECT(dev), "memhp container",
> + MEMORY_HOTPLUG_IO_LEN);
> + sysbus_init_mmio(sbd, &s->container_memhp);
> + acpi_memory_hotplug_init(&s->container_memhp, OBJECT(dev),
> + &s->memhp_state, 0);
>
> memory_region_init_io(&ged_st->regs, obj, &ged_regs_ops, ged_st,
> TYPE_ACPI_GED "-regs", ACPI_GED_REG_COUNT);
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 03/24] hw/i386/acpi-build: Fix build_append_notfication_callback typo
2025-04-28 10:25 ` [RFC 03/24] hw/i386/acpi-build: Fix build_append_notfication_callback typo Eric Auger
@ 2025-05-06 0:11 ` Gustavo Romero
0 siblings, 0 replies; 46+ messages in thread
From: Gustavo Romero @ 2025-05-06 0:11 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> Rename build_append_notfication_callback into
> build_append_notification_callback
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> hw/i386/acpi-build.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 3fffa4a332..85c8a8566b 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -589,8 +589,8 @@ void build_append_pci_bus_devices(Aml *parent_scope, PCIBus *bus)
> }
> }
>
> -static bool build_append_notfication_callback(Aml *parent_scope,
> - const PCIBus *bus)
> +static bool build_append_notification_callback(Aml *parent_scope,
> + const PCIBus *bus)
> {
> Aml *method;
> PCIBus *sec;
> @@ -604,7 +604,7 @@ static bool build_append_notfication_callback(Aml *parent_scope,
> continue;
> }
> nr_notifiers = nr_notifiers +
> - build_append_notfication_callback(br_scope, sec);
> + build_append_notification_callback(br_scope, sec);
> /*
> * add new child scope to parent
> * and keep track of bus that have PCNT,
> @@ -1773,7 +1773,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> PCIBus *b = PCI_HOST_BRIDGE(pci_host)->bus;
>
> scope = aml_scope("\\_SB.PCI0");
> - has_pcnt = build_append_notfication_callback(scope, b);
> + has_pcnt = build_append_notification_callback(scope, b);
> if (has_pcnt) {
> aml_append(dsdt, scope);
> }
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props
2025-04-28 10:25 ` [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props Eric Auger
@ 2025-05-06 0:12 ` Gustavo Romero
2025-05-06 8:42 ` Eric Auger
0 siblings, 1 reply; 46+ messages in thread
From: Gustavo Romero @ 2025-05-06 0:12 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> acpi_pcihp VirtMachineClass state flag will allow
> to opt in for acpi pci hotplug. This is guarded by a
> class no_acpi_pcihp flag to manage compats (<= 10.0
> machine types will not support ACPI PCI hotplug).
>
> Machine state acpi_pcihp flag msu be set before the creation
nit: ^--- must be set
> of the GED device which will use it.
>
> Currently the ACPI PCI HP is turned off by default. This will
> change later on for 10.1 machine type.
>
> We also introduce properties to allow disabling it.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> include/hw/arm/virt.h | 2 ++
> hw/arm/virt.c | 27 +++++++++++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index c8e94e6aed..1e9d002880 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -135,6 +135,7 @@ struct VirtMachineClass {
> bool no_tcg_lpa2;
> bool no_ns_el2_virt_timer_irq;
> bool no_nested_smmu;
> + bool no_acpi_pcihp;
> };
>
> struct VirtMachineState {
> @@ -156,6 +157,7 @@ struct VirtMachineState {
> bool mte;
> bool dtb_randomness;
> bool second_ns_uart_present;
> + bool acpi_pcihp;
> OnOffAuto acpi;
> VirtGICType gic_version;
> VirtIOMMUType iommu;
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 3e72adaa91..1601750913 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine)
> create_pcie(vms);
>
> if (has_ged && aarch64 && firmware_loaded && virt_is_acpi_enabled(vms)) {
> + vms->acpi_pcihp &= !vmc->no_acpi_pcihp;
> vms->acpi_dev = create_acpi_ged(vms);
> } else {
> + vms->acpi_pcihp = false;
> create_gpio_devices(vms, VIRT_GPIO, sysmem);
> }
>
> @@ -2610,6 +2612,20 @@ static void virt_set_its(Object *obj, bool value, Error **errp)
> vms->its = value;
> }
>
> +static bool virt_get_acpi_pcihp(Object *obj, Error **errp)
> +{
> + VirtMachineState *vms = VIRT_MACHINE(obj);
> +
> + return vms->acpi_pcihp;
> +}
> +
> +static void virt_set_acpi_pcihp(Object *obj, bool value, Error **errp)
> +{
> + VirtMachineState *vms = VIRT_MACHINE(obj);
> +
> + vms->acpi_pcihp = value;
> +}
> +
> static bool virt_get_dtb_randomness(Object *obj, Error **errp)
> {
> VirtMachineState *vms = VIRT_MACHINE(obj);
> @@ -3327,6 +3343,10 @@ static void virt_machine_class_init(ObjectClass *oc, void *data)
> "in ACPI table header."
> "The string may be up to 8 bytes in size");
>
> + object_class_property_add_bool(oc, "acpi-pcihp",
> + virt_get_acpi_pcihp, virt_set_acpi_pcihp);
> + object_class_property_set_description(oc, "acpi-pcihp",
> + "Force acpi pci hotplug");
How about "Force ACPI PCI hotplug"?
> }
>
> static void virt_instance_init(Object *obj)
> @@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj)
> }
> }
>
> + /* default disallows ACPI PCI hotplug */
> + vms->acpi_pcihp = false;
> +
> /* Default disallows iommu instantiation */
> vms->iommu = VIRT_IOMMU_NONE;
>
> @@ -3415,8 +3438,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)
>
> static void virt_machine_10_0_options(MachineClass *mc)
> {
> + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
> +
> virt_machine_10_1_options(mc);
> compat_props_add(mc->compat_props, hw_compat_10_0, hw_compat_10_0_len);
> + /* 10.0 and earlier do not support ACPI PCI hotplug */
> + vmc->no_acpi_pcihp = true;
> }
> DEFINE_VIRT_MACHINE(10, 0)
>
Otherwise,
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
2025-04-28 10:25 ` [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp Eric Auger
@ 2025-05-06 0:12 ` Gustavo Romero
2025-05-06 8:42 ` Eric Auger
0 siblings, 1 reply; 46+ messages in thread
From: Gustavo Romero @ 2025-05-06 0:12 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger 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_hotplug is renamed into build_acpi_pci_hotplug().
>
> No code change intended.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> hw/i386/acpi-build.h | 4 -
> include/hw/acpi/pcihp.h | 6 ++
> hw/acpi/pcihp.c | 174 +++++++++++++++++++++++++++++++++++++++-
> hw/i386/acpi-build.c | 150 +---------------------------------
> 4 files changed, 181 insertions(+), 153 deletions(-)
>
> diff --git a/hw/i386/acpi-build.h b/hw/i386/acpi-build.h
> index 0dce155c8c..8ba3c33e48 100644
> --- a/hw/i386/acpi-build.h
> +++ b/hw/i386/acpi-build.h
> @@ -5,10 +5,6 @@
>
> extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
>
> -/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */
> -#define ACPI_PCIHP_SEJ_BASE 0x8
> -#define ACPI_PCIHP_BNMR_BASE 0x10
> -
> void acpi_setup(void);
> Object *acpi_get_i386_pci_host(void);
>
> diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
> index ac21a95913..2da0bc45c9 100644
> --- a/include/hw/acpi/pcihp.h
> +++ b/include/hw/acpi/pcihp.h
> @@ -33,6 +33,10 @@
> #define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"
> #define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len"
>
> +/* PCI Hot-plug registers bases. See docs/spec/acpi_pci_hotplug.txt */
This reference needs to be updated to point to acpi_pci_hotplug.rst.
Otherwise,
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Cheers,
Gustavo
> +#define ACPI_PCIHP_SEJ_BASE 0x8
> +#define ACPI_PCIHP_BNMR_BASE 0x10
> +
> typedef struct AcpiPciHpPciStatus {
> uint32_t up;
> uint32_t down;
> @@ -69,6 +73,8 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
> AcpiPciHpState *s, DeviceState *dev,
> Error **errp);
>
> +void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr);
> +
> /* Called on reset */
> void acpi_pcihp_reset(AcpiPciHpState *s);
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 5f79c9016b..35d8c0bfd2 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -26,7 +26,7 @@
>
> #include "qemu/osdep.h"
> #include "hw/acpi/pcihp.h"
> -
> +#include "hw/acpi/aml-build.h"
> #include "hw/pci-host/i440fx.h"
> #include "hw/pci/pci.h"
> #include "hw/pci/pci_bridge.h"
> @@ -513,6 +513,178 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState *s, PCIBus *root_bus,
> OBJ_PROP_FLAG_READ);
> }
>
> +static void build_append_pci_dsm_func0_common(Aml *ctx, Aml *retvar)
> +{
> + Aml *UUID, *ifctx1;
> + uint8_t byte_list[1] = { 0 }; /* nothing supported yet */
> +
> + aml_append(ctx, aml_store(aml_buffer(1, byte_list), retvar));
> + /*
> + * PCI Firmware Specification 3.1
> + * 4.6. _DSM Definitions for PCI
> + */
> + UUID = aml_touuid("E5C937D0-3553-4D7A-9117-EA4D19C3434D");
> + ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(0), UUID)));
> + {
> + /* call is for unsupported UUID, bail out */
> + aml_append(ifctx1, aml_return(retvar));
> + }
> + aml_append(ctx, ifctx1);
> +
> + ifctx1 = aml_if(aml_lless(aml_arg(1), aml_int(2)));
> + {
> + /* call is for unsupported REV, bail out */
> + aml_append(ifctx1, aml_return(retvar));
> + }
> + aml_append(ctx, ifctx1);
> +}
> +
> +static Aml *aml_pci_pdsm(void)
> +{
> + Aml *method, *ifctx, *ifctx1;
> + Aml *ret = aml_local(0);
> + Aml *caps = aml_local(1);
> + Aml *acpi_index = aml_local(2);
> + Aml *zero = aml_int(0);
> + Aml *one = aml_int(1);
> + Aml *not_supp = aml_int(0xFFFFFFFF);
> + Aml *func = aml_arg(2);
> + Aml *params = aml_arg(4);
> + Aml *bnum = aml_derefof(aml_index(params, aml_int(0)));
> + Aml *sunum = aml_derefof(aml_index(params, aml_int(1)));
> +
> + method = aml_method("PDSM", 5, AML_SERIALIZED);
> +
> + /* get supported functions */
> + ifctx = aml_if(aml_equal(func, zero));
> + {
> + build_append_pci_dsm_func0_common(ifctx, ret);
> +
> + aml_append(ifctx, aml_store(zero, caps));
> + aml_append(ifctx,
> + aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
> + /*
> + * advertise function 7 if device has acpi-index
> + * acpi_index values:
> + * 0: not present (default value)
> + * FFFFFFFF: not supported (old QEMU without PIDX reg)
> + * other: device's acpi-index
> + */
> + ifctx1 = aml_if(aml_lnot(
> + aml_or(aml_equal(acpi_index, zero),
> + aml_equal(acpi_index, not_supp), NULL)
> + ));
> + {
> + /* have supported functions */
> + aml_append(ifctx1, aml_or(caps, one, caps));
> + /* support for function 7 */
> + aml_append(ifctx1,
> + aml_or(caps, aml_shiftleft(one, aml_int(7)), caps));
> + }
> + aml_append(ifctx, ifctx1);
> +
> + aml_append(ifctx, aml_store(caps, aml_index(ret, zero)));
> + aml_append(ifctx, aml_return(ret));
> + }
> + aml_append(method, ifctx);
> +
> + /* handle specific functions requests */
> + /*
> + * PCI Firmware Specification 3.1
> + * 4.6.7. _DSM for Naming a PCI or PCI Express Device Under
> + * Operating Systems
> + */
> + ifctx = aml_if(aml_equal(func, aml_int(7)));
> + {
> + Aml *pkg = aml_package(2);
> +
> + aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
> + aml_append(ifctx, aml_store(pkg, ret));
> + /*
> + * Windows calls func=7 without checking if it's available,
> + * as workaround Microsoft has suggested to return invalid for func7
> + * Package, so return 2 elements package but only initialize elements
> + * when acpi_index is supported and leave them uninitialized, which
> + * leads elements to being Uninitialized ObjectType and should trip
> + * Windows into discarding result as an unexpected and prevent setting
> + * bogus 'PCI Label' on the device.
> + */
> + ifctx1 = aml_if(aml_lnot(aml_lor(
> + aml_equal(acpi_index, zero), aml_equal(acpi_index, not_supp)
> + )));
> + {
> + aml_append(ifctx1, aml_store(acpi_index, aml_index(ret, zero)));
> + /*
> + * optional, if not impl. should return null string
> + */
> + aml_append(ifctx1, aml_store(aml_string("%s", ""),
> + aml_index(ret, one)));
> + }
> + aml_append(ifctx, ifctx1);
> +
> + aml_append(ifctx, aml_return(ret));
> + }
> +
> + aml_append(method, ifctx);
> + return method;
> +}
> +
> +void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr)
> +{
> + Aml *scope;
> + Aml *field;
> + Aml *method;
> +
> + scope = aml_scope("_SB.PCI0");
> +
> + aml_append(scope,
> + aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(pcihp_addr), 0x08));
> + field = aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
> + aml_append(field, aml_named_field("PCIU", 32));
> + aml_append(field, aml_named_field("PCID", 32));
> + aml_append(scope, field);
> +
> + aml_append(scope,
> + aml_operation_region("SEJ", AML_SYSTEM_IO,
> + aml_int(pcihp_addr + ACPI_PCIHP_SEJ_BASE), 0x04));
> + field = aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
> + aml_append(field, aml_named_field("B0EJ", 32));
> + aml_append(scope, field);
> +
> + aml_append(scope,
> + aml_operation_region("BNMR", AML_SYSTEM_IO,
> + aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0x08));
> + field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
> + aml_append(field, aml_named_field("BNUM", 32));
> + aml_append(field, aml_named_field("PIDX", 32));
> + aml_append(scope, field);
> +
> + aml_append(scope, aml_mutex("BLCK", 0));
> +
> + method = aml_method("PCEJ", 2, AML_NOTSERIALIZED);
> + aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
> + aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
> + aml_append(method,
> + aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("B0EJ")));
> + aml_append(method, aml_release(aml_name("BLCK")));
> + aml_append(method, aml_return(aml_int(0)));
> + aml_append(scope, method);
> +
> + method = aml_method("AIDX", 2, AML_NOTSERIALIZED);
> + aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
> + aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
> + aml_append(method,
> + aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("PIDX")));
> + aml_append(method, aml_store(aml_name("PIDX"), aml_local(0)));
> + aml_append(method, aml_release(aml_name("BLCK")));
> + aml_append(method, aml_return(aml_local(0)));
> + aml_append(scope, method);
> +
> + aml_append(scope, aml_pci_pdsm());
> +
> + aml_append(table, scope);
> +}
> +
> const VMStateDescription vmstate_acpi_pcihp_pci_status = {
> .name = "acpi_pcihp_pci_status",
> .version_id = 1,
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 864f6b5bf8..2d1eea4a1a 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -647,96 +647,6 @@ static bool build_append_notification_callback(Aml *parent_scope,
> return !!nr_notifiers;
> }
>
> -static Aml *aml_pci_pdsm(void)
> -{
> - Aml *method, *ifctx, *ifctx1;
> - Aml *ret = aml_local(0);
> - Aml *caps = aml_local(1);
> - Aml *acpi_index = aml_local(2);
> - Aml *zero = aml_int(0);
> - Aml *one = aml_int(1);
> - Aml *not_supp = aml_int(0xFFFFFFFF);
> - Aml *func = aml_arg(2);
> - Aml *params = aml_arg(4);
> - Aml *bnum = aml_derefof(aml_index(params, aml_int(0)));
> - Aml *sunum = aml_derefof(aml_index(params, aml_int(1)));
> -
> - method = aml_method("PDSM", 5, AML_SERIALIZED);
> -
> - /* get supported functions */
> - ifctx = aml_if(aml_equal(func, zero));
> - {
> - build_append_pci_dsm_func0_common(ifctx, ret);
> -
> - aml_append(ifctx, aml_store(zero, caps));
> - aml_append(ifctx,
> - aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
> - /*
> - * advertise function 7 if device has acpi-index
> - * acpi_index values:
> - * 0: not present (default value)
> - * FFFFFFFF: not supported (old QEMU without PIDX reg)
> - * other: device's acpi-index
> - */
> - ifctx1 = aml_if(aml_lnot(
> - aml_or(aml_equal(acpi_index, zero),
> - aml_equal(acpi_index, not_supp), NULL)
> - ));
> - {
> - /* have supported functions */
> - aml_append(ifctx1, aml_or(caps, one, caps));
> - /* support for function 7 */
> - aml_append(ifctx1,
> - aml_or(caps, aml_shiftleft(one, aml_int(7)), caps));
> - }
> - aml_append(ifctx, ifctx1);
> -
> - aml_append(ifctx, aml_store(caps, aml_index(ret, zero)));
> - aml_append(ifctx, aml_return(ret));
> - }
> - aml_append(method, ifctx);
> -
> - /* handle specific functions requests */
> - /*
> - * PCI Firmware Specification 3.1
> - * 4.6.7. _DSM for Naming a PCI or PCI Express Device Under
> - * Operating Systems
> - */
> - ifctx = aml_if(aml_equal(func, aml_int(7)));
> - {
> - Aml *pkg = aml_package(2);
> -
> - aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
> - aml_append(ifctx, aml_store(pkg, ret));
> - /*
> - * Windows calls func=7 without checking if it's available,
> - * as workaround Microsoft has suggested to return invalid for func7
> - * Package, so return 2 elements package but only initialize elements
> - * when acpi_index is supported and leave them uninitialized, which
> - * leads elements to being Uninitialized ObjectType and should trip
> - * Windows into discarding result as an unexpected and prevent setting
> - * bogus 'PCI Label' on the device.
> - */
> - ifctx1 = aml_if(aml_lnot(aml_lor(
> - aml_equal(acpi_index, zero), aml_equal(acpi_index, not_supp)
> - )));
> - {
> - aml_append(ifctx1, aml_store(acpi_index, aml_index(ret, zero)));
> - /*
> - * optional, if not impl. should return null string
> - */
> - aml_append(ifctx1, aml_store(aml_string("%s", ""),
> - aml_index(ret, one)));
> - }
> - aml_append(ifctx, ifctx1);
> -
> - aml_append(ifctx, aml_return(ret));
> - }
> -
> - aml_append(method, ifctx);
> - return method;
> -}
> -
> /*
> * build_prt - Define interrupt routing rules
> *
> @@ -1227,62 +1137,6 @@ static Aml *build_q35_dram_controller(const AcpiMcfgInfo *mcfg)
> return dev;
> }
>
> -static void build_x86_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr)
> -{
> - Aml *scope;
> - Aml *field;
> - Aml *method;
> -
> - scope = aml_scope("_SB.PCI0");
> -
> - aml_append(scope,
> - aml_operation_region("PCST", AML_SYSTEM_IO, aml_int(pcihp_addr), 0x08));
> - field = aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
> - aml_append(field, aml_named_field("PCIU", 32));
> - aml_append(field, aml_named_field("PCID", 32));
> - aml_append(scope, field);
> -
> - aml_append(scope,
> - aml_operation_region("SEJ", AML_SYSTEM_IO,
> - aml_int(pcihp_addr + ACPI_PCIHP_SEJ_BASE), 0x04));
> - field = aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
> - aml_append(field, aml_named_field("B0EJ", 32));
> - aml_append(scope, field);
> -
> - aml_append(scope,
> - aml_operation_region("BNMR", AML_SYSTEM_IO,
> - aml_int(pcihp_addr + ACPI_PCIHP_BNMR_BASE), 0x08));
> - field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK, AML_WRITE_AS_ZEROS);
> - aml_append(field, aml_named_field("BNUM", 32));
> - aml_append(field, aml_named_field("PIDX", 32));
> - aml_append(scope, field);
> -
> - aml_append(scope, aml_mutex("BLCK", 0));
> -
> - method = aml_method("PCEJ", 2, AML_NOTSERIALIZED);
> - aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
> - aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
> - aml_append(method,
> - aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("B0EJ")));
> - aml_append(method, aml_release(aml_name("BLCK")));
> - aml_append(method, aml_return(aml_int(0)));
> - aml_append(scope, method);
> -
> - method = aml_method("AIDX", 2, AML_NOTSERIALIZED);
> - aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
> - aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
> - aml_append(method,
> - aml_store(aml_shiftleft(aml_int(1), aml_arg(1)), aml_name("PIDX")));
> - aml_append(method, aml_store(aml_name("PIDX"), aml_local(0)));
> - aml_append(method, aml_release(aml_name("BLCK")));
> - aml_append(method, aml_return(aml_local(0)));
> - aml_append(scope, method);
> -
> - aml_append(scope, aml_pci_pdsm());
> -
> - aml_append(table, scope);
> -}
> -
> static Aml *build_q35_osc_method(bool enable_native_pcie_hotplug)
> {
> Aml *if_ctx;
> @@ -1394,7 +1248,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> aml_append(dsdt, sb_scope);
>
> if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
> - build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
> + build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
> }
> build_piix4_pci0_int(dsdt);
> } else if (q35) {
> @@ -1438,7 +1292,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
> aml_append(dsdt, sb_scope);
>
> if (pm->pcihp_bridge_en) {
> - build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
> + build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
> }
> build_q35_pci0_int(dsdt);
> }
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
2025-04-28 10:25 ` [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc Eric Auger
@ 2025-05-06 0:13 ` Gustavo Romero
2025-05-06 8:42 ` Eric Auger
0 siblings, 1 reply; 46+ messages in thread
From: Gustavo Romero @ 2025-05-06 0:13 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> Add a new argument to acpi_dsdt_add_pci_osc to be able to disable
> native pci hotplug.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> hw/pci-host/gpex-acpi.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
> index e8b4c64c5f..4016089893 100644
> --- a/hw/pci-host/gpex-acpi.c
> +++ b/hw/pci-host/gpex-acpi.c
> @@ -50,7 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev, uint32_t irq,
> }
> }
>
> -static void acpi_dsdt_add_pci_osc(Aml *dev)
> +static void acpi_dsdt_add_pci_osc(Aml *dev, bool enable_native_pcie_hotplug)
> {
> Aml *method, *UUID, *ifctx, *ifctx1, *elsectx, *buf;
>
> @@ -80,8 +80,9 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)
> * Allow OS control for all 5 features:
> * PCIeHotplug SHPCHotplug PME AER PCIeCapability.
This comment is no longer true for PCIeHotplug, which now can be
controlled by the platform, and so needs to be updated, although
it's going to go away in the series.
Otherwise:
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Cheers,
Gustavo
> */
> - 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")));
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 08/24] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
2025-04-28 10:25 ` [RFC 08/24] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation Eric Auger
@ 2025-05-06 0:13 ` Gustavo Romero
0 siblings, 0 replies; 46+ messages in thread
From: Gustavo Romero @ 2025-05-06 0:13 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> acpi_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.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> hw/pci-host/gpex-acpi.c | 31 +++++++++++++++++++++----------
> 1 file changed, 21 insertions(+), 10 deletions(-)
>
> diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
> index 4016089893..9d9f5ed7c6 100644
> --- a/hw/pci-host/gpex-acpi.c
> +++ b/hw/pci-host/gpex-acpi.c
> @@ -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")));
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 09/24] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex
2025-04-28 10:25 ` [RFC 09/24] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex Eric Auger
@ 2025-05-06 0:13 ` Gustavo Romero
0 siblings, 0 replies; 46+ messages in thread
From: Gustavo Romero @ 2025-05-06 0:13 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> Propagate 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.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> 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(-)
>
> diff --git a/include/hw/pci-host/gpex.h b/include/hw/pci-host/gpex.h
> index 84471533af..feaf827474 100644
> --- a/include/hw/pci-host/gpex.h
> +++ b/include/hw/pci-host/gpex.h
> @@ -45,6 +45,7 @@ struct GPEXConfig {
> MemMapEntry pio;
> int irq;
> PCIBus *bus;
> + bool pci_native_hotplug;
> };
>
> typedef struct GPEXIrq GPEXIrq;
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 3ac8f8e178..46c5a43d27 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -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) {
> diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
> index 9d9f5ed7c6..9a521145bd 100644
> --- a/hw/pci-host/gpex-acpi.c
> +++ b/hw/pci-host/gpex-acpi.c
> @@ -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")));
Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc
2025-05-06 0:13 ` Gustavo Romero
@ 2025-05-06 8:42 ` Eric Auger
0 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-05-06 8:42 UTC (permalink / raw)
To: Gustavo Romero, eric.auger.pro, qemu-devel, qemu-arm,
peter.maydell, imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
On 5/6/25 2:13 AM, Gustavo Romero wrote:
> Hi Eric,
>
> On 4/28/25 07:25, Eric Auger wrote:
>> Add a new argument to acpi_dsdt_add_pci_osc to be able to disable
>> native pci hotplug.
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>> hw/pci-host/gpex-acpi.c | 11 ++++++-----
>> 1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/pci-host/gpex-acpi.c b/hw/pci-host/gpex-acpi.c
>> index e8b4c64c5f..4016089893 100644
>> --- a/hw/pci-host/gpex-acpi.c
>> +++ b/hw/pci-host/gpex-acpi.c
>> @@ -50,7 +50,7 @@ static void acpi_dsdt_add_pci_route_table(Aml *dev,
>> uint32_t irq,
>> }
>> }
>> -static void acpi_dsdt_add_pci_osc(Aml *dev)
>> +static void acpi_dsdt_add_pci_osc(Aml *dev, bool
>> enable_native_pcie_hotplug)
>> {
>> Aml *method, *UUID, *ifctx, *ifctx1, *elsectx, *buf;
>> @@ -80,8 +80,9 @@ static void acpi_dsdt_add_pci_osc(Aml *dev)
>> * Allow OS control for all 5 features:
>> * PCIeHotplug SHPCHotplug PME AER PCIeCapability.
>
> This comment is no longer true for PCIeHotplug, which now can be
> controlled by the platform, and so needs to be updated, although
> it's going to go away in the series.
Sure, replaced by
+ * Allow OS control for SHPCHotplug, PME, AER, PCIeCapability,
+ * and PCIeHotplug depending on enable_native_pcie_hotplug
>
> Otherwise:
>
> Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
thanks!
Eric
>
>
> Cheers,
> Gustavo
>
>> */
>> - 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")));
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
2025-05-06 0:12 ` Gustavo Romero
@ 2025-05-06 8:42 ` Eric Auger
0 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-05-06 8:42 UTC (permalink / raw)
To: Gustavo Romero, eric.auger.pro, qemu-devel, qemu-arm,
peter.maydell, imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
On 5/6/25 2:12 AM, Gustavo Romero wrote:
> Hi Eric,
>
> On 4/28/25 07:25, Eric Auger 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_hotplug is renamed into build_acpi_pci_hotplug().
>>
>> No code change intended.
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>> hw/i386/acpi-build.h | 4 -
>> include/hw/acpi/pcihp.h | 6 ++
>> hw/acpi/pcihp.c | 174 +++++++++++++++++++++++++++++++++++++++-
>> hw/i386/acpi-build.c | 150 +---------------------------------
>> 4 files changed, 181 insertions(+), 153 deletions(-)
>>
>> diff --git a/hw/i386/acpi-build.h b/hw/i386/acpi-build.h
>> index 0dce155c8c..8ba3c33e48 100644
>> --- a/hw/i386/acpi-build.h
>> +++ b/hw/i386/acpi-build.h
>> @@ -5,10 +5,6 @@
>> extern const struct AcpiGenericAddress x86_nvdimm_acpi_dsmio;
>> -/* PCI Hot-plug registers bases. See
>> docs/spec/acpi_pci_hotplug.txt */
>> -#define ACPI_PCIHP_SEJ_BASE 0x8
>> -#define ACPI_PCIHP_BNMR_BASE 0x10
>> -
>> void acpi_setup(void);
>> Object *acpi_get_i386_pci_host(void);
>> diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
>> index ac21a95913..2da0bc45c9 100644
>> --- a/include/hw/acpi/pcihp.h
>> +++ b/include/hw/acpi/pcihp.h
>> @@ -33,6 +33,10 @@
>> #define ACPI_PCIHP_IO_BASE_PROP "acpi-pcihp-io-base"
>> #define ACPI_PCIHP_IO_LEN_PROP "acpi-pcihp-io-len"
>> +/* PCI Hot-plug registers bases. See
>> docs/spec/acpi_pci_hotplug.txt */
>
> This reference needs to be updated to point to acpi_pci_hotplug.rst.
fixed here and above in the file
Thanks!
Eric
>
> Otherwise,
>
> Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
>
>
> Cheers,
> Gustavo
>
>> +#define ACPI_PCIHP_SEJ_BASE 0x8
>> +#define ACPI_PCIHP_BNMR_BASE 0x10
>> +
>> typedef struct AcpiPciHpPciStatus {
>> uint32_t up;
>> uint32_t down;
>> @@ -69,6 +73,8 @@ void
>> acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
>> AcpiPciHpState *s,
>> DeviceState *dev,
>> Error **errp);
>> +void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr);
>> +
>> /* Called on reset */
>> void acpi_pcihp_reset(AcpiPciHpState *s);
>> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
>> index 5f79c9016b..35d8c0bfd2 100644
>> --- a/hw/acpi/pcihp.c
>> +++ b/hw/acpi/pcihp.c
>> @@ -26,7 +26,7 @@
>> #include "qemu/osdep.h"
>> #include "hw/acpi/pcihp.h"
>> -
>> +#include "hw/acpi/aml-build.h"
>> #include "hw/pci-host/i440fx.h"
>> #include "hw/pci/pci.h"
>> #include "hw/pci/pci_bridge.h"
>> @@ -513,6 +513,178 @@ void acpi_pcihp_init(Object *owner,
>> AcpiPciHpState *s, PCIBus *root_bus,
>> OBJ_PROP_FLAG_READ);
>> }
>> +static void build_append_pci_dsm_func0_common(Aml *ctx, Aml *retvar)
>> +{
>> + Aml *UUID, *ifctx1;
>> + uint8_t byte_list[1] = { 0 }; /* nothing supported yet */
>> +
>> + aml_append(ctx, aml_store(aml_buffer(1, byte_list), retvar));
>> + /*
>> + * PCI Firmware Specification 3.1
>> + * 4.6. _DSM Definitions for PCI
>> + */
>> + UUID = aml_touuid("E5C937D0-3553-4D7A-9117-EA4D19C3434D");
>> + ifctx1 = aml_if(aml_lnot(aml_equal(aml_arg(0), UUID)));
>> + {
>> + /* call is for unsupported UUID, bail out */
>> + aml_append(ifctx1, aml_return(retvar));
>> + }
>> + aml_append(ctx, ifctx1);
>> +
>> + ifctx1 = aml_if(aml_lless(aml_arg(1), aml_int(2)));
>> + {
>> + /* call is for unsupported REV, bail out */
>> + aml_append(ifctx1, aml_return(retvar));
>> + }
>> + aml_append(ctx, ifctx1);
>> +}
>> +
>> +static Aml *aml_pci_pdsm(void)
>> +{
>> + Aml *method, *ifctx, *ifctx1;
>> + Aml *ret = aml_local(0);
>> + Aml *caps = aml_local(1);
>> + Aml *acpi_index = aml_local(2);
>> + Aml *zero = aml_int(0);
>> + Aml *one = aml_int(1);
>> + Aml *not_supp = aml_int(0xFFFFFFFF);
>> + Aml *func = aml_arg(2);
>> + Aml *params = aml_arg(4);
>> + Aml *bnum = aml_derefof(aml_index(params, aml_int(0)));
>> + Aml *sunum = aml_derefof(aml_index(params, aml_int(1)));
>> +
>> + method = aml_method("PDSM", 5, AML_SERIALIZED);
>> +
>> + /* get supported functions */
>> + ifctx = aml_if(aml_equal(func, zero));
>> + {
>> + build_append_pci_dsm_func0_common(ifctx, ret);
>> +
>> + aml_append(ifctx, aml_store(zero, caps));
>> + aml_append(ifctx,
>> + aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
>> + /*
>> + * advertise function 7 if device has acpi-index
>> + * acpi_index values:
>> + * 0: not present (default value)
>> + * FFFFFFFF: not supported (old QEMU without PIDX reg)
>> + * other: device's acpi-index
>> + */
>> + ifctx1 = aml_if(aml_lnot(
>> + aml_or(aml_equal(acpi_index, zero),
>> + aml_equal(acpi_index, not_supp), NULL)
>> + ));
>> + {
>> + /* have supported functions */
>> + aml_append(ifctx1, aml_or(caps, one, caps));
>> + /* support for function 7 */
>> + aml_append(ifctx1,
>> + aml_or(caps, aml_shiftleft(one, aml_int(7)), caps));
>> + }
>> + aml_append(ifctx, ifctx1);
>> +
>> + aml_append(ifctx, aml_store(caps, aml_index(ret, zero)));
>> + aml_append(ifctx, aml_return(ret));
>> + }
>> + aml_append(method, ifctx);
>> +
>> + /* handle specific functions requests */
>> + /*
>> + * PCI Firmware Specification 3.1
>> + * 4.6.7. _DSM for Naming a PCI or PCI Express Device Under
>> + * Operating Systems
>> + */
>> + ifctx = aml_if(aml_equal(func, aml_int(7)));
>> + {
>> + Aml *pkg = aml_package(2);
>> +
>> + aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum),
>> acpi_index));
>> + aml_append(ifctx, aml_store(pkg, ret));
>> + /*
>> + * Windows calls func=7 without checking if it's available,
>> + * as workaround Microsoft has suggested to return invalid
>> for func7
>> + * Package, so return 2 elements package but only initialize
>> elements
>> + * when acpi_index is supported and leave them uninitialized,
>> which
>> + * leads elements to being Uninitialized ObjectType and
>> should trip
>> + * Windows into discarding result as an unexpected and
>> prevent setting
>> + * bogus 'PCI Label' on the device.
>> + */
>> + ifctx1 = aml_if(aml_lnot(aml_lor(
>> + aml_equal(acpi_index, zero),
>> aml_equal(acpi_index, not_supp)
>> + )));
>> + {
>> + aml_append(ifctx1, aml_store(acpi_index, aml_index(ret,
>> zero)));
>> + /*
>> + * optional, if not impl. should return null string
>> + */
>> + aml_append(ifctx1, aml_store(aml_string("%s", ""),
>> + aml_index(ret, one)));
>> + }
>> + aml_append(ifctx, ifctx1);
>> +
>> + aml_append(ifctx, aml_return(ret));
>> + }
>> +
>> + aml_append(method, ifctx);
>> + return method;
>> +}
>> +
>> +void build_acpi_pci_hotplug(Aml *table, uint64_t pcihp_addr)
>> +{
>> + Aml *scope;
>> + Aml *field;
>> + Aml *method;
>> +
>> + scope = aml_scope("_SB.PCI0");
>> +
>> + aml_append(scope,
>> + aml_operation_region("PCST", AML_SYSTEM_IO,
>> aml_int(pcihp_addr), 0x08));
>> + field = aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK,
>> AML_WRITE_AS_ZEROS);
>> + aml_append(field, aml_named_field("PCIU", 32));
>> + aml_append(field, aml_named_field("PCID", 32));
>> + aml_append(scope, field);
>> +
>> + aml_append(scope,
>> + aml_operation_region("SEJ", AML_SYSTEM_IO,
>> + aml_int(pcihp_addr +
>> ACPI_PCIHP_SEJ_BASE), 0x04));
>> + field = aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK,
>> AML_WRITE_AS_ZEROS);
>> + aml_append(field, aml_named_field("B0EJ", 32));
>> + aml_append(scope, field);
>> +
>> + aml_append(scope,
>> + aml_operation_region("BNMR", AML_SYSTEM_IO,
>> + aml_int(pcihp_addr +
>> ACPI_PCIHP_BNMR_BASE), 0x08));
>> + field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK,
>> AML_WRITE_AS_ZEROS);
>> + aml_append(field, aml_named_field("BNUM", 32));
>> + aml_append(field, aml_named_field("PIDX", 32));
>> + aml_append(scope, field);
>> +
>> + aml_append(scope, aml_mutex("BLCK", 0));
>> +
>> + method = aml_method("PCEJ", 2, AML_NOTSERIALIZED);
>> + aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
>> + aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
>> + aml_append(method,
>> + aml_store(aml_shiftleft(aml_int(1), aml_arg(1)),
>> aml_name("B0EJ")));
>> + aml_append(method, aml_release(aml_name("BLCK")));
>> + aml_append(method, aml_return(aml_int(0)));
>> + aml_append(scope, method);
>> +
>> + method = aml_method("AIDX", 2, AML_NOTSERIALIZED);
>> + aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
>> + aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
>> + aml_append(method,
>> + aml_store(aml_shiftleft(aml_int(1), aml_arg(1)),
>> aml_name("PIDX")));
>> + aml_append(method, aml_store(aml_name("PIDX"), aml_local(0)));
>> + aml_append(method, aml_release(aml_name("BLCK")));
>> + aml_append(method, aml_return(aml_local(0)));
>> + aml_append(scope, method);
>> +
>> + aml_append(scope, aml_pci_pdsm());
>> +
>> + aml_append(table, scope);
>> +}
>> +
>> const VMStateDescription vmstate_acpi_pcihp_pci_status = {
>> .name = "acpi_pcihp_pci_status",
>> .version_id = 1,
>> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
>> index 864f6b5bf8..2d1eea4a1a 100644
>> --- a/hw/i386/acpi-build.c
>> +++ b/hw/i386/acpi-build.c
>> @@ -647,96 +647,6 @@ static bool
>> build_append_notification_callback(Aml *parent_scope,
>> return !!nr_notifiers;
>> }
>> -static Aml *aml_pci_pdsm(void)
>> -{
>> - Aml *method, *ifctx, *ifctx1;
>> - Aml *ret = aml_local(0);
>> - Aml *caps = aml_local(1);
>> - Aml *acpi_index = aml_local(2);
>> - Aml *zero = aml_int(0);
>> - Aml *one = aml_int(1);
>> - Aml *not_supp = aml_int(0xFFFFFFFF);
>> - Aml *func = aml_arg(2);
>> - Aml *params = aml_arg(4);
>> - Aml *bnum = aml_derefof(aml_index(params, aml_int(0)));
>> - Aml *sunum = aml_derefof(aml_index(params, aml_int(1)));
>> -
>> - method = aml_method("PDSM", 5, AML_SERIALIZED);
>> -
>> - /* get supported functions */
>> - ifctx = aml_if(aml_equal(func, zero));
>> - {
>> - build_append_pci_dsm_func0_common(ifctx, ret);
>> -
>> - aml_append(ifctx, aml_store(zero, caps));
>> - aml_append(ifctx,
>> - aml_store(aml_call2("AIDX", bnum, sunum), acpi_index));
>> - /*
>> - * advertise function 7 if device has acpi-index
>> - * acpi_index values:
>> - * 0: not present (default value)
>> - * FFFFFFFF: not supported (old QEMU without PIDX reg)
>> - * other: device's acpi-index
>> - */
>> - ifctx1 = aml_if(aml_lnot(
>> - aml_or(aml_equal(acpi_index, zero),
>> - aml_equal(acpi_index, not_supp), NULL)
>> - ));
>> - {
>> - /* have supported functions */
>> - aml_append(ifctx1, aml_or(caps, one, caps));
>> - /* support for function 7 */
>> - aml_append(ifctx1,
>> - aml_or(caps, aml_shiftleft(one, aml_int(7)), caps));
>> - }
>> - aml_append(ifctx, ifctx1);
>> -
>> - aml_append(ifctx, aml_store(caps, aml_index(ret, zero)));
>> - aml_append(ifctx, aml_return(ret));
>> - }
>> - aml_append(method, ifctx);
>> -
>> - /* handle specific functions requests */
>> - /*
>> - * PCI Firmware Specification 3.1
>> - * 4.6.7. _DSM for Naming a PCI or PCI Express Device Under
>> - * Operating Systems
>> - */
>> - ifctx = aml_if(aml_equal(func, aml_int(7)));
>> - {
>> - Aml *pkg = aml_package(2);
>> -
>> - aml_append(ifctx, aml_store(aml_call2("AIDX", bnum, sunum),
>> acpi_index));
>> - aml_append(ifctx, aml_store(pkg, ret));
>> - /*
>> - * Windows calls func=7 without checking if it's available,
>> - * as workaround Microsoft has suggested to return invalid
>> for func7
>> - * Package, so return 2 elements package but only initialize
>> elements
>> - * when acpi_index is supported and leave them uninitialized,
>> which
>> - * leads elements to being Uninitialized ObjectType and
>> should trip
>> - * Windows into discarding result as an unexpected and
>> prevent setting
>> - * bogus 'PCI Label' on the device.
>> - */
>> - ifctx1 = aml_if(aml_lnot(aml_lor(
>> - aml_equal(acpi_index, zero),
>> aml_equal(acpi_index, not_supp)
>> - )));
>> - {
>> - aml_append(ifctx1, aml_store(acpi_index, aml_index(ret,
>> zero)));
>> - /*
>> - * optional, if not impl. should return null string
>> - */
>> - aml_append(ifctx1, aml_store(aml_string("%s", ""),
>> - aml_index(ret, one)));
>> - }
>> - aml_append(ifctx, ifctx1);
>> -
>> - aml_append(ifctx, aml_return(ret));
>> - }
>> -
>> - aml_append(method, ifctx);
>> - return method;
>> -}
>> -
>> /*
>> * build_prt - Define interrupt routing rules
>> *
>> @@ -1227,62 +1137,6 @@ static Aml *build_q35_dram_controller(const
>> AcpiMcfgInfo *mcfg)
>> return dev;
>> }
>> -static void build_x86_acpi_pci_hotplug(Aml *table, uint64_t
>> pcihp_addr)
>> -{
>> - Aml *scope;
>> - Aml *field;
>> - Aml *method;
>> -
>> - scope = aml_scope("_SB.PCI0");
>> -
>> - aml_append(scope,
>> - aml_operation_region("PCST", AML_SYSTEM_IO,
>> aml_int(pcihp_addr), 0x08));
>> - field = aml_field("PCST", AML_DWORD_ACC, AML_NOLOCK,
>> AML_WRITE_AS_ZEROS);
>> - aml_append(field, aml_named_field("PCIU", 32));
>> - aml_append(field, aml_named_field("PCID", 32));
>> - aml_append(scope, field);
>> -
>> - aml_append(scope,
>> - aml_operation_region("SEJ", AML_SYSTEM_IO,
>> - aml_int(pcihp_addr +
>> ACPI_PCIHP_SEJ_BASE), 0x04));
>> - field = aml_field("SEJ", AML_DWORD_ACC, AML_NOLOCK,
>> AML_WRITE_AS_ZEROS);
>> - aml_append(field, aml_named_field("B0EJ", 32));
>> - aml_append(scope, field);
>> -
>> - aml_append(scope,
>> - aml_operation_region("BNMR", AML_SYSTEM_IO,
>> - aml_int(pcihp_addr +
>> ACPI_PCIHP_BNMR_BASE), 0x08));
>> - field = aml_field("BNMR", AML_DWORD_ACC, AML_NOLOCK,
>> AML_WRITE_AS_ZEROS);
>> - aml_append(field, aml_named_field("BNUM", 32));
>> - aml_append(field, aml_named_field("PIDX", 32));
>> - aml_append(scope, field);
>> -
>> - aml_append(scope, aml_mutex("BLCK", 0));
>> -
>> - method = aml_method("PCEJ", 2, AML_NOTSERIALIZED);
>> - aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
>> - aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
>> - aml_append(method,
>> - aml_store(aml_shiftleft(aml_int(1), aml_arg(1)),
>> aml_name("B0EJ")));
>> - aml_append(method, aml_release(aml_name("BLCK")));
>> - aml_append(method, aml_return(aml_int(0)));
>> - aml_append(scope, method);
>> -
>> - method = aml_method("AIDX", 2, AML_NOTSERIALIZED);
>> - aml_append(method, aml_acquire(aml_name("BLCK"), 0xFFFF));
>> - aml_append(method, aml_store(aml_arg(0), aml_name("BNUM")));
>> - aml_append(method,
>> - aml_store(aml_shiftleft(aml_int(1), aml_arg(1)),
>> aml_name("PIDX")));
>> - aml_append(method, aml_store(aml_name("PIDX"), aml_local(0)));
>> - aml_append(method, aml_release(aml_name("BLCK")));
>> - aml_append(method, aml_return(aml_local(0)));
>> - aml_append(scope, method);
>> -
>> - aml_append(scope, aml_pci_pdsm());
>> -
>> - aml_append(table, scope);
>> -}
>> -
>> static Aml *build_q35_osc_method(bool enable_native_pcie_hotplug)
>> {
>> Aml *if_ctx;
>> @@ -1394,7 +1248,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>> aml_append(dsdt, sb_scope);
>> if (pm->pcihp_bridge_en || pm->pcihp_root_en) {
>> - build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
>> + build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
>> }
>> build_piix4_pci0_int(dsdt);
>> } else if (q35) {
>> @@ -1438,7 +1292,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker,
>> aml_append(dsdt, sb_scope);
>> if (pm->pcihp_bridge_en) {
>> - build_x86_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
>> + build_acpi_pci_hotplug(dsdt, pm->pcihp_io_base);
>> }
>> build_q35_pci0_int(dsdt);
>> }
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props
2025-05-06 0:12 ` Gustavo Romero
@ 2025-05-06 8:42 ` Eric Auger
0 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-05-06 8:42 UTC (permalink / raw)
To: Gustavo Romero, eric.auger.pro, qemu-devel, qemu-arm,
peter.maydell, imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Gustavo,
On 5/6/25 2:12 AM, Gustavo Romero wrote:
> Hi Eric,
>
> On 4/28/25 07:25, Eric Auger wrote:
>> acpi_pcihp VirtMachineClass state flag will allow
>> to opt in for acpi pci hotplug. This is guarded by a
>> class no_acpi_pcihp flag to manage compats (<= 10.0
>> machine types will not support ACPI PCI hotplug).
>>
>> Machine state acpi_pcihp flag msu be set before the creation
> nit: ^--- must be set
>
>
>> of the GED device which will use it.
>>
>> Currently the ACPI PCI HP is turned off by default. This will
>> change later on for 10.1 machine type.
>>
>> We also introduce properties to allow disabling it.
>>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>> include/hw/arm/virt.h | 2 ++
>> hw/arm/virt.c | 27 +++++++++++++++++++++++++++
>> 2 files changed, 29 insertions(+)
>>
>> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
>> index c8e94e6aed..1e9d002880 100644
>> --- a/include/hw/arm/virt.h
>> +++ b/include/hw/arm/virt.h
>> @@ -135,6 +135,7 @@ struct VirtMachineClass {
>> bool no_tcg_lpa2;
>> bool no_ns_el2_virt_timer_irq;
>> bool no_nested_smmu;
>> + bool no_acpi_pcihp;
>> };
>> struct VirtMachineState {
>> @@ -156,6 +157,7 @@ struct VirtMachineState {
>> bool mte;
>> bool dtb_randomness;
>> bool second_ns_uart_present;
>> + bool acpi_pcihp;
>> OnOffAuto acpi;
>> VirtGICType gic_version;
>> VirtIOMMUType iommu;
>> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
>> index 3e72adaa91..1601750913 100644
>> --- a/hw/arm/virt.c
>> +++ b/hw/arm/virt.c
>> @@ -2414,8 +2414,10 @@ static void machvirt_init(MachineState *machine)
>> create_pcie(vms);
>> if (has_ged && aarch64 && firmware_loaded &&
>> virt_is_acpi_enabled(vms)) {
>> + vms->acpi_pcihp &= !vmc->no_acpi_pcihp;
>> vms->acpi_dev = create_acpi_ged(vms);
>> } else {
>> + vms->acpi_pcihp = false;
>> create_gpio_devices(vms, VIRT_GPIO, sysmem);
>> }
>> @@ -2610,6 +2612,20 @@ static void virt_set_its(Object *obj, bool
>> value, Error **errp)
>> vms->its = value;
>> }
>> +static bool virt_get_acpi_pcihp(Object *obj, Error **errp)
>> +{
>> + VirtMachineState *vms = VIRT_MACHINE(obj);
>> +
>> + return vms->acpi_pcihp;
>> +}
>> +
>> +static void virt_set_acpi_pcihp(Object *obj, bool value, Error **errp)
>> +{
>> + VirtMachineState *vms = VIRT_MACHINE(obj);
>> +
>> + vms->acpi_pcihp = value;
>> +}
>> +
>> static bool virt_get_dtb_randomness(Object *obj, Error **errp)
>> {
>> VirtMachineState *vms = VIRT_MACHINE(obj);
>> @@ -3327,6 +3343,10 @@ static void
>> virt_machine_class_init(ObjectClass *oc, void *data)
>> "in ACPI table header."
>> "The string may be up to
>> 8 bytes in size");
>> + object_class_property_add_bool(oc, "acpi-pcihp",
>> + virt_get_acpi_pcihp,
>> virt_set_acpi_pcihp);
>> + object_class_property_set_description(oc, "acpi-pcihp",
>> + "Force acpi pci hotplug");
>
> How about "Force ACPI PCI hotplug"?
Sure.
Thanks!
Eric
>
>
>> }
>> static void virt_instance_init(Object *obj)
>> @@ -3365,6 +3385,9 @@ static void virt_instance_init(Object *obj)
>> }
>> }
>> + /* default disallows ACPI PCI hotplug */
>> + vms->acpi_pcihp = false;
>> +
>> /* Default disallows iommu instantiation */
>> vms->iommu = VIRT_IOMMU_NONE;
>> @@ -3415,8 +3438,12 @@ DEFINE_VIRT_MACHINE_AS_LATEST(10, 1)
>> static void virt_machine_10_0_options(MachineClass *mc)
>> {
>> + VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc));
>> +
>> virt_machine_10_1_options(mc);
>> compat_props_add(mc->compat_props, hw_compat_10_0,
>> hw_compat_10_0_len);
>> + /* 10.0 and earlier do not support ACPI PCI hotplug */
>> + vmc->no_acpi_pcihp = true;
>> }
>> DEFINE_VIRT_MACHINE(10, 0)
>>
>
> Otherwise,
>
> Reviewed-by: Gustavo Romero <gustavo.romero@linaro.org>
>
>
> Cheers,
> Gustavo
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 00/24] APCI PCI Hotplug support on ARM
2025-05-05 13:26 ` [RFC 00/24] APCI PCI Hotplug support on ARM Gustavo Romero
2025-05-05 14:23 ` Eric Auger
@ 2025-05-06 15:58 ` Eric Auger
2025-05-06 16:08 ` Eric Auger
2025-05-07 0:51 ` Gustavo Romero
1 sibling, 2 replies; 46+ messages in thread
From: Eric Auger @ 2025-05-06 15:58 UTC (permalink / raw)
To: Gustavo Romero, eric.auger.pro, qemu-devel, qemu-arm,
peter.maydell, imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Gustavo,
On 5/5/25 3:26 PM, Gustavo Romero wrote:
> Hi Eric,
>
> On 4/28/25 07:25, Eric Auger wrote:
>> This series enables APCI PCI hotplug/hotunplug on ARM
>> and makes it default for 10.1 machine type. This aligns with
>> x86 q35 machine. Expected benefits should be similar to
>> those listed in [1].
>>
>> The infrastructure used in x86 is heavily reused and a
>> huge part of the series consists in moving code from
>> hw/i386/acpi-build.c to a generic place and slightly
>> adapting it to make it usable on ARM. The DSDT table is
>> augmented to support ACPI PCI hotplug elements.
>>
>> On ARM we use use a GED event to notify the OS about
>> hotplug events.
>>
>> I have not noticed any tests/qtest/bios-tables-test failures
>> neither on x86 nor ARM. x86 DSDT table has not changed.
>> ARM DSDT table definitively has but there are no tests
>> impacted. ARM misses hotplug tests that do exist on x86. This
>> most probably should be considered in the future.
>>
>> Best Regards
>>
>> Eric
>>
>> This series can be found at:
>> https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
>>
>> [1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
>> https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
>
> I've just started to review your series and went to a quick smoke test
> by hotplugging a net adapter and got the following kernel internal error:
>
> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
> (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class
> 0x020000
> [ 64.165895] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
> [ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff
> 64bit pref]
> [ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff
> pref]
> [ 64.167153] pci 0000:01:00.0: enabling Extended Tags
> [ 64.179972] Internal error: synchronous external abort:
> 0000000096000050 [#1] SMP
> [ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce
> polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64
> sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse
> efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables
> x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi
> virtio_net scsi_mod net_failover failover virtio_blk scsi_common
> crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev
> virtio_pci_modern_dev virtio_mmio
> [ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted
> 6.1.0-30-arm64 #1 Debian 6.1.124-1
> [ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS
> edk2-stable202408-prebuilt.qemu.org 08/13/2024
> [ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
> [ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS
> BTYPE=--)
> [ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300
> [ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334
> [ 64.186490] sp : ffff80000a6bb3b0
> [ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27:
> 0000000000000000
> [ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24:
> 0000000000000001
> [ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21:
> ffff0000c206cb00
> [ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18:
> 0000000000000000
> [ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
> 0000000000000000
> [ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12:
> 4d7a3553e5c937d0
> [ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :
> ffff800008735b34
> [ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 :
> 00000000000000f8
> [ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 :
> 00000000090c0018
> [ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 :
> 0000000000000001
> [ 64.190734] Call trace:
> [ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300
> [ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334
> [ 64.192042] acpi_ex_access_region+0xe4/0x2e0
> [ 64.192287] acpi_ex_field_datum_io+0x88/0x200
> [ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120
> [ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0
> [ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190
> [ 64.193298] acpi_ex_store_object_to_node+0x150/0x240
> [ 64.193527] acpi_ex_store+0x144/0x300
> [ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580
> [ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0
> [ 64.194227] acpi_ps_parse_loop+0x100/0x6a0
> [ 64.194477] acpi_ps_parse_aml+0x94/0x3b0
> [ 64.194674] acpi_ps_execute_method+0x128/0x25c
> [ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0
> [ 64.195148] acpi_evaluate_object+0x138/0x2d0
> [ 64.195380] acpi_evaluate_dsm+0xb8/0x134
> [ 64.195613] acpi_check_dsm+0x34/0xdc
> [ 64.195822] smbios_attr_is_visible+0x5c/0xb0
> [ 64.196089] internal_create_group+0xd0/0x3d0
> [ 64.196335] internal_create_groups+0x58/0xe0
> [ 64.196584] sysfs_create_groups+0x20/0x30
> [ 64.196813] device_add_groups+0x18/0x2c
> [ 64.197039] bus_add_device+0x48/0x160
> [ 64.197260] device_add+0x3a4/0x85c
> [ 64.197463] pci_device_add+0x308/0x660
> [ 64.197680] pci_scan_single_device+0xe4/0x114
> [ 64.197941] pci_scan_slot+0x70/0x1fc
> [ 64.198155] acpiphp_rescan_slot+0x90/0xa4
> [ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300
> [ 64.198584] acpi_device_hotplug+0x138/0x4c0
> [ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c
> [ 64.199045] process_one_work+0x1f4/0x460
> [ 64.199277] worker_thread+0x188/0x4e0
> [ 64.199492] kthread+0xe0/0xe4
> [ 64.199671] ret_from_fork+0x10/0x20
> [ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
> [ 64.200820] ---[ end trace 0000000000000000 ]---
>
> (qemu)
>
> This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH
> branch.
>
> The machine was started with:
>
> ./qemu-system-aarch64 -m 16G -nographic -machine
> type=virt,gic-version=max -cpu cortex-a57 -initrd
> /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64
> -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device
> virtio-scsi-pci -device virtio-blk-pci,drive=root -drive
> if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device
> pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios
> ./pc-bios/edk2-aarch64-code.fd
>
> ./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so
> nothing special.
I have just tested debian-12-nocloud-arm64.qcow2 which features
6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to
hotplug/hot-unplug the virtio-net-pci device. Can you retry without
-initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel
/mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1
console=ttyAMA0,115200 acpi=force" ?
Cheers
Eric
>
> It seems Linux acpi crashed when ingesting the _DSM method but I could
> not
> figure out what exactly in it could cause it.
>
>
> Cheers,
> Gustavo
>
>>
>> Eric Auger (24):
>> hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
>> hw/acpi/ged: Fix wrong identation
>> hw/i386/acpi-build: Fix build_append_notfication_callback typo
>> hw/i386/acpi-build: Make aml_pci_device_dsm() static
>> hw/arm/virt: Introduce machine state acpi pcihp flags and props
>> hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
>> hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to
>> acpi_dsdt_add_pci_osc
>> hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
>> hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine
>> downto gpex
>> hw/i386/acpi-build: Turn build_q35_osc_method into a generic method
>> hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
>> hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
>> hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
>> hw/i386/acpi-build: Move build_append_notification_callback to pcihp
>> hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp
>> hw/i386/acpi-build: Introduce and use acpi_get_pci_host
>> hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug
>> hw/acpi/ged: Prepare the device to react to PCI hotplug events
>> hw/acpi/ged: Call pcihp plug callbacks in hotplug handler
>> implementation
>> hw/acpi/ged: Support migration of AcpiPciHpState
>> hw/core/sysbus: Introduce sysbus_mmio_map_name() helper
>> hw/arm/virt: Let virt support pci hotplug/unplug GED event
>> hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks
>> hw/arm/virt: Use ACPI PCI hotplug by default
>>
>> hw/i386/acpi-build.h | 4 -
>> include/hw/acpi/aml-build.h | 2 +
>> include/hw/acpi/generic_event_device.h | 5 +
>> include/hw/acpi/pci.h | 4 +-
>> include/hw/acpi/pcihp.h | 14 +
>> include/hw/arm/virt.h | 4 +
>> include/hw/pci-host/gpex.h | 1 +
>> include/hw/sysbus.h | 1 +
>> hw/acpi/aml-build.c | 50 +++
>> hw/acpi/generic_event_device.c | 64 +++-
>> hw/acpi/pci.c | 20 ++
>> hw/acpi/pcihp.c | 428 +++++++++++++++++++++-
>> hw/arm/virt-acpi-build.c | 26 ++
>> hw/arm/virt.c | 100 +++++-
>> hw/core/sysbus.c | 11 +
>> hw/i386/acpi-build.c | 475 +------------------------
>> hw/pci-host/gpex-acpi.c | 75 +---
>> hw/pci/pcie_port.c | 4 +-
>> hw/arm/Kconfig | 2 +
>> 19 files changed, 748 insertions(+), 542 deletions(-)
>>
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 00/24] APCI PCI Hotplug support on ARM
2025-05-06 15:58 ` Eric Auger
@ 2025-05-06 16:08 ` Eric Auger
2025-05-07 0:51 ` Gustavo Romero
1 sibling, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-05-06 16:08 UTC (permalink / raw)
To: eric.auger, Gustavo Romero, eric.auger.pro, qemu-devel, qemu-arm,
peter.maydell, imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
On 5/6/25 5:58 PM, Eric Auger wrote:
> Hi Gustavo,
>
> On 5/5/25 3:26 PM, Gustavo Romero wrote:
>> Hi Eric,
>>
>> On 4/28/25 07:25, Eric Auger wrote:
>>> This series enables APCI PCI hotplug/hotunplug on ARM
>>> and makes it default for 10.1 machine type. This aligns with
>>> x86 q35 machine. Expected benefits should be similar to
>>> those listed in [1].
>>>
>>> The infrastructure used in x86 is heavily reused and a
>>> huge part of the series consists in moving code from
>>> hw/i386/acpi-build.c to a generic place and slightly
>>> adapting it to make it usable on ARM. The DSDT table is
>>> augmented to support ACPI PCI hotplug elements.
>>>
>>> On ARM we use use a GED event to notify the OS about
>>> hotplug events.
>>>
>>> I have not noticed any tests/qtest/bios-tables-test failures
>>> neither on x86 nor ARM. x86 DSDT table has not changed.
>>> ARM DSDT table definitively has but there are no tests
>>> impacted. ARM misses hotplug tests that do exist on x86. This
>>> most probably should be considered in the future.
>>>
>>> Best Regards
>>>
>>> Eric
>>>
>>> This series can be found at:
>>> https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
>>>
>>> [1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
>>> https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
>>
>> I've just started to review your series and went to a quick smoke test
>> by hotplugging a net adapter and got the following kernel internal error:
>>
>> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
>> (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class
>> 0x020000
>> [ 64.165895] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
>> [ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff
>> 64bit pref]
>> [ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff
>> pref]
>> [ 64.167153] pci 0000:01:00.0: enabling Extended Tags
>> [ 64.179972] Internal error: synchronous external abort:
>> 0000000096000050 [#1] SMP
>> [ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce
>> polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64
>> sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse
>> efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables
>> x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi
>> virtio_net scsi_mod net_failover failover virtio_blk scsi_common
>> crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev
>> virtio_pci_modern_dev virtio_mmio
>> [ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted
>> 6.1.0-30-arm64 #1 Debian 6.1.124-1
>> [ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS
>> edk2-stable202408-prebuilt.qemu.org 08/13/2024
>> [ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
>> [ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS
>> BTYPE=--)
>> [ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300
>> [ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334
>> [ 64.186490] sp : ffff80000a6bb3b0
>> [ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27:
>> 0000000000000000
>> [ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24:
>> 0000000000000001
>> [ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21:
>> ffff0000c206cb00
>> [ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18:
>> 0000000000000000
>> [ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
>> 0000000000000000
>> [ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12:
>> 4d7a3553e5c937d0
>> [ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :
>> ffff800008735b34
>> [ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 :
>> 00000000000000f8
>> [ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 :
>> 00000000090c0018
>> [ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 :
>> 0000000000000001
>> [ 64.190734] Call trace:
>> [ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300
>> [ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334
>> [ 64.192042] acpi_ex_access_region+0xe4/0x2e0
>> [ 64.192287] acpi_ex_field_datum_io+0x88/0x200
>> [ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120
>> [ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0
>> [ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190
>> [ 64.193298] acpi_ex_store_object_to_node+0x150/0x240
>> [ 64.193527] acpi_ex_store+0x144/0x300
>> [ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580
>> [ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0
>> [ 64.194227] acpi_ps_parse_loop+0x100/0x6a0
>> [ 64.194477] acpi_ps_parse_aml+0x94/0x3b0
>> [ 64.194674] acpi_ps_execute_method+0x128/0x25c
>> [ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0
>> [ 64.195148] acpi_evaluate_object+0x138/0x2d0
>> [ 64.195380] acpi_evaluate_dsm+0xb8/0x134
>> [ 64.195613] acpi_check_dsm+0x34/0xdc
>> [ 64.195822] smbios_attr_is_visible+0x5c/0xb0
>> [ 64.196089] internal_create_group+0xd0/0x3d0
>> [ 64.196335] internal_create_groups+0x58/0xe0
>> [ 64.196584] sysfs_create_groups+0x20/0x30
>> [ 64.196813] device_add_groups+0x18/0x2c
>> [ 64.197039] bus_add_device+0x48/0x160
>> [ 64.197260] device_add+0x3a4/0x85c
>> [ 64.197463] pci_device_add+0x308/0x660
>> [ 64.197680] pci_scan_single_device+0xe4/0x114
>> [ 64.197941] pci_scan_slot+0x70/0x1fc
>> [ 64.198155] acpiphp_rescan_slot+0x90/0xa4
>> [ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300
>> [ 64.198584] acpi_device_hotplug+0x138/0x4c0
>> [ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c
>> [ 64.199045] process_one_work+0x1f4/0x460
>> [ 64.199277] worker_thread+0x188/0x4e0
>> [ 64.199492] kthread+0xe0/0xe4
>> [ 64.199671] ret_from_fork+0x10/0x20
>> [ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
>> [ 64.200820] ---[ end trace 0000000000000000 ]---
>>
>> (qemu)
>>
>> This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH
>> branch.
>>
>> The machine was started with:
>>
>> ./qemu-system-aarch64 -m 16G -nographic -machine
>> type=virt,gic-version=max -cpu cortex-a57 -initrd
>> /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64
>> -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device
>> virtio-scsi-pci -device virtio-blk-pci,drive=root -drive
>> if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device
>> pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios
>> ./pc-bios/edk2-aarch64-code.fd
>>
>> ./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so
>> nothing special.
>
> I have just tested debian-12-nocloud-arm64.qcow2 which features
> 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to
> hotplug/hot-unplug the virtio-net-pci device. Can you retry without
>
> -initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel
> /mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1
> console=ttyAMA0,115200 acpi=force" ?
Also tried with an upstream kernel 6.15-rc3 and it works for me:
/home/augere/UPSTREAM/acpipcihp-qemu/build/qemu-system-aarch64 -M
virt,acpi-pcihp=on,gic-version=host -cpu max -smp 8 -m
16G,maxmem=32G,slots=3 -display none --enable-kvm -serial
tcp:localhost:4444,server -device
pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -device
pcie-root-port,bus=pcie.0,chassis=2,id=pcie.2,addr=0x3.0x0 -device
pcie-root-port,bus=pcie.0,chassis=3,id=pcie.3,addr=0x4.0x0 -device
pcie-root-port,bus=pcie.0,chassis=4,id=pcie.4,addr=0x5.0x0 -device
pcie-root-port,bus=pcie.0,chassis=5,id=pcie.5,addr=0x6.0x0 -netdev
tap,id=nic1,script=/home/augere/TEST/SCRIPTS/qemu-ifup,downscript=/home/augere/TEST/SCRIPTS/qemu-ifdown
-qmp unix:/home/augere/TEST/QEMU/qmp-sock,server,nowait -drive
file=/home/nfs_vm/UEFI/edk2-aarch64-code.fd,if=pflash,format=raw,unit=0,readonly=on
-drive file=/home/nfs_vm/UEFI/vars,if=pflash,format=raw,unit=1 -device
virtio-blk-pci,bus=pcie.4,drive=drv0,id=virtio-disk0,bootindex=1,werror=stop,rerror=stop
-drive
file=/home/nfs_vm/IMAGES/aarch64/debian-12-nocloud-arm64.qcow2,format=qcow2,if=none,cache=writethrough,id=drv0
-kernel /home/nfs_vm/BOOT/aarch64/vmlinuz-6.15.0-rc3-acpi-hp-guest+
-initrd /home/nfs_vm/BOOT/aarch64/initrd.img-6.15.0-rc3-acpi-hp-guest+
-append 'root=/dev/vda1 console=ttyAMA0,115200 acpi=force earlyprintk
iommu.strict=no acpi=force' -net none -d guest_errors
(QEMU) device_add driver=virtio-net-pci bus=pcie.1 netdev=nic1
mac=6a:f5:10:b1:3d:d3 id=net
Cheers
Eric
>
> Cheers
>
> Eric
>>
>> It seems Linux acpi crashed when ingesting the _DSM method but I could
>> not
>> figure out what exactly in it could cause it.
>>
>>
>> Cheers,
>> Gustavo
>>
>>>
>>> Eric Auger (24):
>>> hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo
>>> hw/acpi/ged: Fix wrong identation
>>> hw/i386/acpi-build: Fix build_append_notfication_callback typo
>>> hw/i386/acpi-build: Make aml_pci_device_dsm() static
>>> hw/arm/virt: Introduce machine state acpi pcihp flags and props
>>> hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp
>>> hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to
>>> acpi_dsdt_add_pci_osc
>>> hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation
>>> hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine
>>> downto gpex
>>> hw/i386/acpi-build: Turn build_q35_osc_method into a generic method
>>> hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method
>>> hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper
>>> hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug
>>> hw/i386/acpi-build: Move build_append_notification_callback to pcihp
>>> hw/i386/acpi-build: Move remaining pcihp generic functions to pcihp
>>> hw/i386/acpi-build: Introduce and use acpi_get_pci_host
>>> hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug
>>> hw/acpi/ged: Prepare the device to react to PCI hotplug events
>>> hw/acpi/ged: Call pcihp plug callbacks in hotplug handler
>>> implementation
>>> hw/acpi/ged: Support migration of AcpiPciHpState
>>> hw/core/sysbus: Introduce sysbus_mmio_map_name() helper
>>> hw/arm/virt: Let virt support pci hotplug/unplug GED event
>>> hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks
>>> hw/arm/virt: Use ACPI PCI hotplug by default
>>>
>>> hw/i386/acpi-build.h | 4 -
>>> include/hw/acpi/aml-build.h | 2 +
>>> include/hw/acpi/generic_event_device.h | 5 +
>>> include/hw/acpi/pci.h | 4 +-
>>> include/hw/acpi/pcihp.h | 14 +
>>> include/hw/arm/virt.h | 4 +
>>> include/hw/pci-host/gpex.h | 1 +
>>> include/hw/sysbus.h | 1 +
>>> hw/acpi/aml-build.c | 50 +++
>>> hw/acpi/generic_event_device.c | 64 +++-
>>> hw/acpi/pci.c | 20 ++
>>> hw/acpi/pcihp.c | 428 +++++++++++++++++++++-
>>> hw/arm/virt-acpi-build.c | 26 ++
>>> hw/arm/virt.c | 100 +++++-
>>> hw/core/sysbus.c | 11 +
>>> hw/i386/acpi-build.c | 475 +------------------------
>>> hw/pci-host/gpex-acpi.c | 75 +---
>>> hw/pci/pcie_port.c | 4 +-
>>> hw/arm/Kconfig | 2 +
>>> 19 files changed, 748 insertions(+), 542 deletions(-)
>>>
>>
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 00/24] APCI PCI Hotplug support on ARM
2025-05-06 15:58 ` Eric Auger
2025-05-06 16:08 ` Eric Auger
@ 2025-05-07 0:51 ` Gustavo Romero
2025-05-07 1:13 ` Gustavo Romero
1 sibling, 1 reply; 46+ messages in thread
From: Gustavo Romero @ 2025-05-07 0:51 UTC (permalink / raw)
To: eric.auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 5/6/25 12:58, Eric Auger wrote:
> Hi Gustavo,
>
> On 5/5/25 3:26 PM, Gustavo Romero wrote:
>> Hi Eric,
>>
>> On 4/28/25 07:25, Eric Auger wrote:
>>> This series enables APCI PCI hotplug/hotunplug on ARM
>>> and makes it default for 10.1 machine type. This aligns with
>>> x86 q35 machine. Expected benefits should be similar to
>>> those listed in [1].
>>>
>>> The infrastructure used in x86 is heavily reused and a
>>> huge part of the series consists in moving code from
>>> hw/i386/acpi-build.c to a generic place and slightly
>>> adapting it to make it usable on ARM. The DSDT table is
>>> augmented to support ACPI PCI hotplug elements.
>>>
>>> On ARM we use use a GED event to notify the OS about
>>> hotplug events.
>>>
>>> I have not noticed any tests/qtest/bios-tables-test failures
>>> neither on x86 nor ARM. x86 DSDT table has not changed.
>>> ARM DSDT table definitively has but there are no tests
>>> impacted. ARM misses hotplug tests that do exist on x86. This
>>> most probably should be considered in the future.
>>>
>>> Best Regards
>>>
>>> Eric
>>>
>>> This series can be found at:
>>> https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
>>>
>>> [1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
>>> https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
>>
>> I've just started to review your series and went to a quick smoke test
>> by hotplugging a net adapter and got the following kernel internal error:
>>
>> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
>> (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class
>> 0x020000
>> [ 64.165895] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
>> [ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff
>> 64bit pref]
>> [ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff
>> pref]
>> [ 64.167153] pci 0000:01:00.0: enabling Extended Tags
>> [ 64.179972] Internal error: synchronous external abort:
>> 0000000096000050 [#1] SMP
>> [ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce
>> polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64
>> sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse
>> efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables
>> x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi
>> virtio_net scsi_mod net_failover failover virtio_blk scsi_common
>> crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev
>> virtio_pci_modern_dev virtio_mmio
>> [ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted
>> 6.1.0-30-arm64 #1 Debian 6.1.124-1
>> [ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS
>> edk2-stable202408-prebuilt.qemu.org 08/13/2024
>> [ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
>> [ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS
>> BTYPE=--)
>> [ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300
>> [ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334
>> [ 64.186490] sp : ffff80000a6bb3b0
>> [ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27:
>> 0000000000000000
>> [ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24:
>> 0000000000000001
>> [ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21:
>> ffff0000c206cb00
>> [ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18:
>> 0000000000000000
>> [ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
>> 0000000000000000
>> [ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12:
>> 4d7a3553e5c937d0
>> [ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :
>> ffff800008735b34
>> [ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 :
>> 00000000000000f8
>> [ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 :
>> 00000000090c0018
>> [ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 :
>> 0000000000000001
>> [ 64.190734] Call trace:
>> [ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300
>> [ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334
>> [ 64.192042] acpi_ex_access_region+0xe4/0x2e0
>> [ 64.192287] acpi_ex_field_datum_io+0x88/0x200
>> [ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120
>> [ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0
>> [ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190
>> [ 64.193298] acpi_ex_store_object_to_node+0x150/0x240
>> [ 64.193527] acpi_ex_store+0x144/0x300
>> [ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580
>> [ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0
>> [ 64.194227] acpi_ps_parse_loop+0x100/0x6a0
>> [ 64.194477] acpi_ps_parse_aml+0x94/0x3b0
>> [ 64.194674] acpi_ps_execute_method+0x128/0x25c
>> [ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0
>> [ 64.195148] acpi_evaluate_object+0x138/0x2d0
>> [ 64.195380] acpi_evaluate_dsm+0xb8/0x134
>> [ 64.195613] acpi_check_dsm+0x34/0xdc
>> [ 64.195822] smbios_attr_is_visible+0x5c/0xb0
>> [ 64.196089] internal_create_group+0xd0/0x3d0
>> [ 64.196335] internal_create_groups+0x58/0xe0
>> [ 64.196584] sysfs_create_groups+0x20/0x30
>> [ 64.196813] device_add_groups+0x18/0x2c
>> [ 64.197039] bus_add_device+0x48/0x160
>> [ 64.197260] device_add+0x3a4/0x85c
>> [ 64.197463] pci_device_add+0x308/0x660
>> [ 64.197680] pci_scan_single_device+0xe4/0x114
>> [ 64.197941] pci_scan_slot+0x70/0x1fc
>> [ 64.198155] acpiphp_rescan_slot+0x90/0xa4
>> [ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300
>> [ 64.198584] acpi_device_hotplug+0x138/0x4c0
>> [ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c
>> [ 64.199045] process_one_work+0x1f4/0x460
>> [ 64.199277] worker_thread+0x188/0x4e0
>> [ 64.199492] kthread+0xe0/0xe4
>> [ 64.199671] ret_from_fork+0x10/0x20
>> [ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
>> [ 64.200820] ---[ end trace 0000000000000000 ]---
>>
>> (qemu)
>>
>> This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH
>> branch.
>>
>> The machine was started with:
>>
>> ./qemu-system-aarch64 -m 16G -nographic -machine
>> type=virt,gic-version=max -cpu cortex-a57 -initrd
>> /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64
>> -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device
>> virtio-scsi-pci -device virtio-blk-pci,drive=root -drive
>> if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device
>> pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios
>> ./pc-bios/edk2-aarch64-code.fd
>>
>> ./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so
>> nothing special.
>
> I have just tested debian-12-nocloud-arm64.qcow2 which features
> 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to
> hotplug/hot-unplug the virtio-net-pci device. Can you retry without
>
> -initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel
> /mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1
> console=ttyAMA0,115200 acpi=force" ?
Sure, so I got the same internal error without passing the kernel, the initrd,
and the append command.
I also tried with a pristine Debian .qcow2 taken from:
https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.qcow2
I'm building your Github branch:
gromero@gromero0:/mnt/git/qemu_/build$ git branch -vv | grep eauger
* arm-acpi-pcihp-rfc cf92b293ff [eauger/arm-acpi-pcihp-rfc] hw/arm/virt: Use ACPI PCI hotplug by default
gromero@gromero0:/mnt/git/qemu_/build$ git log --oneline -1
cf92b293ff (HEAD -> arm-acpi-pcihp-rfc, eauger/arm-acpi-pcihp-rfc) hw/arm/virt: Use ACPI PCI hotplug by default
I tried in a pristine ./build dir.
QEMU options:
gromero@gromero0:/mnt/git/qemu_/build$ ./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu max -drive if=none,file=/mnt/debian/debian-12-nocloud-arm64.qcow2,format=qcow2,id=hd -device virtio-blk-device,drive=hd -device pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -bios ./pc-bios/edk2-aarch64-code.fd
UEFI firmware (version edk2-stable202408-prebuilt.qemu.org built at 16:28:50 on Sep 12 2024)
gromero@gromero0:/mnt/git/qemu_/build$ md5sum ./pc-bios/edk2-aarch64-code.fd
3426cd25efb1593f86352ec0c61d66f5 ./pc-bios/edk2-aarch64-code.fd
and I get the same error:
root@localhost:~# QEMU 10.0.50 monitor - type 'help' for more information
(qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
(qemu) [ 56.865284] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000
[ 56.866620] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
[ 56.867711] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
[ 56.868287] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]
[ 56.869143] pci 0000:01:00.0: enabling Extended Tags
[ 56.900481] Internal error: synchronous external abort: 0000000096000050 [#1] SMP
[ 56.900911] Modules linked in: aes_ce_blk binfmt_misc aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha3_ce sha3_generic sha512_ce sha512_arm64 sha2_ce sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse drm efi_pstore dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_net net_failover failover virtio_blk crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio
[ 56.903132] CPU: 0 PID: 10 Comm: kworker/u2:0 Not tainted 6.1.0-34-arm64 #1 Debian 6.1.135-1
[ 56.903753] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
[ 56.904126] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
[ 56.904877] pstate: 60402005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 56.905085] pc : acpi_ex_system_memory_space_handler+0x290/0x300
[ 56.905306] lr : acpi_ev_address_space_dispatch+0x124/0x334
[ 56.905471] sp : ffff80000809b3b0
[ 56.905580] x29: ffff80000809b3b0 x28: ffff0003fcb852d0 x27: 0000000000000000
[ 56.905856] x26: ffff0003fcb85558 x25: ffff80000809b568 x24: 0000000000000001
[ 56.906092] x23: ffff80000809b568 x22: 0000000000000004 x21: ffff0000c1644980
[ 56.906333] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000
[ 56.906557] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
[ 56.906793] x14: 0000000000000000 x13: ffffb8324c78ebb0 x12: 0000000000000001
[ 56.907016] x11: 000000000000002e x10: ffffb8324cab6e20 x9 : ffffb8324b2076b4
[ 56.907236] x8 : 0000000000000001 x7 : ffffb8324b20e3d0 x6 : 00000000000000f8
[ 56.907473] x5 : ffff0000c1644980 x4 : 0000000000000000 x3 : 00000000090c0018
[ 56.907705] x2 : ffff800008837014 x1 : 00000000090c0018 x0 : 0000000000000001
[ 56.908026] Call trace:
[ 56.908226] acpi_ex_system_memory_space_handler+0x290/0x300
[ 56.908540] acpi_ev_address_space_dispatch+0x124/0x334
[ 56.908736] acpi_ex_access_region+0xe4/0x2e0
[ 56.908870] acpi_ex_field_datum_io+0x88/0x200
[ 56.909003] acpi_ex_write_with_update_rule+0xd4/0x120
[ 56.909152] acpi_ex_insert_into_field+0x210/0x2b0
[ 56.909285] acpi_ex_write_data_to_field+0xa0/0x190
[ 56.909426] acpi_ex_store_object_to_node+0x150/0x240
[ 56.909569] acpi_ex_store+0x144/0x300
[ 56.909688] acpi_ex_opcode_1A_1T_1R+0x218/0x580
[ 56.909824] acpi_ds_exec_end_op+0x24c/0x4b0
[ 56.909953] acpi_ps_parse_loop+0x100/0x6a0
[ 56.910074] acpi_ps_parse_aml+0x94/0x3b0
[ 56.910197] acpi_ps_execute_method+0x128/0x25c
[ 56.910331] acpi_ns_evaluate+0x1f0/0x2d0
[ 56.910445] acpi_evaluate_object+0x138/0x2d0
[ 56.910573] acpi_evaluate_dsm+0xb8/0x134
[ 56.910696] acpi_check_dsm+0x34/0xdc
[ 56.910809] smbios_attr_is_visible+0x5c/0xb0
[ 56.910937] internal_create_group+0xd0/0x3d0
[ 56.911066] internal_create_groups+0x58/0xe0
[ 56.911194] sysfs_create_groups+0x20/0x30
[ 56.911315] device_add_groups+0x18/0x2c
[ 56.911435] bus_add_device+0x48/0x160
[ 56.911552] device_add+0x3a4/0x85c
[ 56.911678] pci_device_add+0x308/0x660
[ 56.911803] pci_scan_single_device+0xe4/0x114
[ 56.911937] pci_scan_slot+0x70/0x1fc
[ 56.912039] acpiphp_rescan_slot+0x90/0xa4
[ 56.912161] acpiphp_hotplug_notify+0x2a8/0x300
[ 56.912290] acpi_device_hotplug+0x138/0x4c0
[ 56.912428] acpi_hotplug_work_fn+0x2c/0x4c
[ 56.912549] process_one_work+0x1f4/0x460
[ 56.912679] worker_thread+0x188/0x4e0
[ 56.912792] kthread+0xe0/0xe4
[ 56.912892] ret_from_fork+0x10/0x20
[ 56.913136] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
[ 56.913532] ---[ end trace 0000000000000000 ]---
I'm wondering if we are using the same ./pc-bios/edk2-aarch64-code.fd, although
I can't see how it would cause such error.
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 00/24] APCI PCI Hotplug support on ARM
2025-05-07 0:51 ` Gustavo Romero
@ 2025-05-07 1:13 ` Gustavo Romero
2025-05-14 16:27 ` Gustavo Romero
0 siblings, 1 reply; 46+ messages in thread
From: Gustavo Romero @ 2025-05-07 1:13 UTC (permalink / raw)
To: eric.auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 5/6/25 21:51, Gustavo Romero wrote:
> Hi Eric,
>
> On 5/6/25 12:58, Eric Auger wrote:
>> Hi Gustavo,
>>
>> On 5/5/25 3:26 PM, Gustavo Romero wrote:
>>> Hi Eric,
>>>
>>> On 4/28/25 07:25, Eric Auger wrote:
>>>> This series enables APCI PCI hotplug/hotunplug on ARM
>>>> and makes it default for 10.1 machine type. This aligns with
>>>> x86 q35 machine. Expected benefits should be similar to
>>>> those listed in [1].
>>>>
>>>> The infrastructure used in x86 is heavily reused and a
>>>> huge part of the series consists in moving code from
>>>> hw/i386/acpi-build.c to a generic place and slightly
>>>> adapting it to make it usable on ARM. The DSDT table is
>>>> augmented to support ACPI PCI hotplug elements.
>>>>
>>>> On ARM we use use a GED event to notify the OS about
>>>> hotplug events.
>>>>
>>>> I have not noticed any tests/qtest/bios-tables-test failures
>>>> neither on x86 nor ARM. x86 DSDT table has not changed.
>>>> ARM DSDT table definitively has but there are no tests
>>>> impacted. ARM misses hotplug tests that do exist on x86. This
>>>> most probably should be considered in the future.
>>>>
>>>> Best Regards
>>>>
>>>> Eric
>>>>
>>>> This series can be found at:
>>>> https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
>>>>
>>>> [1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
>>>> https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
>>>
>>> I've just started to review your series and went to a quick smoke test
>>> by hotplugging a net adapter and got the following kernel internal error:
>>>
>>> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
>>> (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class
>>> 0x020000
>>> [ 64.165895] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
>>> [ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff
>>> 64bit pref]
>>> [ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff
>>> pref]
>>> [ 64.167153] pci 0000:01:00.0: enabling Extended Tags
>>> [ 64.179972] Internal error: synchronous external abort:
>>> 0000000096000050 [#1] SMP
>>> [ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce
>>> polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64
>>> sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse
>>> efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables
>>> x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi
>>> virtio_net scsi_mod net_failover failover virtio_blk scsi_common
>>> crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev
>>> virtio_pci_modern_dev virtio_mmio
>>> [ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted
>>> 6.1.0-30-arm64 #1 Debian 6.1.124-1
>>> [ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS
>>> edk2-stable202408-prebuilt.qemu.org 08/13/2024
>>> [ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
>>> [ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS
>>> BTYPE=--)
>>> [ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300
>>> [ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334
>>> [ 64.186490] sp : ffff80000a6bb3b0
>>> [ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27:
>>> 0000000000000000
>>> [ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24:
>>> 0000000000000001
>>> [ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21:
>>> ffff0000c206cb00
>>> [ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18:
>>> 0000000000000000
>>> [ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
>>> 0000000000000000
>>> [ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12:
>>> 4d7a3553e5c937d0
>>> [ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :
>>> ffff800008735b34
>>> [ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 :
>>> 00000000000000f8
>>> [ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 :
>>> 00000000090c0018
>>> [ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 :
>>> 0000000000000001
>>> [ 64.190734] Call trace:
>>> [ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300
>>> [ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334
>>> [ 64.192042] acpi_ex_access_region+0xe4/0x2e0
>>> [ 64.192287] acpi_ex_field_datum_io+0x88/0x200
>>> [ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120
>>> [ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0
>>> [ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190
>>> [ 64.193298] acpi_ex_store_object_to_node+0x150/0x240
>>> [ 64.193527] acpi_ex_store+0x144/0x300
>>> [ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580
>>> [ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0
>>> [ 64.194227] acpi_ps_parse_loop+0x100/0x6a0
>>> [ 64.194477] acpi_ps_parse_aml+0x94/0x3b0
>>> [ 64.194674] acpi_ps_execute_method+0x128/0x25c
>>> [ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0
>>> [ 64.195148] acpi_evaluate_object+0x138/0x2d0
>>> [ 64.195380] acpi_evaluate_dsm+0xb8/0x134
>>> [ 64.195613] acpi_check_dsm+0x34/0xdc
>>> [ 64.195822] smbios_attr_is_visible+0x5c/0xb0
>>> [ 64.196089] internal_create_group+0xd0/0x3d0
>>> [ 64.196335] internal_create_groups+0x58/0xe0
>>> [ 64.196584] sysfs_create_groups+0x20/0x30
>>> [ 64.196813] device_add_groups+0x18/0x2c
>>> [ 64.197039] bus_add_device+0x48/0x160
>>> [ 64.197260] device_add+0x3a4/0x85c
>>> [ 64.197463] pci_device_add+0x308/0x660
>>> [ 64.197680] pci_scan_single_device+0xe4/0x114
>>> [ 64.197941] pci_scan_slot+0x70/0x1fc
>>> [ 64.198155] acpiphp_rescan_slot+0x90/0xa4
>>> [ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300
>>> [ 64.198584] acpi_device_hotplug+0x138/0x4c0
>>> [ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c
>>> [ 64.199045] process_one_work+0x1f4/0x460
>>> [ 64.199277] worker_thread+0x188/0x4e0
>>> [ 64.199492] kthread+0xe0/0xe4
>>> [ 64.199671] ret_from_fork+0x10/0x20
>>> [ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
>>> [ 64.200820] ---[ end trace 0000000000000000 ]---
>>>
>>> (qemu)
>>>
>>> This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH
>>> branch.
>>>
>>> The machine was started with:
>>>
>>> ./qemu-system-aarch64 -m 16G -nographic -machine
>>> type=virt,gic-version=max -cpu cortex-a57 -initrd
>>> /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64
>>> -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device
>>> virtio-scsi-pci -device virtio-blk-pci,drive=root -drive
>>> if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device
>>> pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios
>>> ./pc-bios/edk2-aarch64-code.fd
>>>
>>> ./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so
>>> nothing special.
>>
>> I have just tested debian-12-nocloud-arm64.qcow2 which features
>> 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to
>> hotplug/hot-unplug the virtio-net-pci device. Can you retry without
>>
>> -initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel
>> /mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1
>> console=ttyAMA0,115200 acpi=force" ?
>
> Sure, so I got the same internal error without passing the kernel, the initrd,
> and the append command.
>
>
> I also tried with a pristine Debian .qcow2 taken from:
>
> https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.qcow2
>
> I'm building your Github branch:
>
> gromero@gromero0:/mnt/git/qemu_/build$ git branch -vv | grep eauger
> * arm-acpi-pcihp-rfc cf92b293ff [eauger/arm-acpi-pcihp-rfc] hw/arm/virt: Use ACPI PCI hotplug by default
> gromero@gromero0:/mnt/git/qemu_/build$ git log --oneline -1
> cf92b293ff (HEAD -> arm-acpi-pcihp-rfc, eauger/arm-acpi-pcihp-rfc) hw/arm/virt: Use ACPI PCI hotplug by default
>
> I tried in a pristine ./build dir.
>
> QEMU options:
>
> gromero@gromero0:/mnt/git/qemu_/build$ ./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu max -drive if=none,file=/mnt/debian/debian-12-nocloud-arm64.qcow2,format=qcow2,id=hd -device virtio-blk-device,drive=hd -device pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -bios ./pc-bios/edk2-aarch64-code.fd
> UEFI firmware (version edk2-stable202408-prebuilt.qemu.org built at 16:28:50 on Sep 12 2024)
>
> gromero@gromero0:/mnt/git/qemu_/build$ md5sum ./pc-bios/edk2-aarch64-code.fd
> 3426cd25efb1593f86352ec0c61d66f5 ./pc-bios/edk2-aarch64-code.fd
>
> and I get the same error:
>
> root@localhost:~# QEMU 10.0.50 monitor - type 'help' for more information
> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
> (qemu) [ 56.865284] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000
> [ 56.866620] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
> [ 56.867711] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
> [ 56.868287] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]
> [ 56.869143] pci 0000:01:00.0: enabling Extended Tags
> [ 56.900481] Internal error: synchronous external abort: 0000000096000050 [#1] SMP
> [ 56.900911] Modules linked in: aes_ce_blk binfmt_misc aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha3_ce sha3_generic sha512_ce sha512_arm64 sha2_ce sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse drm efi_pstore dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_net net_failover failover virtio_blk crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio
> [ 56.903132] CPU: 0 PID: 10 Comm: kworker/u2:0 Not tainted 6.1.0-34-arm64 #1 Debian 6.1.135-1
> [ 56.903753] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
> [ 56.904126] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
> [ 56.904877] pstate: 60402005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [ 56.905085] pc : acpi_ex_system_memory_space_handler+0x290/0x300
> [ 56.905306] lr : acpi_ev_address_space_dispatch+0x124/0x334
> [ 56.905471] sp : ffff80000809b3b0
> [ 56.905580] x29: ffff80000809b3b0 x28: ffff0003fcb852d0 x27: 0000000000000000
> [ 56.905856] x26: ffff0003fcb85558 x25: ffff80000809b568 x24: 0000000000000001
> [ 56.906092] x23: ffff80000809b568 x22: 0000000000000004 x21: ffff0000c1644980
> [ 56.906333] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000
> [ 56.906557] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
> [ 56.906793] x14: 0000000000000000 x13: ffffb8324c78ebb0 x12: 0000000000000001
> [ 56.907016] x11: 000000000000002e x10: ffffb8324cab6e20 x9 : ffffb8324b2076b4
> [ 56.907236] x8 : 0000000000000001 x7 : ffffb8324b20e3d0 x6 : 00000000000000f8
> [ 56.907473] x5 : ffff0000c1644980 x4 : 0000000000000000 x3 : 00000000090c0018
> [ 56.907705] x2 : ffff800008837014 x1 : 00000000090c0018 x0 : 0000000000000001
> [ 56.908026] Call trace:
> [ 56.908226] acpi_ex_system_memory_space_handler+0x290/0x300
> [ 56.908540] acpi_ev_address_space_dispatch+0x124/0x334
> [ 56.908736] acpi_ex_access_region+0xe4/0x2e0
> [ 56.908870] acpi_ex_field_datum_io+0x88/0x200
> [ 56.909003] acpi_ex_write_with_update_rule+0xd4/0x120
> [ 56.909152] acpi_ex_insert_into_field+0x210/0x2b0
> [ 56.909285] acpi_ex_write_data_to_field+0xa0/0x190
> [ 56.909426] acpi_ex_store_object_to_node+0x150/0x240
> [ 56.909569] acpi_ex_store+0x144/0x300
> [ 56.909688] acpi_ex_opcode_1A_1T_1R+0x218/0x580
> [ 56.909824] acpi_ds_exec_end_op+0x24c/0x4b0
> [ 56.909953] acpi_ps_parse_loop+0x100/0x6a0
> [ 56.910074] acpi_ps_parse_aml+0x94/0x3b0
> [ 56.910197] acpi_ps_execute_method+0x128/0x25c
> [ 56.910331] acpi_ns_evaluate+0x1f0/0x2d0
> [ 56.910445] acpi_evaluate_object+0x138/0x2d0
> [ 56.910573] acpi_evaluate_dsm+0xb8/0x134
> [ 56.910696] acpi_check_dsm+0x34/0xdc
> [ 56.910809] smbios_attr_is_visible+0x5c/0xb0
> [ 56.910937] internal_create_group+0xd0/0x3d0
> [ 56.911066] internal_create_groups+0x58/0xe0
> [ 56.911194] sysfs_create_groups+0x20/0x30
> [ 56.911315] device_add_groups+0x18/0x2c
> [ 56.911435] bus_add_device+0x48/0x160
> [ 56.911552] device_add+0x3a4/0x85c
> [ 56.911678] pci_device_add+0x308/0x660
> [ 56.911803] pci_scan_single_device+0xe4/0x114
> [ 56.911937] pci_scan_slot+0x70/0x1fc
> [ 56.912039] acpiphp_rescan_slot+0x90/0xa4
> [ 56.912161] acpiphp_hotplug_notify+0x2a8/0x300
> [ 56.912290] acpi_device_hotplug+0x138/0x4c0
> [ 56.912428] acpi_hotplug_work_fn+0x2c/0x4c
> [ 56.912549] process_one_work+0x1f4/0x460
> [ 56.912679] worker_thread+0x188/0x4e0
> [ 56.912792] kthread+0xe0/0xe4
> [ 56.912892] ret_from_fork+0x10/0x20
> [ 56.913136] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
> [ 56.913532] ---[ end trace 0000000000000000 ]---
>
>
> I'm wondering if we are using the same ./pc-bios/edk2-aarch64-code.fd, although
> I can't see how it would cause such error.
hmm actually I'm able to properly hotplug the network device using the exactly
same sw stack as above (your branch, Debian 12, edk2) but running on an arm64 host.
It seems your running on a arm64 host since you're passing --enable-kvm. Do you
mind trying it on a x86_64 or without --enable-kvm on the arm64 host? I'm able to
reproduce it on arm64 host without --enable-kvm but not with --enable-kvm passed to QEMU.
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events
2025-04-28 10:25 ` [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events Eric Auger
@ 2025-05-14 16:20 ` Gustavo Romero
2025-05-14 16:46 ` Eric Auger
0 siblings, 1 reply; 46+ messages in thread
From: Gustavo Romero @ 2025-05-14 16:20 UTC (permalink / raw)
To: Eric Auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Eric,
On 4/28/25 07:25, Eric Auger wrote:
> QEMU will notify the OS about PCI hotplug/hotunplug events through
> GED interrupts. Let the GED device handle a new PCI hotplug event.
> On its occurence it calls the \\_SB.PCI0.PCNT method with the BLCK
nit: occurrence -^
> 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
nit: period missing ^
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> include/hw/acpi/generic_event_device.h | 5 +++++
> include/hw/acpi/pcihp.h | 2 ++
> hw/acpi/generic_event_device.c | 14 ++++++++++++++
> 3 files changed, 21 insertions(+)
>
> diff --git a/include/hw/acpi/generic_event_device.h b/include/hw/acpi/generic_event_device.h
> index d2dac87b4a..28be6c0582 100644
> --- a/include/hw/acpi/generic_event_device.h
> +++ b/include/hw/acpi/generic_event_device.h
> @@ -63,6 +63,7 @@
> #include "hw/acpi/memory_hotplug.h"
> #include "hw/acpi/ghes.h"
> #include "hw/acpi/cpu.h"
> +#include "hw/acpi/pcihp.h"
> #include "qom/object.h"
>
> #define ACPI_POWER_BUTTON_DEVICE "PWRB"
> @@ -101,6 +102,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)
> #define ACPI_GED_PWR_DOWN_EVT 0x2
> #define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4
> #define ACPI_GED_CPU_HOTPLUG_EVT 0x8
> +#define ACPI_GED_PCI_HOTPLUG_EVT 0x10
>
> typedef struct GEDState {
> MemoryRegion evt;
> @@ -114,6 +116,9 @@ struct AcpiGedState {
> MemoryRegion container_memhp;
> CPUHotplugState cpuhp_state;
> MemoryRegion container_cpuhp;
> + AcpiPciHpState pcihp_state;
> + MemoryRegion container_pcihp;
> +
> GEDState ged_state;
> uint32_t ged_event_bitmap;
> qemu_irq irq;
> diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
> index 451ef74284..abb6e14549 100644
> --- a/include/hw/acpi/pcihp.h
> +++ b/include/hw/acpi/pcihp.h
> @@ -38,6 +38,8 @@
> #define ACPI_PCIHP_SEJ_BASE 0x8
> #define ACPI_PCIHP_BNMR_BASE 0x10
>
> +#define ACPI_PCI_HOTPLUG_REG_LEN 0x14
This is wrong, no? It should be 0x18, i.e. 24 bytes or 6 registers of 4 bytes.
I think it's better to move the defines in pcihp.c into pcihp.h and
use them to define ACPI_PCI_HOTPLUG_REG_LEN so the values are consistent, like:
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 82b8ea2811..3ab8b9de94 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -44,14 +44,6 @@
#include "qobject/qnum.h"
#include "trace.h"
-#define ACPI_PCIHP_SIZE 0x0018
-#define PCI_UP_BASE 0x0000
-#define PCI_DOWN_BASE 0x0004
-#define PCI_EJ_BASE 0x0008
-#define PCI_RMV_BASE 0x000c
-#define PCI_SEL_BASE 0x0010
-#define PCI_AIDX_BASE 0x0014
-
typedef struct AcpiPciHpFind {
int bsel;
PCIBus *bus;
diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
index abb6e14549..6b79adcaef 100644
--- a/include/hw/acpi/pcihp.h
+++ b/include/hw/acpi/pcihp.h
@@ -38,7 +38,15 @@
#define ACPI_PCIHP_SEJ_BASE 0x8
#define ACPI_PCIHP_BNMR_BASE 0x10
-#define ACPI_PCI_HOTPLUG_REG_LEN 0x14
+#define ACPI_PCIHP_SIZE 0x0018
+#define PCI_UP_BASE 0x0000
+#define PCI_DOWN_BASE 0x0004
+#define PCI_EJ_BASE 0x0008
+#define PCI_RMV_BASE 0x000c
+#define PCI_SEL_BASE 0x0010
+#define PCI_AIDX_BASE 0x0014
+
+#define ACPI_PCI_HOTPLUG_REG_LEN ACPI_PCIHP_SIZE
typedef struct AcpiPciHpPciStatus {
uint32_t up;
or even use only one of them (ACPI_PCI_HOTPLUG_REG_LEN, ACPI_PCIHP_SIZE, or
another new name that would fit better in both contexts).
Cheers,
Gustavo
> +
> typedef struct AcpiPciHpPciStatus {
> uint32_t up;
> uint32_t down;
> diff --git a/hw/acpi/generic_event_device.c b/hw/acpi/generic_event_device.c
> index 7b2d582fff..0fd8baba97 100644
> --- a/hw/acpi/generic_event_device.c
> +++ b/hw/acpi/generic_event_device.c
> @@ -26,6 +26,7 @@ static const uint32_t ged_supported_events[] = {
> ACPI_GED_PWR_DOWN_EVT,
> ACPI_GED_NVDIMM_HOTPLUG_EVT,
> ACPI_GED_CPU_HOTPLUG_EVT,
> + ACPI_GED_PCI_HOTPLUG_EVT,
> };
>
> /*
> @@ -121,6 +122,12 @@ void build_ged_aml(Aml *table, const char *name, HotplugHandler *hotplug_dev,
> aml_notify(aml_name("\\_SB.NVDR"),
> aml_int(0x80)));
> break;
> + case ACPI_GED_PCI_HOTPLUG_EVT:
> + aml_append(if_ctx,
> + aml_acquire(aml_name("\\_SB.PCI0.BLCK"), 0xFFFF));
> + aml_append(if_ctx, aml_call0("\\_SB.PCI0.PCNT"));
> + aml_append(if_ctx, aml_release(aml_name("\\_SB.PCI0.BLCK")));
> + break;
> default:
> /*
> * Please make sure all the events in ged_supported_events[]
> @@ -299,6 +306,8 @@ static void acpi_ged_send_event(AcpiDeviceIf *adev, AcpiEventStatusBits ev)
> sel = ACPI_GED_NVDIMM_HOTPLUG_EVT;
> } else if (ev & ACPI_CPU_HOTPLUG_STATUS) {
> sel = ACPI_GED_CPU_HOTPLUG_EVT;
> + } else if (ev & ACPI_PCI_HOTPLUG_STATUS) {
> + sel = ACPI_GED_PCI_HOTPLUG_EVT;
> } else {
> /* Unknown event. Return without generating interrupt. */
> warn_report("GED: Unsupported event %d. No irq injected", ev);
> @@ -428,6 +437,11 @@ static void acpi_ged_realize(DeviceState *dev, Error **errp)
> cpu_hotplug_hw_init(&s->container_cpuhp, OBJECT(dev),
> &s->cpuhp_state, 0);
> break;
> + case ACPI_GED_PCI_HOTPLUG_EVT:
> + memory_region_init(&s->container_pcihp, OBJECT(dev),
> + "pcihp container",
> + ACPI_PCI_HOTPLUG_REG_LEN);
> + sysbus_init_mmio(sbd, &s->container_pcihp);
> }
> ged_events--;
> }
^ permalink raw reply related [flat|nested] 46+ messages in thread
* Re: [RFC 00/24] APCI PCI Hotplug support on ARM
2025-05-07 1:13 ` Gustavo Romero
@ 2025-05-14 16:27 ` Gustavo Romero
2025-05-14 16:51 ` Eric Auger
0 siblings, 1 reply; 46+ messages in thread
From: Gustavo Romero @ 2025-05-14 16:27 UTC (permalink / raw)
To: eric.auger, eric.auger.pro, qemu-devel, qemu-arm, peter.maydell,
imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron, Alex Bennée
Hi Eric,
On 5/7/25 22:13, Gustavo Romero wrote:
> Hi Eric,
>
> On 5/6/25 21:51, Gustavo Romero wrote:
>> Hi Eric,
>>
>> On 5/6/25 12:58, Eric Auger wrote:
>>> Hi Gustavo,
>>>
>>> On 5/5/25 3:26 PM, Gustavo Romero wrote:
>>>> Hi Eric,
>>>>
>>>> On 4/28/25 07:25, Eric Auger wrote:
>>>>> This series enables APCI PCI hotplug/hotunplug on ARM
>>>>> and makes it default for 10.1 machine type. This aligns with
>>>>> x86 q35 machine. Expected benefits should be similar to
>>>>> those listed in [1].
>>>>>
>>>>> The infrastructure used in x86 is heavily reused and a
>>>>> huge part of the series consists in moving code from
>>>>> hw/i386/acpi-build.c to a generic place and slightly
>>>>> adapting it to make it usable on ARM. The DSDT table is
>>>>> augmented to support ACPI PCI hotplug elements.
>>>>>
>>>>> On ARM we use use a GED event to notify the OS about
>>>>> hotplug events.
>>>>>
>>>>> I have not noticed any tests/qtest/bios-tables-test failures
>>>>> neither on x86 nor ARM. x86 DSDT table has not changed.
>>>>> ARM DSDT table definitively has but there are no tests
>>>>> impacted. ARM misses hotplug tests that do exist on x86. This
>>>>> most probably should be considered in the future.
>>>>>
>>>>> Best Regards
>>>>>
>>>>> Eric
>>>>>
>>>>> This series can be found at:
>>>>> https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
>>>>>
>>>>> [1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
>>>>> https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
>>>>
>>>> I've just started to review your series and went to a quick smoke test
>>>> by hotplugging a net adapter and got the following kernel internal error:
>>>>
>>>> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
>>>> (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class
>>>> 0x020000
>>>> [ 64.165895] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
>>>> [ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff
>>>> 64bit pref]
>>>> [ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff
>>>> pref]
>>>> [ 64.167153] pci 0000:01:00.0: enabling Extended Tags
>>>> [ 64.179972] Internal error: synchronous external abort:
>>>> 0000000096000050 [#1] SMP
>>>> [ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce
>>>> polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64
>>>> sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse
>>>> efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables
>>>> x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi
>>>> virtio_net scsi_mod net_failover failover virtio_blk scsi_common
>>>> crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev
>>>> virtio_pci_modern_dev virtio_mmio
>>>> [ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted
>>>> 6.1.0-30-arm64 #1 Debian 6.1.124-1
>>>> [ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS
>>>> edk2-stable202408-prebuilt.qemu.org 08/13/2024
>>>> [ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
>>>> [ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS
>>>> BTYPE=--)
>>>> [ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300
>>>> [ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334
>>>> [ 64.186490] sp : ffff80000a6bb3b0
>>>> [ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27:
>>>> 0000000000000000
>>>> [ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24:
>>>> 0000000000000001
>>>> [ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21:
>>>> ffff0000c206cb00
>>>> [ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18:
>>>> 0000000000000000
>>>> [ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
>>>> 0000000000000000
>>>> [ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12:
>>>> 4d7a3553e5c937d0
>>>> [ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :
>>>> ffff800008735b34
>>>> [ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 :
>>>> 00000000000000f8
>>>> [ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 :
>>>> 00000000090c0018
>>>> [ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 :
>>>> 0000000000000001
>>>> [ 64.190734] Call trace:
>>>> [ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300
>>>> [ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334
>>>> [ 64.192042] acpi_ex_access_region+0xe4/0x2e0
>>>> [ 64.192287] acpi_ex_field_datum_io+0x88/0x200
>>>> [ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120
>>>> [ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0
>>>> [ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190
>>>> [ 64.193298] acpi_ex_store_object_to_node+0x150/0x240
>>>> [ 64.193527] acpi_ex_store+0x144/0x300
>>>> [ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580
>>>> [ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0
>>>> [ 64.194227] acpi_ps_parse_loop+0x100/0x6a0
>>>> [ 64.194477] acpi_ps_parse_aml+0x94/0x3b0
>>>> [ 64.194674] acpi_ps_execute_method+0x128/0x25c
>>>> [ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0
>>>> [ 64.195148] acpi_evaluate_object+0x138/0x2d0
>>>> [ 64.195380] acpi_evaluate_dsm+0xb8/0x134
>>>> [ 64.195613] acpi_check_dsm+0x34/0xdc
>>>> [ 64.195822] smbios_attr_is_visible+0x5c/0xb0
>>>> [ 64.196089] internal_create_group+0xd0/0x3d0
>>>> [ 64.196335] internal_create_groups+0x58/0xe0
>>>> [ 64.196584] sysfs_create_groups+0x20/0x30
>>>> [ 64.196813] device_add_groups+0x18/0x2c
>>>> [ 64.197039] bus_add_device+0x48/0x160
>>>> [ 64.197260] device_add+0x3a4/0x85c
>>>> [ 64.197463] pci_device_add+0x308/0x660
>>>> [ 64.197680] pci_scan_single_device+0xe4/0x114
>>>> [ 64.197941] pci_scan_slot+0x70/0x1fc
>>>> [ 64.198155] acpiphp_rescan_slot+0x90/0xa4
>>>> [ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300
>>>> [ 64.198584] acpi_device_hotplug+0x138/0x4c0
>>>> [ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c
>>>> [ 64.199045] process_one_work+0x1f4/0x460
>>>> [ 64.199277] worker_thread+0x188/0x4e0
>>>> [ 64.199492] kthread+0xe0/0xe4
>>>> [ 64.199671] ret_from_fork+0x10/0x20
>>>> [ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
>>>> [ 64.200820] ---[ end trace 0000000000000000 ]---
>>>>
>>>> (qemu)
>>>>
>>>> This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH
>>>> branch.
>>>>
>>>> The machine was started with:
>>>>
>>>> ./qemu-system-aarch64 -m 16G -nographic -machine
>>>> type=virt,gic-version=max -cpu cortex-a57 -initrd
>>>> /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64
>>>> -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device
>>>> virtio-scsi-pci -device virtio-blk-pci,drive=root -drive
>>>> if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device
>>>> pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios
>>>> ./pc-bios/edk2-aarch64-code.fd
>>>>
>>>> ./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so
>>>> nothing special.
>>>
>>> I have just tested debian-12-nocloud-arm64.qcow2 which features
>>> 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to
>>> hotplug/hot-unplug the virtio-net-pci device. Can you retry without
>>>
>>> -initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel
>>> /mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1
>>> console=ttyAMA0,115200 acpi=force" ?
>>
>> Sure, so I got the same internal error without passing the kernel, the initrd,
>> and the append command.
>>
>>
>> I also tried with a pristine Debian .qcow2 taken from:
>>
>> https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.qcow2
>>
>> I'm building your Github branch:
>>
>> gromero@gromero0:/mnt/git/qemu_/build$ git branch -vv | grep eauger
>> * arm-acpi-pcihp-rfc cf92b293ff [eauger/arm-acpi-pcihp-rfc] hw/arm/virt: Use ACPI PCI hotplug by default
>> gromero@gromero0:/mnt/git/qemu_/build$ git log --oneline -1
>> cf92b293ff (HEAD -> arm-acpi-pcihp-rfc, eauger/arm-acpi-pcihp-rfc) hw/arm/virt: Use ACPI PCI hotplug by default
>>
>> I tried in a pristine ./build dir.
>>
>> QEMU options:
>>
>> gromero@gromero0:/mnt/git/qemu_/build$ ./qemu-system-aarch64 -m 16G -nographic -machine type=virt,gic-version=max -cpu max -drive if=none,file=/mnt/debian/debian-12-nocloud-arm64.qcow2,format=qcow2,id=hd -device virtio-blk-device,drive=hd -device pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -bios ./pc-bios/edk2-aarch64-code.fd
>> UEFI firmware (version edk2-stable202408-prebuilt.qemu.org built at 16:28:50 on Sep 12 2024)
>>
>> gromero@gromero0:/mnt/git/qemu_/build$ md5sum ./pc-bios/edk2-aarch64-code.fd
>> 3426cd25efb1593f86352ec0c61d66f5 ./pc-bios/edk2-aarch64-code.fd
>>
>> and I get the same error:
>>
>> root@localhost:~# QEMU 10.0.50 monitor - type 'help' for more information
>> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
>> (qemu) [ 56.865284] pci 0000:01:00.0: [1af4:1041] type 00 class 0x020000
>> [ 56.866620] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
>> [ 56.867711] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff 64bit pref]
>> [ 56.868287] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff pref]
>> [ 56.869143] pci 0000:01:00.0: enabling Extended Tags
>> [ 56.900481] Internal error: synchronous external abort: 0000000096000050 [#1] SMP
>> [ 56.900911] Modules linked in: aes_ce_blk binfmt_misc aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha3_ce sha3_generic sha512_ce sha512_arm64 sha2_ce sha256_arm64 sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse drm efi_pstore dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_net net_failover failover virtio_blk crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio
>> [ 56.903132] CPU: 0 PID: 10 Comm: kworker/u2:0 Not tainted 6.1.0-34-arm64 #1 Debian 6.1.135-1
>> [ 56.903753] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202408-prebuilt.qemu.org 08/13/2024
>> [ 56.904126] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
>> [ 56.904877] pstate: 60402005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
>> [ 56.905085] pc : acpi_ex_system_memory_space_handler+0x290/0x300
>> [ 56.905306] lr : acpi_ev_address_space_dispatch+0x124/0x334
>> [ 56.905471] sp : ffff80000809b3b0
>> [ 56.905580] x29: ffff80000809b3b0 x28: ffff0003fcb852d0 x27: 0000000000000000
>> [ 56.905856] x26: ffff0003fcb85558 x25: ffff80000809b568 x24: 0000000000000001
>> [ 56.906092] x23: ffff80000809b568 x22: 0000000000000004 x21: ffff0000c1644980
>> [ 56.906333] x20: 00000000090c0014 x19: 0000000000000020 x18: 0000000000000000
>> [ 56.906557] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
>> [ 56.906793] x14: 0000000000000000 x13: ffffb8324c78ebb0 x12: 0000000000000001
>> [ 56.907016] x11: 000000000000002e x10: ffffb8324cab6e20 x9 : ffffb8324b2076b4
>> [ 56.907236] x8 : 0000000000000001 x7 : ffffb8324b20e3d0 x6 : 00000000000000f8
>> [ 56.907473] x5 : ffff0000c1644980 x4 : 0000000000000000 x3 : 00000000090c0018
>> [ 56.907705] x2 : ffff800008837014 x1 : 00000000090c0018 x0 : 0000000000000001
>> [ 56.908026] Call trace:
>> [ 56.908226] acpi_ex_system_memory_space_handler+0x290/0x300
>> [ 56.908540] acpi_ev_address_space_dispatch+0x124/0x334
>> [ 56.908736] acpi_ex_access_region+0xe4/0x2e0
>> [ 56.908870] acpi_ex_field_datum_io+0x88/0x200
>> [ 56.909003] acpi_ex_write_with_update_rule+0xd4/0x120
>> [ 56.909152] acpi_ex_insert_into_field+0x210/0x2b0
>> [ 56.909285] acpi_ex_write_data_to_field+0xa0/0x190
>> [ 56.909426] acpi_ex_store_object_to_node+0x150/0x240
>> [ 56.909569] acpi_ex_store+0x144/0x300
>> [ 56.909688] acpi_ex_opcode_1A_1T_1R+0x218/0x580
>> [ 56.909824] acpi_ds_exec_end_op+0x24c/0x4b0
>> [ 56.909953] acpi_ps_parse_loop+0x100/0x6a0
>> [ 56.910074] acpi_ps_parse_aml+0x94/0x3b0
>> [ 56.910197] acpi_ps_execute_method+0x128/0x25c
>> [ 56.910331] acpi_ns_evaluate+0x1f0/0x2d0
>> [ 56.910445] acpi_evaluate_object+0x138/0x2d0
>> [ 56.910573] acpi_evaluate_dsm+0xb8/0x134
>> [ 56.910696] acpi_check_dsm+0x34/0xdc
>> [ 56.910809] smbios_attr_is_visible+0x5c/0xb0
>> [ 56.910937] internal_create_group+0xd0/0x3d0
>> [ 56.911066] internal_create_groups+0x58/0xe0
>> [ 56.911194] sysfs_create_groups+0x20/0x30
>> [ 56.911315] device_add_groups+0x18/0x2c
>> [ 56.911435] bus_add_device+0x48/0x160
>> [ 56.911552] device_add+0x3a4/0x85c
>> [ 56.911678] pci_device_add+0x308/0x660
>> [ 56.911803] pci_scan_single_device+0xe4/0x114
>> [ 56.911937] pci_scan_slot+0x70/0x1fc
>> [ 56.912039] acpiphp_rescan_slot+0x90/0xa4
>> [ 56.912161] acpiphp_hotplug_notify+0x2a8/0x300
>> [ 56.912290] acpi_device_hotplug+0x138/0x4c0
>> [ 56.912428] acpi_hotplug_work_fn+0x2c/0x4c
>> [ 56.912549] process_one_work+0x1f4/0x460
>> [ 56.912679] worker_thread+0x188/0x4e0
>> [ 56.912792] kthread+0xe0/0xe4
>> [ 56.912892] ret_from_fork+0x10/0x20
>> [ 56.913136] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
>> [ 56.913532] ---[ end trace 0000000000000000 ]---
>>
>>
>> I'm wondering if we are using the same ./pc-bios/edk2-aarch64-code.fd, although
>> I can't see how it would cause such error.
>
> hmm actually I'm able to properly hotplug the network device using the exactly
> same sw stack as above (your branch, Debian 12, edk2) but running on an arm64 host.
>
> It seems your running on a arm64 host since you're passing --enable-kvm. Do you
> mind trying it on a x86_64 or without --enable-kvm on the arm64 host? I'm able to
> reproduce it on arm64 host without --enable-kvm but not with --enable-kvm passed to QEMU.
What causes this behaviour is that the container size is < than the register region
in the pcihp device:
[...]
00000000090c0000-00000000090c0013 (prio 0, i/o): pcihp container
00000000090c0000-00000000090c0017 (prio 0, i/o): acpi-pci-hotplug
[...]
Because ACPI_PCI_HOTPLUG_REG_LEN and ACPI_PCIHP_SIZE values don't match. Please see my
comment in patch 18/24 for a possible fix for it.
Cheers,
Gustavo
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events
2025-05-14 16:20 ` Gustavo Romero
@ 2025-05-14 16:46 ` Eric Auger
0 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-05-14 16:46 UTC (permalink / raw)
To: Gustavo Romero, eric.auger.pro, qemu-devel, qemu-arm,
peter.maydell, imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron
Hi Gustavo,
On 5/14/25 6:20 PM, Gustavo Romero wrote:
> Hi Eric,
>
> On 4/28/25 07:25, Eric Auger wrote:
>> QEMU will notify the OS about PCI hotplug/hotunplug events through
>> GED interrupts. Let the GED device handle a new PCI hotplug event.
>> On its occurence it calls the \\_SB.PCI0.PCNT method with the BLCK
>
> nit: occurrence -^
>
>
>> 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
>
> nit: period missing ^
>
>
>> Signed-off-by: Eric Auger <eric.auger@redhat.com>
>> ---
>> include/hw/acpi/generic_event_device.h | 5 +++++
>> include/hw/acpi/pcihp.h | 2 ++
>> hw/acpi/generic_event_device.c | 14 ++++++++++++++
>> 3 files changed, 21 insertions(+)
>>
>> diff --git a/include/hw/acpi/generic_event_device.h
>> b/include/hw/acpi/generic_event_device.h
>> index d2dac87b4a..28be6c0582 100644
>> --- a/include/hw/acpi/generic_event_device.h
>> +++ b/include/hw/acpi/generic_event_device.h
>> @@ -63,6 +63,7 @@
>> #include "hw/acpi/memory_hotplug.h"
>> #include "hw/acpi/ghes.h"
>> #include "hw/acpi/cpu.h"
>> +#include "hw/acpi/pcihp.h"
>> #include "qom/object.h"
>> #define ACPI_POWER_BUTTON_DEVICE "PWRB"
>> @@ -101,6 +102,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(AcpiGedState, ACPI_GED)
>> #define ACPI_GED_PWR_DOWN_EVT 0x2
>> #define ACPI_GED_NVDIMM_HOTPLUG_EVT 0x4
>> #define ACPI_GED_CPU_HOTPLUG_EVT 0x8
>> +#define ACPI_GED_PCI_HOTPLUG_EVT 0x10
>> typedef struct GEDState {
>> MemoryRegion evt;
>> @@ -114,6 +116,9 @@ struct AcpiGedState {
>> MemoryRegion container_memhp;
>> CPUHotplugState cpuhp_state;
>> MemoryRegion container_cpuhp;
>> + AcpiPciHpState pcihp_state;
>> + MemoryRegion container_pcihp;
>> +
>> GEDState ged_state;
>> uint32_t ged_event_bitmap;
>> qemu_irq irq;
>> diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
>> index 451ef74284..abb6e14549 100644
>> --- a/include/hw/acpi/pcihp.h
>> +++ b/include/hw/acpi/pcihp.h
>> @@ -38,6 +38,8 @@
>> #define ACPI_PCIHP_SEJ_BASE 0x8
>> #define ACPI_PCIHP_BNMR_BASE 0x10
>> +#define ACPI_PCI_HOTPLUG_REG_LEN 0x14
>
> This is wrong, no? It should be 0x18, i.e. 24 bytes or 6 registers of
> 4 bytes.
yes this is wrong. you are totally right. I am about to send a new
version where this is fixed, sorry. I noticed that when testing the acpi
index modality which did not work with the RFC series.
Now I am using ACPI_PCIHP_SIZE.
Cheers
Eric
>
> I think it's better to move the defines in pcihp.c into pcihp.h and
> use them to define ACPI_PCI_HOTPLUG_REG_LEN so the values are
> consistent, like:
>
> diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
> index 82b8ea2811..3ab8b9de94 100644
> --- a/hw/acpi/pcihp.c
> +++ b/hw/acpi/pcihp.c
> @@ -44,14 +44,6 @@
> #include "qobject/qnum.h"
> #include "trace.h"
>
> -#define ACPI_PCIHP_SIZE 0x0018
> -#define PCI_UP_BASE 0x0000
> -#define PCI_DOWN_BASE 0x0004
> -#define PCI_EJ_BASE 0x0008
> -#define PCI_RMV_BASE 0x000c
> -#define PCI_SEL_BASE 0x0010
> -#define PCI_AIDX_BASE 0x0014
> -
> typedef struct AcpiPciHpFind {
> int bsel;
> PCIBus *bus;
> diff --git a/include/hw/acpi/pcihp.h b/include/hw/acpi/pcihp.h
> index abb6e14549..6b79adcaef 100644
> --- a/include/hw/acpi/pcihp.h
> +++ b/include/hw/acpi/pcihp.h
> @@ -38,7 +38,15 @@
> #define ACPI_PCIHP_SEJ_BASE 0x8
> #define ACPI_PCIHP_BNMR_BASE 0x10
>
> -#define ACPI_PCI_HOTPLUG_REG_LEN 0x14
> +#define ACPI_PCIHP_SIZE 0x0018
> +#define PCI_UP_BASE 0x0000
> +#define PCI_DOWN_BASE 0x0004
> +#define PCI_EJ_BASE 0x0008
> +#define PCI_RMV_BASE 0x000c
> +#define PCI_SEL_BASE 0x0010
> +#define PCI_AIDX_BASE 0x0014
> +
> +#define ACPI_PCI_HOTPLUG_REG_LEN ACPI_PCIHP_SIZE
>
> typedef struct AcpiPciHpPciStatus {
> uint32_t up;
>
>
> or even use only one of them (ACPI_PCI_HOTPLUG_REG_LEN,
> ACPI_PCIHP_SIZE, or
> another new name that would fit better in both contexts).
>
>
> Cheers,
> Gustavo
>
>> +
>> typedef struct AcpiPciHpPciStatus {
>> uint32_t up;
>> uint32_t down;
>> diff --git a/hw/acpi/generic_event_device.c
>> b/hw/acpi/generic_event_device.c
>> index 7b2d582fff..0fd8baba97 100644
>> --- a/hw/acpi/generic_event_device.c
>> +++ b/hw/acpi/generic_event_device.c
>> @@ -26,6 +26,7 @@ static const uint32_t ged_supported_events[] = {
>> ACPI_GED_PWR_DOWN_EVT,
>> ACPI_GED_NVDIMM_HOTPLUG_EVT,
>> ACPI_GED_CPU_HOTPLUG_EVT,
>> + ACPI_GED_PCI_HOTPLUG_EVT,
>> };
>> /*
>> @@ -121,6 +122,12 @@ void build_ged_aml(Aml *table, const char *name,
>> HotplugHandler *hotplug_dev,
>> aml_notify(aml_name("\\_SB.NVDR"),
>> aml_int(0x80)));
>> break;
>> + case ACPI_GED_PCI_HOTPLUG_EVT:
>> + aml_append(if_ctx,
>> + aml_acquire(aml_name("\\_SB.PCI0.BLCK"),
>> 0xFFFF));
>> + aml_append(if_ctx, aml_call0("\\_SB.PCI0.PCNT"));
>> + aml_append(if_ctx,
>> aml_release(aml_name("\\_SB.PCI0.BLCK")));
>> + break;
>> default:
>> /*
>> * Please make sure all the events in
>> ged_supported_events[]
>> @@ -299,6 +306,8 @@ static void acpi_ged_send_event(AcpiDeviceIf
>> *adev, AcpiEventStatusBits ev)
>> sel = ACPI_GED_NVDIMM_HOTPLUG_EVT;
>> } else if (ev & ACPI_CPU_HOTPLUG_STATUS) {
>> sel = ACPI_GED_CPU_HOTPLUG_EVT;
>> + } else if (ev & ACPI_PCI_HOTPLUG_STATUS) {
>> + sel = ACPI_GED_PCI_HOTPLUG_EVT;
>> } else {
>> /* Unknown event. Return without generating interrupt. */
>> warn_report("GED: Unsupported event %d. No irq injected", ev);
>> @@ -428,6 +437,11 @@ static void acpi_ged_realize(DeviceState *dev,
>> Error **errp)
>> cpu_hotplug_hw_init(&s->container_cpuhp, OBJECT(dev),
>> &s->cpuhp_state, 0);
>> break;
>> + case ACPI_GED_PCI_HOTPLUG_EVT:
>> + memory_region_init(&s->container_pcihp, OBJECT(dev),
>> + "pcihp container",
>> + ACPI_PCI_HOTPLUG_REG_LEN);
>> + sysbus_init_mmio(sbd, &s->container_pcihp);
>> }
>> ged_events--;
>> }
>
^ permalink raw reply [flat|nested] 46+ messages in thread
* Re: [RFC 00/24] APCI PCI Hotplug support on ARM
2025-05-14 16:27 ` Gustavo Romero
@ 2025-05-14 16:51 ` Eric Auger
0 siblings, 0 replies; 46+ messages in thread
From: Eric Auger @ 2025-05-14 16:51 UTC (permalink / raw)
To: Gustavo Romero, eric.auger.pro, qemu-devel, qemu-arm,
peter.maydell, imammedo, anisinha, mst, shannon.zhaosl
Cc: pbonzini, Jonathan.Cameron, Alex Bennée
Hi Gustavo,
On 5/14/25 6:27 PM, Gustavo Romero wrote:
> Hi Eric,
>
> On 5/7/25 22:13, Gustavo Romero wrote:
>> Hi Eric,
>>
>> On 5/6/25 21:51, Gustavo Romero wrote:
>>> Hi Eric,
>>>
>>> On 5/6/25 12:58, Eric Auger wrote:
>>>> Hi Gustavo,
>>>>
>>>> On 5/5/25 3:26 PM, Gustavo Romero wrote:
>>>>> Hi Eric,
>>>>>
>>>>> On 4/28/25 07:25, Eric Auger wrote:
>>>>>> This series enables APCI PCI hotplug/hotunplug on ARM
>>>>>> and makes it default for 10.1 machine type. This aligns with
>>>>>> x86 q35 machine. Expected benefits should be similar to
>>>>>> those listed in [1].
>>>>>>
>>>>>> The infrastructure used in x86 is heavily reused and a
>>>>>> huge part of the series consists in moving code from
>>>>>> hw/i386/acpi-build.c to a generic place and slightly
>>>>>> adapting it to make it usable on ARM. The DSDT table is
>>>>>> augmented to support ACPI PCI hotplug elements.
>>>>>>
>>>>>> On ARM we use use a GED event to notify the OS about
>>>>>> hotplug events.
>>>>>>
>>>>>> I have not noticed any tests/qtest/bios-tables-test failures
>>>>>> neither on x86 nor ARM. x86 DSDT table has not changed.
>>>>>> ARM DSDT table definitively has but there are no tests
>>>>>> impacted. ARM misses hotplug tests that do exist on x86. This
>>>>>> most probably should be considered in the future.
>>>>>>
>>>>>> Best Regards
>>>>>>
>>>>>> Eric
>>>>>>
>>>>>> This series can be found at:
>>>>>> https://github.com/eauger/qemu/tree/arm-acpi-pcihp-rfc
>>>>>>
>>>>>> [1] [PATCH v6 0/6] Use ACPI PCI hot-plug for Q35
>>>>>> https://lore.kernel.org/all/20210713004205.775386-1-jusual@redhat.com/
>>>>>>
>>>>>
>>>>> I've just started to review your series and went to a quick smoke
>>>>> test
>>>>> by hotplugging a net adapter and got the following kernel internal
>>>>> error:
>>>>>
>>>>> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
>>>>> (qemu) [ 64.165411] pci 0000:01:00.0: [1af4:1041] type 00 class
>>>>> 0x020000
>>>>> [ 64.165895] pci 0000:01:00.0: reg 0x14: [mem
>>>>> 0x00000000-0x00000fff]
>>>>> [ 64.166259] pci 0000:01:00.0: reg 0x20: [mem 0x00000000-0x00003fff
>>>>> 64bit pref]
>>>>> [ 64.166658] pci 0000:01:00.0: reg 0x30: [mem 0x00000000-0x0003ffff
>>>>> pref]
>>>>> [ 64.167153] pci 0000:01:00.0: enabling Extended Tags
>>>>> [ 64.179972] Internal error: synchronous external abort:
>>>>> 0000000096000050 [#1] SMP
>>>>> [ 64.180719] Modules linked in: aes_ce_blk aes_ce_cipher polyval_ce
>>>>> polyval_generic ghash_ce gf128mul sha2_ce binfmt_misc sha256_arm64
>>>>> sha1_ce nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse
>>>>> efi_pstore drm dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables
>>>>> x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_scsi
>>>>> virtio_net scsi_mod net_failover failover virtio_blk scsi_common
>>>>> crct10dif_ce crct10dif_common virtio_pci virtio_pci_legacy_dev
>>>>> virtio_pci_modern_dev virtio_mmio
>>>>> [ 64.183656] CPU: 0 PID: 23 Comm: kworker/u2:1 Not tainted
>>>>> 6.1.0-30-arm64 #1 Debian 6.1.124-1
>>>>> [ 64.184071] Hardware name: QEMU QEMU Virtual Machine, BIOS
>>>>> edk2-stable202408-prebuilt.qemu.org 08/13/2024
>>>>> [ 64.184759] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
>>>>> [ 64.185320] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS
>>>>> BTYPE=--)
>>>>> [ 64.185737] pc : acpi_ex_system_memory_space_handler+0x290/0x300
>>>>> [ 64.186175] lr : acpi_ev_address_space_dispatch+0x124/0x334
>>>>> [ 64.186490] sp : ffff80000a6bb3b0
>>>>> [ 64.186663] x29: ffff80000a6bb3b0 x28: ffff0003fcbb08b8 x27:
>>>>> 0000000000000000
>>>>> [ 64.187126] x26: ffff0003fcbb0288 x25: ffff80000a6bb568 x24:
>>>>> 0000000000000001
>>>>> [ 64.187499] x23: ffff80000a6bb568 x22: 0000000000000004 x21:
>>>>> ffff0000c206cb00
>>>>> [ 64.187885] x20: 00000000090c0014 x19: 0000000000000020 x18:
>>>>> 0000000000000000
>>>>> [ 64.188265] x17: 0000000000000000 x16: 0000000000000000 x15:
>>>>> 0000000000000000
>>>>> [ 64.188640] x14: 0000000000000000 x13: 4d43c3194dea1791 x12:
>>>>> 4d7a3553e5c937d0
>>>>> [ 64.189003] x11: 0000000000000001 x10: 0000000000000000 x9 :
>>>>> ffff800008735b34
>>>>> [ 64.189383] x8 : 0000000000000001 x7 : ffff80000873c850 x6 :
>>>>> 00000000000000f8
>>>>> [ 64.189778] x5 : ffff0000c206cb00 x4 : 0000000000000000 x3 :
>>>>> 00000000090c0018
>>>>> [ 64.190163] x2 : ffff80000a9af014 x1 : 00000000090c0018 x0 :
>>>>> 0000000000000001
>>>>> [ 64.190734] Call trace:
>>>>> [ 64.191086] acpi_ex_system_memory_space_handler+0x290/0x300
>>>>> [ 64.191696] acpi_ev_address_space_dispatch+0x124/0x334
>>>>> [ 64.192042] acpi_ex_access_region+0xe4/0x2e0
>>>>> [ 64.192287] acpi_ex_field_datum_io+0x88/0x200
>>>>> [ 64.192509] acpi_ex_write_with_update_rule+0xd4/0x120
>>>>> [ 64.192793] acpi_ex_insert_into_field+0x210/0x2b0
>>>>> [ 64.193048] acpi_ex_write_data_to_field+0xa0/0x190
>>>>> [ 64.193298] acpi_ex_store_object_to_node+0x150/0x240
>>>>> [ 64.193527] acpi_ex_store+0x144/0x300
>>>>> [ 64.193726] acpi_ex_opcode_1A_1T_1R+0x218/0x580
>>>>> [ 64.193971] acpi_ds_exec_end_op+0x24c/0x4b0
>>>>> [ 64.194227] acpi_ps_parse_loop+0x100/0x6a0
>>>>> [ 64.194477] acpi_ps_parse_aml+0x94/0x3b0
>>>>> [ 64.194674] acpi_ps_execute_method+0x128/0x25c
>>>>> [ 64.194922] acpi_ns_evaluate+0x1f0/0x2d0
>>>>> [ 64.195148] acpi_evaluate_object+0x138/0x2d0
>>>>> [ 64.195380] acpi_evaluate_dsm+0xb8/0x134
>>>>> [ 64.195613] acpi_check_dsm+0x34/0xdc
>>>>> [ 64.195822] smbios_attr_is_visible+0x5c/0xb0
>>>>> [ 64.196089] internal_create_group+0xd0/0x3d0
>>>>> [ 64.196335] internal_create_groups+0x58/0xe0
>>>>> [ 64.196584] sysfs_create_groups+0x20/0x30
>>>>> [ 64.196813] device_add_groups+0x18/0x2c
>>>>> [ 64.197039] bus_add_device+0x48/0x160
>>>>> [ 64.197260] device_add+0x3a4/0x85c
>>>>> [ 64.197463] pci_device_add+0x308/0x660
>>>>> [ 64.197680] pci_scan_single_device+0xe4/0x114
>>>>> [ 64.197941] pci_scan_slot+0x70/0x1fc
>>>>> [ 64.198155] acpiphp_rescan_slot+0x90/0xa4
>>>>> [ 64.198366] acpiphp_hotplug_notify+0x2a8/0x300
>>>>> [ 64.198584] acpi_device_hotplug+0x138/0x4c0
>>>>> [ 64.198819] acpi_hotplug_work_fn+0x2c/0x4c
>>>>> [ 64.199045] process_one_work+0x1f4/0x460
>>>>> [ 64.199277] worker_thread+0x188/0x4e0
>>>>> [ 64.199492] kthread+0xe0/0xe4
>>>>> [ 64.199671] ret_from_fork+0x10/0x20
>>>>> [ 64.200114] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
>>>>> [ 64.200820] ---[ end trace 0000000000000000 ]---
>>>>>
>>>>> (qemu)
>>>>>
>>>>> This is a Debian Bookworm stock kernel 6.1. I built QEMU from your GH
>>>>> branch.
>>>>>
>>>>> The machine was started with:
>>>>>
>>>>> ./qemu-system-aarch64 -m 16G -nographic -machine
>>>>> type=virt,gic-version=max -cpu cortex-a57 -initrd
>>>>> /mnt/initrd.img-6.1.0-30-arm64 -kernel /mnt/vmlinuz-6.1.0-30-arm64
>>>>> -append "root=/dev/vda1 console=ttyAMA0,115200 acpi=force" -device
>>>>> virtio-scsi-pci -device virtio-blk-pci,drive=root -drive
>>>>> if=none,id=root,file=/mnt/debian-12-nocloud-arm64.qcow2 -device
>>>>> pcie-root-port,id=pcie.1,chassis=1,slot=1 -bios
>>>>> ./pc-bios/edk2-aarch64-code.fd
>>>>>
>>>>> ./pc-bios/edk2-aarch64-code.fd is the one found under ./build dir, so
>>>>> nothing special.
>>>>
>>>> I have just tested debian-12-nocloud-arm64.qcow2 which features
>>>> 6.1.0-34-arm64 + edk2-aarch64-code.fd and I am able to
>>>> hotplug/hot-unplug the virtio-net-pci device. Can you retry without
>>>>
>>>> -initrd /mnt/initrd.img-6.1.0-30-arm64 -kernel
>>>> /mnt/vmlinuz-6.1.0-30-arm64 -append "root=/dev/vda1
>>>> console=ttyAMA0,115200 acpi=force" ?
>>>
>>> Sure, so I got the same internal error without passing the kernel,
>>> the initrd,
>>> and the append command.
>>>
>>>
>>> I also tried with a pristine Debian .qcow2 taken from:
>>>
>>> https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-nocloud-arm64.qcow2
>>>
>>>
>>> I'm building your Github branch:
>>>
>>> gromero@gromero0:/mnt/git/qemu_/build$ git branch -vv | grep eauger
>>> * arm-acpi-pcihp-rfc cf92b293ff [eauger/arm-acpi-pcihp-rfc]
>>> hw/arm/virt: Use ACPI PCI hotplug by default
>>> gromero@gromero0:/mnt/git/qemu_/build$ git log --oneline -1
>>> cf92b293ff (HEAD -> arm-acpi-pcihp-rfc, eauger/arm-acpi-pcihp-rfc)
>>> hw/arm/virt: Use ACPI PCI hotplug by default
>>>
>>> I tried in a pristine ./build dir.
>>>
>>> QEMU options:
>>>
>>> gromero@gromero0:/mnt/git/qemu_/build$ ./qemu-system-aarch64 -m 16G
>>> -nographic -machine type=virt,gic-version=max -cpu max -drive
>>> if=none,file=/mnt/debian/debian-12-nocloud-arm64.qcow2,format=qcow2,id=hd
>>> -device virtio-blk-device,drive=hd -device
>>> pcie-root-port,bus=pcie.0,chassis=1,id=pcie.1,addr=0x2.0x0 -bios
>>> ./pc-bios/edk2-aarch64-code.fd
>>> UEFI firmware (version edk2-stable202408-prebuilt.qemu.org built at
>>> 16:28:50 on Sep 12 2024)
>>>
>>> gromero@gromero0:/mnt/git/qemu_/build$ md5sum
>>> ./pc-bios/edk2-aarch64-code.fd
>>> 3426cd25efb1593f86352ec0c61d66f5 ./pc-bios/edk2-aarch64-code.fd
>>>
>>> and I get the same error:
>>>
>>> root@localhost:~# QEMU 10.0.50 monitor - type 'help' for more
>>> information
>>> (qemu) device_add virtio-net-pci,bus=pcie.1,addr=0,id=na
>>> (qemu) [ 56.865284] pci 0000:01:00.0: [1af4:1041] type 00 class
>>> 0x020000
>>> [ 56.866620] pci 0000:01:00.0: reg 0x14: [mem 0x00000000-0x00000fff]
>>> [ 56.867711] pci 0000:01:00.0: reg 0x20: [mem
>>> 0x00000000-0x00003fff 64bit pref]
>>> [ 56.868287] pci 0000:01:00.0: reg 0x30: [mem
>>> 0x00000000-0x0003ffff pref]
>>> [ 56.869143] pci 0000:01:00.0: enabling Extended Tags
>>> [ 56.900481] Internal error: synchronous external abort:
>>> 0000000096000050 [#1] SMP
>>> [ 56.900911] Modules linked in: aes_ce_blk binfmt_misc
>>> aes_ce_cipher polyval_ce polyval_generic ghash_ce gf128mul sha3_ce
>>> sha3_generic sha512_ce sha512_arm64 sha2_ce sha256_arm64 sha1_ce
>>> nls_ascii nls_cp437 vfat fat evdev cfg80211 rfkill loop fuse drm
>>> efi_pstore dm_mod dax configfs efivarfs qemu_fw_cfg ip_tables
>>> x_tables autofs4 ext4 crc16 mbcache jbd2 crc32c_generic virtio_net
>>> net_failover failover virtio_blk crct10dif_ce crct10dif_common
>>> virtio_pci virtio_pci_legacy_dev virtio_pci_modern_dev virtio_mmio
>>> [ 56.903132] CPU: 0 PID: 10 Comm: kworker/u2:0 Not tainted
>>> 6.1.0-34-arm64 #1 Debian 6.1.135-1
>>> [ 56.903753] Hardware name: QEMU QEMU Virtual Machine, BIOS
>>> edk2-stable202408-prebuilt.qemu.org 08/13/2024
>>> [ 56.904126] Workqueue: kacpi_hotplug acpi_hotplug_work_fn
>>> [ 56.904877] pstate: 60402005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS
>>> BTYPE=--)
>>> [ 56.905085] pc : acpi_ex_system_memory_space_handler+0x290/0x300
>>> [ 56.905306] lr : acpi_ev_address_space_dispatch+0x124/0x334
>>> [ 56.905471] sp : ffff80000809b3b0
>>> [ 56.905580] x29: ffff80000809b3b0 x28: ffff0003fcb852d0 x27:
>>> 0000000000000000
>>> [ 56.905856] x26: ffff0003fcb85558 x25: ffff80000809b568 x24:
>>> 0000000000000001
>>> [ 56.906092] x23: ffff80000809b568 x22: 0000000000000004 x21:
>>> ffff0000c1644980
>>> [ 56.906333] x20: 00000000090c0014 x19: 0000000000000020 x18:
>>> 0000000000000000
>>> [ 56.906557] x17: 0000000000000000 x16: 0000000000000000 x15:
>>> 0000000000000000
>>> [ 56.906793] x14: 0000000000000000 x13: ffffb8324c78ebb0 x12:
>>> 0000000000000001
>>> [ 56.907016] x11: 000000000000002e x10: ffffb8324cab6e20 x9 :
>>> ffffb8324b2076b4
>>> [ 56.907236] x8 : 0000000000000001 x7 : ffffb8324b20e3d0 x6 :
>>> 00000000000000f8
>>> [ 56.907473] x5 : ffff0000c1644980 x4 : 0000000000000000 x3 :
>>> 00000000090c0018
>>> [ 56.907705] x2 : ffff800008837014 x1 : 00000000090c0018 x0 :
>>> 0000000000000001
>>> [ 56.908026] Call trace:
>>> [ 56.908226] acpi_ex_system_memory_space_handler+0x290/0x300
>>> [ 56.908540] acpi_ev_address_space_dispatch+0x124/0x334
>>> [ 56.908736] acpi_ex_access_region+0xe4/0x2e0
>>> [ 56.908870] acpi_ex_field_datum_io+0x88/0x200
>>> [ 56.909003] acpi_ex_write_with_update_rule+0xd4/0x120
>>> [ 56.909152] acpi_ex_insert_into_field+0x210/0x2b0
>>> [ 56.909285] acpi_ex_write_data_to_field+0xa0/0x190
>>> [ 56.909426] acpi_ex_store_object_to_node+0x150/0x240
>>> [ 56.909569] acpi_ex_store+0x144/0x300
>>> [ 56.909688] acpi_ex_opcode_1A_1T_1R+0x218/0x580
>>> [ 56.909824] acpi_ds_exec_end_op+0x24c/0x4b0
>>> [ 56.909953] acpi_ps_parse_loop+0x100/0x6a0
>>> [ 56.910074] acpi_ps_parse_aml+0x94/0x3b0
>>> [ 56.910197] acpi_ps_execute_method+0x128/0x25c
>>> [ 56.910331] acpi_ns_evaluate+0x1f0/0x2d0
>>> [ 56.910445] acpi_evaluate_object+0x138/0x2d0
>>> [ 56.910573] acpi_evaluate_dsm+0xb8/0x134
>>> [ 56.910696] acpi_check_dsm+0x34/0xdc
>>> [ 56.910809] smbios_attr_is_visible+0x5c/0xb0
>>> [ 56.910937] internal_create_group+0xd0/0x3d0
>>> [ 56.911066] internal_create_groups+0x58/0xe0
>>> [ 56.911194] sysfs_create_groups+0x20/0x30
>>> [ 56.911315] device_add_groups+0x18/0x2c
>>> [ 56.911435] bus_add_device+0x48/0x160
>>> [ 56.911552] device_add+0x3a4/0x85c
>>> [ 56.911678] pci_device_add+0x308/0x660
>>> [ 56.911803] pci_scan_single_device+0xe4/0x114
>>> [ 56.911937] pci_scan_slot+0x70/0x1fc
>>> [ 56.912039] acpiphp_rescan_slot+0x90/0xa4
>>> [ 56.912161] acpiphp_hotplug_notify+0x2a8/0x300
>>> [ 56.912290] acpi_device_hotplug+0x138/0x4c0
>>> [ 56.912428] acpi_hotplug_work_fn+0x2c/0x4c
>>> [ 56.912549] process_one_work+0x1f4/0x460
>>> [ 56.912679] worker_thread+0x188/0x4e0
>>> [ 56.912792] kthread+0xe0/0xe4
>>> [ 56.912892] ret_from_fork+0x10/0x20
>>> [ 56.913136] Code: f90002e0 52800000 17ffff97 f94002e0 (b9000040)
>>> [ 56.913532] ---[ end trace 0000000000000000 ]---
>>>
>>>
>>> I'm wondering if we are using the same
>>> ./pc-bios/edk2-aarch64-code.fd, although
>>> I can't see how it would cause such error.
>>
>> hmm actually I'm able to properly hotplug the network device using
>> the exactly
>> same sw stack as above (your branch, Debian 12, edk2) but running on
>> an arm64 host.
>>
>> It seems your running on a arm64 host since you're passing
>> --enable-kvm. Do you
>> mind trying it on a x86_64 or without --enable-kvm on the arm64 host?
>> I'm able to
>> reproduce it on arm64 host without --enable-kvm but not with
>> --enable-kvm passed to QEMU.
>
> What causes this behaviour is that the container size is < than the
> register region
> in the pcihp device:
>
> [...]
> 00000000090c0000-00000000090c0013 (prio 0, i/o): pcihp container
> 00000000090c0000-00000000090c0017 (prio 0, i/o): acpi-pci-hotplug
> [...]
>
> Because ACPI_PCI_HOTPLUG_REG_LEN and ACPI_PCIHP_SIZE values don't
> match. Please see my
> comment in patch 18/24 for a possible fix for it.
thank you very much for the investigation. This should be fixed in the
next version I am about the send ...
Eric
>
>
> Cheers,
> Gustavo
>
^ permalink raw reply [flat|nested] 46+ messages in thread
end of thread, other threads:[~2025-05-14 16:51 UTC | newest]
Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-28 10:25 [RFC 00/24] APCI PCI Hotplug support on ARM Eric Auger
2025-04-28 10:25 ` [RFC 01/24] hw/pci/pcie_port: Fix pcie_slot_is_hotpluggbale_bus typo Eric Auger
2025-05-06 0:11 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 02/24] hw/acpi/ged: Fix wrong identation Eric Auger
2025-05-06 0:11 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 03/24] hw/i386/acpi-build: Fix build_append_notfication_callback typo Eric Auger
2025-05-06 0:11 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 04/24] hw/i386/acpi-build: Make aml_pci_device_dsm() static Eric Auger
2025-04-28 10:25 ` [RFC 05/24] hw/arm/virt: Introduce machine state acpi pcihp flags and props Eric Auger
2025-05-06 0:12 ` Gustavo Romero
2025-05-06 8:42 ` Eric Auger
2025-04-28 10:25 ` [RFC 06/24] hw/acpi: Rename and move build_x86_acpi_pci_hotplug to pcihp Eric Auger
2025-05-06 0:12 ` Gustavo Romero
2025-05-06 8:42 ` Eric Auger
2025-04-28 10:25 ` [RFC 07/24] hw/pci-host/gpex-acpi: Add native_pci_hotplug arg to acpi_dsdt_add_pci_osc Eric Auger
2025-05-06 0:13 ` Gustavo Romero
2025-05-06 8:42 ` Eric Auger
2025-04-28 10:25 ` [RFC 08/24] hw/pci-host/gpex-acpi: Split host bridge OSC and DSM generation Eric Auger
2025-05-06 0:13 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 09/24] hw/pci-host/gpex-acpi: Propagate hotplug type info from virt machine downto gpex Eric Auger
2025-05-06 0:13 ` Gustavo Romero
2025-04-28 10:25 ` [RFC 10/24] hw/i386/acpi-build: Turn build_q35_osc_method into a generic method Eric Auger
2025-04-28 10:25 ` [RFC 11/24] hw/pci-host/gpex-acpi: Use build_pci_host_bridge_osc_method Eric Auger
2025-04-28 10:25 ` [RFC 12/24] hw/i386/acpi-build: Introduce build_append_pcihp_resources() helper Eric Auger
2025-04-28 10:25 ` [RFC 13/24] hw/acpi/pcihp: Add an AmlRegionSpace arg to build_acpi_pci_hotplug Eric Auger
2025-04-28 10:25 ` [RFC 14/24] hw/i386/acpi-build: Move build_append_notification_callback to pcihp Eric Auger
2025-04-28 10:25 ` [RFC 15/24] hw/i386/acpi-build: Move remaining pcihp generic functions " Eric Auger
2025-04-28 10:25 ` [RFC 16/24] hw/i386/acpi-build: Introduce and use acpi_get_pci_host Eric Auger
2025-04-28 10:25 ` [RFC 17/24] hw/arm/virt-acpi-build: Add DSDT additions for PCI hotplug Eric Auger
2025-04-28 10:25 ` [RFC 18/24] hw/acpi/ged: Prepare the device to react to PCI hotplug events Eric Auger
2025-05-14 16:20 ` Gustavo Romero
2025-05-14 16:46 ` Eric Auger
2025-04-28 10:25 ` [RFC 19/24] hw/acpi/ged: Call pcihp plug callbacks in hotplug handler implementation Eric Auger
2025-04-28 10:25 ` [RFC 20/24] hw/acpi/ged: Support migration of AcpiPciHpState Eric Auger
2025-04-28 10:25 ` [RFC 21/24] hw/core/sysbus: Introduce sysbus_mmio_map_name() helper Eric Auger
2025-04-28 10:25 ` [RFC 22/24] hw/arm/virt: Let virt support pci hotplug/unplug GED event Eric Auger
2025-04-28 10:25 ` [RFC 23/24] hw/arm/virt: Plug pcihp hotplug/hotunplug callbacks Eric Auger
2025-04-28 10:25 ` [RFC 24/24] hw/arm/virt: Use ACPI PCI hotplug by default Eric Auger
2025-05-05 13:26 ` [RFC 00/24] APCI PCI Hotplug support on ARM Gustavo Romero
2025-05-05 14:23 ` Eric Auger
2025-05-06 15:58 ` Eric Auger
2025-05-06 16:08 ` Eric Auger
2025-05-07 0:51 ` Gustavo Romero
2025-05-07 1:13 ` Gustavo Romero
2025-05-14 16:27 ` Gustavo Romero
2025-05-14 16:51 ` Eric Auger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).