[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 5/9] vfio: Improve error reporting when MMIO region mapping fa
From: |
Cédric Le Goater |
Subject: |
[PATCH v2 5/9] vfio: Improve error reporting when MMIO region mapping fails |
Date: |
Thu, 30 Jan 2025 14:43:42 +0100 |
When the IOMMU address space width is smaller than the physical
address width, a MMIO region of a device can fail to map because the
region is outside the supported IOVA ranges of the VM. In this case,
PCI peer-to-peer transactions on BARs are not supported.
This can occur with the 39-bit IOMMU address space width, as can be
the case on some consumer processors or when using a vIOMMU device
with default settings. The current error message is unclear, also
change the error report to a warning because it is a non fatal
condition for the VM.
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/common.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index
62af1216fc5a9089fc718c2afe3a405d9381db32..5c9d8657d746ce30af5ae8f9122101e086a61ef5
100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -555,6 +555,18 @@ static bool vfio_get_section_iova_range(VFIOContainerBase
*bcontainer,
return true;
}
+static void vfio_device_error_append(VFIODevice *vbasedev, Error **errp)
+{
+ /*
+ * MMIO region mapping failures are not fatal but in this case PCI
+ * peer-to-peer transactions are broken.
+ */
+ if (vbasedev && vbasedev->type == VFIO_DEVICE_TYPE_PCI) {
+ error_append_hint(errp, "%s: PCI peer-to-peer transactions "
+ "on BARs are not supported.\n", vbasedev->name);
+ }
+}
+
static void vfio_listener_region_add(MemoryListener *listener,
MemoryRegionSection *section)
{
@@ -670,7 +682,10 @@ static void vfio_listener_region_add(MemoryListener
*listener,
strerror(-ret));
if (memory_region_is_ram_device(section->mr)) {
/* Allow unexpected mappings not to be fatal for RAM devices */
- error_report_err(err);
+ VFIODevice *vbasedev =
+ vfio_get_vfio_device(memory_region_owner(section->mr));
+ vfio_device_error_append(vbasedev, &err);
+ warn_report_once_err(err);
return;
}
goto fail;
--
2.48.1
[PATCH v2 2/9] vfio/pci: Replace "iommu_device" by "vIOMMU", Cédric Le Goater, 2025/01/30
[PATCH v2 3/9] vfio: Rephrase comment in vfio_listener_region_add() error path, Cédric Le Goater, 2025/01/30
[PATCH v2 5/9] vfio: Improve error reporting when MMIO region mapping fails,
Cédric Le Goater <=
[PATCH v2 6/9] vfio: Remove reports of DMA mapping errors in backends, Cédric Le Goater, 2025/01/30
[PATCH v2 4/9] vfio: Introduce vfio_get_vfio_device(), Cédric Le Goater, 2025/01/30
[PATCH v2 8/9] vfio: Check compatibility of CPU and IOMMU address space width, Cédric Le Goater, 2025/01/30
[PATCH v2 7/9] cpu: Introduce cpu_get_phys_bits(), Cédric Le Goater, 2025/01/30
[PATCH v2 9/9] vfio: Remove superfluous error report in vfio_listener_region_add(), Cédric Le Goater, 2025/01/30