On aarch64 hosts with 64K pages, the platform bus MMIO allocator can
place device regions (such as the 1KB "tpm-ppi" region) at offsets
that are not aligned to the host page size. This causes unnecessary
and noisy VFIO IOMMU warnings when starting VMs configured with
passed-through PCI devices:
vfio_listener_valid_section received unaligned region tpm-ppi
iova=0xc005000 offset_within_region=0x0
qemu_real_host_page_size=0x10000
Fix this by ensuring the alignment used by the platform bus allocator
is at least qemu_real_host_page_size().
Signed-off-by: Cédric Le Goater <[email protected]>
---
hw/core/platform-bus.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index
a2217a2deec7ab0f49b211c6658db02d13c319df..a17a38c1ba5491e2001fec5a29c188de67e93d11
100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -140,6 +140,13 @@ static void platform_bus_map_mmio(PlatformBusDevice *pbus,
SysBusDevice *sbdev,
return;
}
+ /*
+ * Ensure alignment is at least the host page size so that IOMMU
+ * mappings (e.g. VFIO) work on hosts with large pages such as
+ * aarch64 with 64K pages.
+ */
+ alignment = MAX(alignment, qemu_real_host_page_size());
+
/*
* Look for empty space in the MMIO space that is naturally aligned with
* the target device's memory region
--
2.54.0