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 <clg@redhat.com>
---
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
On Tue, 30 Jun 2026 at 18:33, Cédric Le Goater <clg@redhat.com> 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. > 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 <clg@redhat.com> > --- > 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. -- PMM
On 6/30/26 22:03, Peter Maydell wrote:
> On Tue, 30 Jun 2026 at 18:33, Cédric Le Goater <clg@redhat.com> 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 <clg@redhat.com>
>> ---
>> 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.
On Wed, 1 Jul 2026 at 08:34, Cédric Le Goater <clg@redhat.com> wrote:
>
> On 6/30/26 22:03, Peter Maydell wrote:
> > On Tue, 30 Jun 2026 at 18:33, Cédric Le Goater <clg@redhat.com> 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.
That sounds like the problem then is that VFIO is warning about
things that are not in any way going to cause an issue. We should
stop it from doing that, not change the rest of the platform
because its warnings are over-broad.
> OK. Let's extend vfio_known_safe_misalignment() instead as done
> by commit 851d6d1a0ff2 ("vfio/common: remove spurious tpm-crb-cmd
> misalignment warning").
That seems like vfio is gradually accumulating a very
specific list of "we know this thing is misaligned" every
time. That is clearly wrong -- any device anywhere on the
board is allowed to have a non-aligned memory region. Those
are totally normal.
I think the vfio code needs to change so that it's only checking
the stuff that's actually vfio related. Drop the "we have a
whitelist" approach, please.
-- PMM
© 2016 - 2026 Red Hat, Inc.