On 6/30/26 22:03, Peter Maydell wrote:
On Tue, 30 Jun 2026 at 18:33, Cédric Le Goater <[email protected]> wrote:

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

Why does vfio care about the tpm-ppi region? I thought vfio
was only for passthrough devices, not for normal ones.

It's caught by the VFIO listener which doesn't filer per device, it
covers the entire address space.

This is a benign address mis-alignment warning of the tpm-ppi memory
region and VFIO simply skips the region.


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());

Do we need to tie this to machine versions? Otherwise I think
the memory layout can change underfoot which would break a
guest migrated from an old QEMU to new.

OK. Let's extend vfio_known_safe_misalignment() instead as done
by commit 851d6d1a0ff2 ("vfio/common: remove spurious tpm-crb-cmd
misalignment warning").


Thanks,

C.



Reply via email to