From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>, Ani Sinha <ani@anisinha.ca>
Subject: [PATCH 11/40] pci: acpihp: assign BSEL only to coldplugged bridges
Date: Thu, 12 Jan 2023 15:02:43 +0100 [thread overview]
Message-ID: <20230112140312.3096331-12-imammedo@redhat.com> (raw)
In-Reply-To: <20230112140312.3096331-1-imammedo@redhat.com>
ACPI PCI hotplug would broken after bridge hotplug and then migration
if hotplugged bridge were specified on target at command line.
Currently it's not possible since, 'hotplugged' property was made
read-only for some time now.
The issue would happen due to BSEL being assigned to all bridges
during 1st 'reset':
source seq:
1. start 'pc' machine => sets BSEL to 0 on pci.0 (host-bridge)
2. hotplug bridge, no bsel is assigned (so far is ok)
target seq:
1. start 'pc' machine with
-S -device pci-bridge,id=hp_br,hotplugged=on
BSEL gets assigned to as follows
hp_br: 0
pci.0: 1
as result hotplug requests with migrated AML generated on source
would be misdirected to 'hp_br' instead of intended pci.0
While it's not issue at the moment, it's based on implicit assumptions
* 'hotplugged' property is read-only
* 1st reset happens before QEMU drops into monitor mode
which lets add hotplugged on source bridges as hotplugged ones
(anything added at that stage counts as hotplugged
(yet another assumption))
All of it looks too fragile to me, so lets restrict BSEL only
to cold-plugged bridges explicitly.
Migration wise it shouldn't break anything since assignment order
stays the same:
* user can't specify 'hotplugged=on' on CLI
* user can't specify 'hotplugged=off' at monitor stage or later
on older QEMU versions where 'hotplugged' is RW, hotplug is broken
after migration anyways and we cannot do anything to fix that.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
hw/acpi/pcihp.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 99a898d9ae..5dc7377411 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -85,31 +85,40 @@ static int acpi_pcihp_get_bsel(PCIBus *bus)
}
}
-/* Assign BSEL property to all buses. In the future, this can be changed
- * to only assign to buses that support hotplug.
- */
+typedef struct {
+ unsigned bsel_alloc;
+ bool has_bridge_hotplug;
+} BSELInfo;
+
+/* Assign BSEL property only to buses that support hotplug. */
static void *acpi_set_bsel(PCIBus *bus, void *opaque)
{
- unsigned *bsel_alloc = opaque;
+ BSELInfo *info = opaque;
unsigned *bus_bsel;
+ DeviceState *br = bus->qbus.parent;
+ bool is_bridge = IS_PCI_BRIDGE(br);
+ /* hotplugged bridges can't be described in ACPI ignore them */
if (qbus_is_hotpluggable(BUS(bus))) {
- bus_bsel = g_malloc(sizeof *bus_bsel);
+ if (!is_bridge || (!br->hotplugged && info->has_bridge_hotplug)) {
+ bus_bsel = g_malloc(sizeof *bus_bsel);
- *bus_bsel = (*bsel_alloc)++;
- object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
- bus_bsel, OBJ_PROP_FLAG_READ);
+ *bus_bsel = info->bsel_alloc++;
+ object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL,
+ bus_bsel, OBJ_PROP_FLAG_READ);
+ }
}
- return bsel_alloc;
+ return info;
}
-static void acpi_set_pci_info(void)
+static void acpi_set_pci_info(bool has_bridge_hotplug)
{
static bool bsel_is_set;
Object *host = acpi_get_i386_pci_host();
PCIBus *bus;
- unsigned bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT;
+ BSELInfo info = { .bsel_alloc = ACPI_PCIHP_BSEL_DEFAULT,
+ .has_bridge_hotplug = has_bridge_hotplug };
if (bsel_is_set) {
return;
@@ -123,7 +132,7 @@ static void acpi_set_pci_info(void)
bus = PCI_HOST_BRIDGE(host)->bus;
if (bus) {
/* Scan all PCI buses. Set property to enable acpi based hotplug. */
- pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc);
+ pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &info);
}
}
@@ -287,7 +296,7 @@ void acpi_pcihp_reset(AcpiPciHpState *s, bool acpihp_root_off)
if (acpihp_root_off) {
acpi_pcihp_disable_root_bus();
}
- acpi_set_pci_info();
+ acpi_set_pci_info(!s->legacy_piix);
acpi_pcihp_update(s);
}
--
2.31.1
next prev parent reply other threads:[~2023-01-12 14:35 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-12 14:02 [PATCH 00/40] x86: fixing and cleaning up ACPI PCI code part 3 Igor Mammedov
2023-01-12 14:02 ` [PATCH 01/40] tests: qtest: print device_add error before failing test Igor Mammedov
2023-01-12 14:02 ` [PATCH 02/40] tests: acpi: cleanup arguments to make them more readable Igor Mammedov
2023-01-12 14:02 ` [PATCH 03/40] tests: acpi: whitelist DSDT blobs for tests that use pci-bridges Igor Mammedov
2023-01-12 14:02 ` [PATCH 04/40] tests: acpi: extend pcihp with nested bridges Igor Mammedov
2023-01-12 14:02 ` [PATCH 05/40] tests: acpi: update expected blobs Igor Mammedov
2023-01-12 14:02 ` [PATCH 06/40] tests: acpi: cleanup use_uefi argument usage Igor Mammedov
2023-01-12 14:02 ` [PATCH 07/40] pci_bridge: remove whitespace Igor Mammedov
2023-01-12 14:02 ` [PATCH 08/40] x86: acpi: pcihp: clean up duplicate bridge_in_acpi assignment Igor Mammedov
2023-01-12 14:02 ` [PATCH 09/40] pci: acpi hotplug: rename x-native-hotplug to x-do-not-expose-native-hotplug-cap Igor Mammedov
2023-01-12 14:02 ` [PATCH 10/40] pcihp: piix4: do not call acpi_pcihp_reset() when ACPI PCI hotplug is disabled Igor Mammedov
2023-01-12 14:02 ` Igor Mammedov [this message]
2023-01-12 14:02 ` [PATCH 12/40] x86: pcihp: fix invalid AML PCNT calls to hotplugged bridges Igor Mammedov
2023-01-12 14:02 ` [PATCH 13/40] tests: boot_sector_test: avoid crashing if status is not available yet Igor Mammedov
2023-01-12 14:02 ` [PATCH 14/40] tests: acpi: extend bridge tests with hotplugged bridges Igor Mammedov
2023-01-12 14:02 ` [PATCH 15/40] tests: boot_sector_test(): make it multi-shot Igor Mammedov
2023-01-12 14:02 ` [PATCH 16/40] tests: acpi: add reboot cycle to bridge test Igor Mammedov
2023-01-12 14:02 ` [PATCH 17/40] tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug machinery Igor Mammedov
2023-01-12 14:02 ` [PATCH 18/40] pcihp: drop pcihp_bridge_en dependency when composing PCNT method Igor Mammedov
2023-01-12 14:02 ` [PATCH 19/40] tests: acpi: update expected blobs Igor Mammedov
2023-01-12 14:02 ` [PATCH 20/40] tests: acpi: whitelist DSDT before refactoring acpi based PCI hotplug machinery Igor Mammedov
2023-01-12 14:02 ` [PATCH 21/40] pcihp: compose PCNT callchain right before its user _GPE._E01 Igor Mammedov
2023-01-12 14:02 ` [PATCH 22/40] pcihp: do not put empty PCNT in DSDT Igor Mammedov
2023-01-12 14:02 ` [PATCH 23/40] tests: acpi: update expected blobs Igor Mammedov
2023-01-12 14:02 ` [PATCH 24/40] whitelist DSDT before adding endpoint devices to bridge testcases Igor Mammedov
2023-01-12 14:02 ` [PATCH 25/40] tests: acpi: add endpoint devices to bridges Igor Mammedov
2023-01-12 14:02 ` [PATCH 26/40] tests: acpi: update expected blobs Igor Mammedov
2023-01-12 14:02 ` [PATCH 27/40] x86: pcihp: acpi: prepare slot ignore rule to work with self describing bridges Igor Mammedov
2023-01-12 14:03 ` [PATCH 28/40] pci: acpi: wire up AcpiDevAmlIf interface to generic bridge Igor Mammedov
2023-01-12 14:03 ` [PATCH 29/40] pcihp: make bridge describe itself using AcpiDevAmlIfClass:build_dev_aml Igor Mammedov
2023-01-12 14:03 ` [PATCH 30/40] pci: make sure pci_bus_is_express() won't error out with "discards ‘const’ qualifier" Igor Mammedov
2023-01-12 14:03 ` [PATCH 31/40] pcihp: isolate rule whether slot should be described in DSDT Igor Mammedov
2023-01-12 14:03 ` [PATCH 32/40] tests: acpi: whitelist DSDT before decoupling PCI hotplug code from basic slots description Igor Mammedov
2023-01-12 14:03 ` [PATCH 33/40] pcihp: acpi: decouple hotplug and generic " Igor Mammedov
2023-01-12 14:03 ` [PATCH 34/40] tests: acpi: update expected blobs Igor Mammedov
2023-01-12 14:03 ` [PATCH 35/40] tests: acpi: whitelist DSDT blobs before removing dynamic _DSM on coldplugged bridges Igor Mammedov
2023-01-12 14:03 ` [PATCH 36/40] pcihp: acpi: ignore coldplugged bridges when composing hotpluggable slots Igor Mammedov
2023-01-12 14:03 ` [PATCH 37/40] tests: acpi: update expected blobs Igor Mammedov
2023-01-12 14:03 ` [PATCH 38/40] tests: acpi: whitelist DSDT before moving non-hotpluggble slots description from hotplug path Igor Mammedov
2023-01-12 14:03 ` [PATCH 39/40] pcihp: generate populated non-hotpluggble slot descriptions on non-hotplug path Igor Mammedov
2023-01-12 14:03 ` [PATCH 40/40] tests: acpi: update expected blobs Igor Mammedov
2023-01-25 17:02 ` [PATCH 00/40] x86: fixing and cleaning up ACPI PCI code part 3 Igor Mammedov
2023-01-25 17:34 ` Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230112140312.3096331-12-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=ani@anisinha.ca \
--cc=mst@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).