On 7/8/26 17:06, Alex Williamson wrote:
On Wed, 8 Jul 2026 15:36:04 +0200
Cédric Le Goater <[email protected]> wrote:
The vfio_known_safe_misalignment() whitelist (currently TPM CRB only)
requires a new entry every time a device exposes a non-page-aligned
region, which does not scale.
Arguable as we have exactly one class of device so far that's validated
as safe.
Replace it with a DMA capability check: a region that is not
page-aligned or is smaller than a host page can never be a valid DMA
target, so a page-offset mismatch is harmless and only traced. Only
warn for page-aligned, page-sized regions where the mismatch could
indicate a real mapping problem.
But it's the composition into the address space and how that address
space is defined to the guest that matters. Imagine a minimum counter
example to the test presented here, a page-size range of RAM in the VM
is composed by a device as two contiguous sub-page MemoryRegions. We
only see the individual MRs here, they're each sub-page, the shape
suggests they're not DMA targets, but together they map contiguously
into the VM address space. KVM can trap and emulate them as normal
RAM. QEMU emulated devices can DMA to them as RAM. VFIO cannot map
them through the IOMMU.
That is what this test is meant to validate. The judgment that the
control register range for a TPM device presented as a RAM MR is not a
meaningful DMA target for a vfio device is the thing that cannot be
determined based only on the shape of the MR.
ok. I understand. this is difficult to address cleanly without a
white list then. Which is what "Extend safe misalignment check to
tpm-ppi region" proposes. I will let it cool down.
This change is not critical. It is part of a broader effort to
avoid giving users the wrong impression that the problem comes
from VFIO when analyzing diagnostic logs with errors/warnings
spread across the system. This is not the only VFIO message in
this category.
C.