[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v9 15/17] hw/vfio/pci: Omit errp for pci_add_capability
From: |
Akihiko Odaki |
Subject: |
[PATCH v9 15/17] hw/vfio/pci: Omit errp for pci_add_capability |
Date: |
Tue, 1 Nov 2022 23:55:56 +0900 |
The code generating errors in pci_add_capability has a comment which
says:
> Verify that capabilities don't overlap. Note: device assignment
> depends on this check to verify that the device is not broken.
> Should never trigger for emulated devices, but it's helpful for
> debugging these.
Indeed vfio has some code that passes capability offsets and sizes from
a physical device, but it explicitly pays attention so that the
capabilities never overlap. Therefore, in pci_add_capability(), we can
always assert that capabilities never overlap, and that is what happens
when omitting errp.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
hw/vfio/pci-quirks.c | 15 +++------------
hw/vfio/pci.c | 14 +++++---------
2 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/hw/vfio/pci-quirks.c b/hw/vfio/pci-quirks.c
index f0147a050a..e94fd273ea 100644
--- a/hw/vfio/pci-quirks.c
+++ b/hw/vfio/pci-quirks.c
@@ -1530,7 +1530,7 @@ const PropertyInfo qdev_prop_nv_gpudirect_clique = {
static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice *vdev, Error **errp)
{
PCIDevice *pdev = &vdev->pdev;
- int ret, pos = 0xC8;
+ int pos = 0xC8;
if (vdev->nv_gpudirect_clique == 0xFF) {
return 0;
@@ -1547,11 +1547,7 @@ static int vfio_add_nv_gpudirect_cap(VFIOPCIDevice
*vdev, Error **errp)
return -EINVAL;
}
- ret = pci_add_capability(pdev, PCI_CAP_ID_VNDR, pos, 8, errp);
- if (ret < 0) {
- error_prepend(errp, "Failed to add NVIDIA GPUDirect cap: ");
- return ret;
- }
+ pci_add_capability(pdev, PCI_CAP_ID_VNDR, pos, 8);
memset(vdev->emulated_config_bits + pos, 0xFF, 8);
pos += PCI_CAP_FLAGS;
@@ -1718,12 +1714,7 @@ static int vfio_add_vmd_shadow_cap(VFIOPCIDevice *vdev,
Error **errp)
return -EFAULT;
}
- ret = pci_add_capability(&vdev->pdev, PCI_CAP_ID_VNDR, pos,
- VMD_SHADOW_CAP_LEN, errp);
- if (ret < 0) {
- error_prepend(errp, "Failed to add VMD MEMBAR Shadow cap: ");
- return ret;
- }
+ pci_add_capability(&vdev->pdev, PCI_CAP_ID_VNDR, pos, VMD_SHADOW_CAP_LEN);
memset(vdev->emulated_config_bits + pos, 0xFF, VMD_SHADOW_CAP_LEN);
pos += PCI_CAP_FLAGS;
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 0ca6b5ff4b..458729eae3 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -1839,7 +1839,7 @@ static void vfio_add_emulated_long(VFIOPCIDevice *vdev,
int pos,
vfio_set_long_bits(vdev->emulated_config_bits + pos, mask, mask);
}
-static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int pos, uint8_t size,
+static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, uint8_t pos, uint8_t size,
Error **errp)
{
uint16_t flags;
@@ -1956,11 +1956,7 @@ static int vfio_setup_pcie_cap(VFIOPCIDevice *vdev, int
pos, uint8_t size,
1, PCI_EXP_FLAGS_VERS);
}
- pos = pci_add_capability(&vdev->pdev, PCI_CAP_ID_EXP, pos, size,
- errp);
- if (pos < 0) {
- return pos;
- }
+ pos = pci_add_capability(&vdev->pdev, PCI_CAP_ID_EXP, pos, size);
vdev->pdev.exp.exp_cap = pos;
@@ -2058,14 +2054,14 @@ static int vfio_add_std_cap(VFIOPCIDevice *vdev,
uint8_t pos, Error **errp)
case PCI_CAP_ID_PM:
vfio_check_pm_reset(vdev, pos);
vdev->pm_cap = pos;
- ret = pci_add_capability(pdev, cap_id, pos, size, errp);
+ pci_add_capability(pdev, cap_id, pos, size);
break;
case PCI_CAP_ID_AF:
vfio_check_af_flr(vdev, pos);
- ret = pci_add_capability(pdev, cap_id, pos, size, errp);
+ pci_add_capability(pdev, cap_id, pos, size);
break;
default:
- ret = pci_add_capability(pdev, cap_id, pos, size, errp);
+ pci_add_capability(pdev, cap_id, pos, size);
break;
}
--
2.38.1
- [PATCH v9 05/17] e1000e: Omit errp for pci_add_capability, (continued)
- [PATCH v9 05/17] e1000e: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 06/17] eepro100: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 07/17] hw/nvme: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 08/17] msi: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 09/17] hw/pci/pci_bridge: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 10/17] pcie: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 11/17] pci/shpc: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 12/17] msix: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 13/17] pci/slotid: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 14/17] hw/pci-bridge/pcie_pci_bridge: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 15/17] hw/vfio/pci: Omit errp for pci_add_capability,
Akihiko Odaki <=
- [PATCH v9 16/17] virtio-pci: Omit errp for pci_add_capability, Akihiko Odaki, 2022/11/01
- [PATCH v9 17/17] pci: Remove legacy errp from pci_add_capability, Akihiko Odaki, 2022/11/01