vfio/listener: Extend safe misalignment check to tpm-ppi region
PATCH 1/1 vfio/listener: Extend safe misalignment check to tpm-ppi region
On aarch64 hosts with 64K pages, the platform bus MMIO allocator can allocate the 1KB "tpm-ppi" region at offsets not aligned to the host page size, triggering a noisy VFIO IOMMU warning at VM startup:
vfio_listener_valid_section received unaligned region tpm-ppi
iova=0xc005000 offset_within_region=0x0
qemu_real_host_page_size=0x10000Commit 851d6d1a0ff2 ("vfio/common: remove spurious tpm-crb-cmd misalignment warning") suppressed this for TPM CRB devices via a TPM_IS_CRB(owner) check. However, this misses "tpm-ppi" regions owned by other TPM types like SysBus/ISA tpm-tis devices.
Avoid enumerating every TPM device type by matching the "tpm-ppi" memory region name directly in vfio_known_safe_misalignment().
--- hw/vfio/listener.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
hw/vfio/listener.c +3 -1
@@ -355,8 +355,10 @@ static void vfio_ram_discard_unregister_listener(VFIOContainer *bcontainer,static bool vfio_known_safe_misalignment (MemoryRegionSection *section) {MemoryRegion *mr = section->mr; +const char *name =memory_region_name (mr); -if (!TPM_IS_CRB (mr->owner)) { +if (!TPM_IS_CRB (mr->owner) && + !(name &&strcmp (name,"tpm-ppi" ) ==0 )) {return false; }
Signature · 1 line
2.54.0
Quoted 27 lines · Cédric Le Goater
On aarch64 hosts with 64K pages, the platform bus MMIO allocator can allocate the 1KB "tpm-ppi" region at offsets not aligned to the host page size, triggering a noisy VFIO IOMMU warning at VM startup:
vfio_listener_valid_sectionreceived unaligned region tpm-ppiiova=0xc005000 offset_within_region=0x0 qemu_real_host_page_size=0x10000Commit
851d6d1a0ff2("vfio/common: remove spurious tpm-crb-cmd misalignment warning") suppressed this for TPM CRB devices via aTPM_IS_CRB(owner)check. However, this misses "tpm-ppi" regions owned by other TPM types like SysBus/ISA tpm-tis devices.Avoid enumerating every TPM device type by matching the "tpm-ppi" memory region name directly in
vfio_known_safe_misalignment().Signed-off-by Cedric Le Goater <[email protected]>--- hw/vfio/listener.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/vfio/listener.c +0
-0
hw/vfio/listener.c static void vfio_ram_discard_unregister_listener(VFIOContainer *bcontainer, · line 363
Quoted 10 lines
hw/vfio/listener.c +3
-1@@ -355,8 +355,10 @@ static void vfio_ram_discard_unregister_listener(VFIOContainer *bcontainer,static bool vfio_known_safe_misalignment (MemoryRegionSection *section) {MemoryRegion *mr = section->mr; +const char *name =memory_region_name (mr); -if (!TPM_IS_CRB (mr->owner)) { +if (!TPM_IS_CRB (mr->owner) && + !(name &&strcmp (name,"tpm-ppi" ) ==0 )) {return false; }
I think this is the wrong approach, see my comments on the other email thread. vfio should not be building up some kind of whitelist of "this specific not-page-aligned RAM is OK", because a not-page-aligned RAM backed MMIO region is in general a normal thing to have.
thanks
-- PMM
Quoted 33 lines · Peter Maydell
Quoted 32 lines · Cédric Le Goater
On aarch64 hosts with 64K pages, the platform bus MMIO allocator can allocate the 1KB "tpm-ppi" region at offsets not aligned to the host page size, triggering a noisy VFIO IOMMU warning at VM startup:
vfio_listener_valid_section received unaligned region tpm-ppi iova=0xc005000 offset_within_region=0x0 qemu_real_host_page_size=0x10000Commit
851d6d1a0ff2("vfio/common: remove spurious tpm-crb-cmd misalignment warning") suppressed this for TPM CRB devices via aTPM_IS_CRB(owner)check. However, this misses "tpm-ppi" regions owned by other TPM types like SysBus/ISA tpm-tis devices.Avoid enumerating every TPM device type by matching the "tpm-ppi" memory region name directly in
vfio_known_safe_misalignment().Signed-off-by Cedric Le Goater <[email protected]>--- hw/vfio/listener.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)hw/vfio/listener.c +1
-0@@ -355,8 +355,10 @@ static void vfio_ram_discard_unregister_listener(VFIOContainer *bcontainer,static bool vfio_known_safe_misalignment (MemoryRegionSection *section) {MemoryRegion *mr = section->mr; +const char *name =memory_region_name (mr);
Quoted 11 lines
hw/vfio/listener.c static void vfio_ram_discard_unregister_listener(VFIOContainer *bcontainer, · line 363
Quoted 5 lines
hw/vfio/listener.c +2
-1-if (!TPM_IS_CRB (mr->owner)) { +if (!TPM_IS_CRB (mr->owner) && + !(name &&strcmp (name,"tpm-ppi" ) ==0 )) {return false; }I think this is the wrong approach, see my comments on the other email thread. vfio should not be building up some kind of whitelist of "this specific not-page-aligned RAM is OK", because a not-page-aligned RAM backed MMIO region is in general a normal thing to have.
We should warn for only VFIO-owned regions. I agree.
Forget this patch. It's minor anyway. I will see how the listener can be improved to remove vfio_known_safe_misalignment()
Thanks,
C.