[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/29] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot
From: |
Michael S. Tsirkin |
Subject: |
[PULL 01/29] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot |
Date: |
Mon, 4 May 2020 10:29:14 -0400 |
From: Julia Suvorova <address@hidden>
Raise an error when trying to hot-plug/unplug a device through QMP to a device
with disabled hot-plug capability. This makes the device behaviour more
consistent and provides an explanation of the failure in the case of
asynchronous unplug.
Signed-off-by: Julia Suvorova <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
Reviewed-by: Marcel Apfelbaum <address@hidden>
---
hw/pci/pcie.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c
index 0eb3a2a5d2..6b48d04d2c 100644
--- a/hw/pci/pcie.c
+++ b/hw/pci/pcie.c
@@ -415,6 +415,7 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev,
{
PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
+ uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
PCIDevice *pci_dev = PCI_DEVICE(dev);
/* Don't send event when device is enabled during qemu machine creation:
@@ -430,6 +431,13 @@ void pcie_cap_slot_plug_cb(HotplugHandler *hotplug_dev,
DeviceState *dev,
return;
}
+ /* Check if hot-plug is disabled on the slot */
+ if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
+ error_setg(errp, "Hot-plug failed: unsupported by the port device
'%s'",
+ DEVICE(hotplug_pdev)->id);
+ return;
+ }
+
/* To enable multifunction hot-plug, we just ensure the function
* 0 added last. When function 0 is added, we set the sltsta and
* inform OS via event notification.
@@ -470,6 +478,17 @@ void pcie_cap_slot_unplug_request_cb(HotplugHandler
*hotplug_dev,
Error *local_err = NULL;
PCIDevice *pci_dev = PCI_DEVICE(dev);
PCIBus *bus = pci_get_bus(pci_dev);
+ PCIDevice *hotplug_pdev = PCI_DEVICE(hotplug_dev);
+ uint8_t *exp_cap = hotplug_pdev->config + hotplug_pdev->exp.exp_cap;
+ uint32_t sltcap = pci_get_word(exp_cap + PCI_EXP_SLTCAP);
+
+ /* Check if hot-unplug is disabled on the slot */
+ if ((sltcap & PCI_EXP_SLTCAP_HPC) == 0) {
+ error_setg(errp, "Hot-unplug failed: "
+ "unsupported by the port device '%s'",
+ DEVICE(hotplug_pdev)->id);
+ return;
+ }
pcie_cap_slot_plug_common(PCI_DEVICE(hotplug_dev), dev, &local_err);
if (local_err) {
--
MST
- [PULL 00/29] virtio,acpi,pci,pc: backlog from pre-5.0, Michael S. Tsirkin, 2020/05/04
- [PULL 01/29] hw/pci/pcie: Forbid hot-plug if it's disabled on the slot,
Michael S. Tsirkin <=
- [PULL 02/29] hw/pci/pcie: Replace PCI_DEVICE() casts with existing variable, Michael S. Tsirkin, 2020/05/04
- [PULL 03/29] move 'typedef Aml' to qemu/types.h, Michael S. Tsirkin, 2020/05/04
- [PULL 05/29] qtest: allow DSDT acpi table changes, Michael S. Tsirkin, 2020/05/04
- [PULL 06/29] acpi: drop pointless _STA method, Michael S. Tsirkin, 2020/05/04
- [PULL 07/29] acpi: add ISADeviceClass->build_aml(), Michael S. Tsirkin, 2020/05/04
- [PULL 08/29] rtc: add RTC_ISA_BASE, Michael S. Tsirkin, 2020/05/04
- [PULL 09/29] virtio-vga: fix virtio-vga bar ordering, Michael S. Tsirkin, 2020/05/04
- [PULL 11/29] vhost-user-blk: fix invalid memory access, Michael S. Tsirkin, 2020/05/04
- [PULL 12/29] checkpatch: fix acpi check with multiple file name, Michael S. Tsirkin, 2020/05/04
- [PULL 13/29] checkpatch: ignore allowed diff list, Michael S. Tsirkin, 2020/05/04