From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>
Subject: [PULL 10/12] vfio: Improve error reporting when MMIO region mapping fails
Date: Tue, 11 Feb 2025 15:33:38 +0100 [thread overview]
Message-ID: <20250211143340.787996-11-clg@redhat.com> (raw)
In-Reply-To: <20250211143340.787996-1-clg@redhat.com>
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 Intel consumer processors, or when using a vIOMMU device with
default settings.
The current error message is unclear, improve it and also change the
error report to a warning because it is a non fatal condition for the
VM. To prevent excessive log messages, restrict these recurring DMA
mapping errors to a single warning at runtime.
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20250206131438.1505542-6-clg@redhat.com
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..4fca4c6166f761acceb7b57b52e379603ea53876 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_err_once(err);
return;
}
goto fail;
--
2.48.1
next prev parent reply other threads:[~2025-02-11 14:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 14:33 [PULL 00/12] vfio queue Cédric Le Goater
2025-02-11 14:33 ` [PULL 01/12] vfio/igd: Fix potential overflow in igd_gtt_memory_size() Cédric Le Goater
2025-02-11 14:33 ` [PULL 02/12] vfio/pci: declare generic quirks in a new header file Cédric Le Goater
2025-02-11 14:33 ` [PULL 03/12] vfio/pci: introduce config_offset field in VFIOConfigMirrorQuirk Cédric Le Goater
2025-02-11 14:33 ` [PULL 04/12] vfio/igd: use VFIOConfigMirrorQuirk for mirrored registers Cédric Le Goater
2025-02-11 14:33 ` [PULL 05/12] vfio/iommufd: Fix SIGSEV in iommufd_cdev_attach() Cédric Le Goater
2025-02-12 19:12 ` Michael Tokarev
2025-02-13 6:32 ` Cédric Le Goater
2025-02-13 6:42 ` Michael Tokarev
2025-02-13 8:48 ` Cédric Le Goater
2025-02-13 9:30 ` Michael Tokarev
2025-02-11 14:33 ` [PULL 06/12] util/error: Introduce warn_report_err_once() Cédric Le Goater
2025-02-11 14:33 ` [PULL 07/12] vfio/pci: Replace "iommu_device" by "vIOMMU" Cédric Le Goater
2025-02-11 14:33 ` [PULL 08/12] vfio: Rephrase comment in vfio_listener_region_add() error path Cédric Le Goater
2025-02-11 14:33 ` [PULL 09/12] vfio: Introduce vfio_get_vfio_device() Cédric Le Goater
2025-02-11 14:33 ` Cédric Le Goater [this message]
2025-02-11 14:33 ` [PULL 11/12] vfio: Remove reports of DMA mapping errors in backends Cédric Le Goater
2025-02-11 14:33 ` [PULL 12/12] vfio: Remove superfluous error report in vfio_listener_region_add() Cédric Le Goater
2025-02-12 17:38 ` [PULL 00/12] vfio queue Stefan Hajnoczi
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=20250211143340.787996-11-clg@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@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).