[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 12/12] hw/acpi: Make the PCI hot-plug aware of SR-IOV
From: |
Lukasz Maniak |
Subject: |
[PATCH v6 12/12] hw/acpi: Make the PCI hot-plug aware of SR-IOV |
Date: |
Fri, 18 Mar 2022 19:53:51 +0100 |
From: Łukasz Gieryk <lukasz.gieryk@linux.intel.com>
PCI device capable of SR-IOV support is a new, still-experimental
feature with only a single working example of the Nvme device.
This patch in an attempt to fix a double-free problem when a
SR-IOV-capable Nvme device is hot-unplugged. The problem and the
reproduction steps can be found in this thread:
https://patchew.org/QEMU/20220217174504.1051716-1-lukasz.maniak@linux.intel.com/20220217174504.1051716-14-lukasz.maniak@linux.intel.com/
Details of the proposed solution are, for convenience, included below.
1) The current SR-IOV implementation assumes it’s the PhysicalFunction
that creates and deletes VirtualFunctions.
2) It’s a design decision (the Nvme device at least) for the VFs to be
of the same class as PF. Effectively, they share the dc->hotpluggable
value.
3) When a VF is created, it’s added as a child node to PF’s PCI bus
slot.
4) Monitor/device_del triggers the ACPI mechanism. The implementation is
not aware of SR/IOV and ejects PF’s PCI slot, directly unrealizing all
hot-pluggable (!acpi_pcihp_pc_no_hotplug) children nodes.
5) VFs are unrealized directly, and it doesn’t work well with (1).
SR/IOV structures are not updated, so when it’s PF’s turn to be
unrealized, it works on stale pointers to already-deleted VFs.
Signed-off-by: Łukasz Gieryk <lukasz.gieryk@linux.intel.com>
---
hw/acpi/pcihp.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 6351bd3424d..248839e1110 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -192,8 +192,12 @@ static bool acpi_pcihp_pc_no_hotplug(AcpiPciHpState *s,
PCIDevice *dev)
* ACPI doesn't allow hotplug of bridge devices. Don't allow
* hot-unplug of bridge devices unless they were added by hotplug
* (and so, not described by acpi).
+ *
+ * Don't allow hot-unplug of SR-IOV Virtual Functions, as they
+ * will be removed implicitly, when Physical Function is unplugged.
*/
- return (pc->is_bridge && !dev->qdev.hotplugged) || !dc->hotpluggable;
+ return (pc->is_bridge && !dev->qdev.hotplugged) || !dc->hotpluggable ||
+ pci_is_vf(dev);
}
static void acpi_pcihp_eject_slot(AcpiPciHpState *s, unsigned bsel, unsigned
slots)
--
2.25.1
- [PATCH v6 03/12] hw/nvme: Add support for Secondary Controller List, (continued)
- [PATCH v6 03/12] hw/nvme: Add support for Secondary Controller List, Lukasz Maniak, 2022/03/18
- [PATCH v6 02/12] hw/nvme: Add support for Primary Controller Capabilities, Lukasz Maniak, 2022/03/18
- [PATCH v6 04/12] hw/nvme: Implement the Function Level Reset, Lukasz Maniak, 2022/03/18
- [PATCH v6 05/12] hw/nvme: Make max_ioqpairs and msix_qsize configurable in runtime, Lukasz Maniak, 2022/03/18
- [PATCH v6 06/12] hw/nvme: Remove reg_size variable and update BAR0 size calculation, Lukasz Maniak, 2022/03/18
- [PATCH v6 08/12] hw/nvme: Initialize capability structures for primary/secondary controllers, Lukasz Maniak, 2022/03/18
- [PATCH v6 09/12] hw/nvme: Add support for the Virtualization Management command, Lukasz Maniak, 2022/03/18
- [PATCH v6 10/12] docs: Add documentation for SR-IOV and Virtualization Enhancements, Lukasz Maniak, 2022/03/18
- [PATCH v6 07/12] hw/nvme: Calculate BAR attributes in a function, Lukasz Maniak, 2022/03/18
- [PATCH v6 11/12] hw/nvme: Update the initalization place for the AER queue, Lukasz Maniak, 2022/03/18
- [PATCH v6 12/12] hw/acpi: Make the PCI hot-plug aware of SR-IOV,
Lukasz Maniak <=