virtio-devices: iommu: Translate buffers spanning adjacent mappings - #8520
Conversation
|
@rbradford Nice generalized approach! My open question is a non contiguous span, where a single descriptor contiguous IOVA resolves to multiple non contiguous physical pages in the guest. I don't know if virtio-net ever generates that, so maybe it doesn't touch the reported issue, but I'll validate by running your patch on the environment that first reproduced it and follow up with results. Thanks |
The virtio-iommu translation required the whole [addr, addr+size) span to be covered by a single mapping. A guest is free to describe one contiguous buffer with several adjacent mappings: the specification lets the driver map at page granularity and the Linux IOMMU core splits a single mapping request at page size boundaries. A descriptor buffer backed this way was rejected as an invalid translation even though every page was mapped, wedging the device. Walk consecutive mappings when no single one covers the span, accepting the translation once the mappings are adjacent in IOVA space and contiguous in guest-physical space. A non-contiguous span cannot be represented by the single returned address and is still rejected. Assisted-by: Claude:Opus-4.8 Signed-off-by: Rob Bradford <[email protected]>
190083f to
738e597
Compare
I asked Claude to analyse the Linux code when I was working on this and it told me that this is a 1x1 relationship between sqb and descriptor. |
weltling
left a comment
There was a problem hiding this comment.
Ran your patch on the repro environment. The issue is gone, no NEEDS_RESET or failed to translate, and no other symptoms of a broken NIC.
Looks good to me, thanks!
The virtio-iommu translation required the whole [addr, addr+size) span
to be covered by a single mapping. A guest is free to describe one
contiguous buffer with several adjacent mappings: the specification lets
the driver map at page granularity and the Linux IOMMU core splits a
single mapping request at page size boundaries. A descriptor buffer
backed this way was rejected as an invalid translation even though every
page was mapped, wedging the device.
Walk consecutive mappings when no single one covers the span, accepting
the translation once the mappings are adjacent in IOVA space and
contiguous in guest-physical space. A non-contiguous span cannot be
represented by the single returned address and is still rejected.
Assisted-by: Claude:Opus-4.8
Signed-off-by: Rob Bradford [email protected]