Thanks to visit codestin.com
Credit goes to github.com

Skip to content

virtio-devices: iommu: Translate buffers spanning adjacent mappings - #8520

Merged
likebreath merged 1 commit into
cloud-hypervisor:mainfrom
rbradford:202607/virtio-iommu-span
Jul 6, 2026
Merged

likebreath merged 1 commit into
cloud-hypervisor:mainfrom
rbradford:202607/virtio-iommu-span

Conversation

@rbradford

Copy link
Copy Markdown
Member

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]

Comment thread virtio-devices/src/iommu.rs Outdated
Comment thread virtio-devices/src/iommu.rs Outdated
Comment thread virtio-devices/src/iommu.rs Outdated
@weltling

weltling commented Jul 3, 2026

Copy link
Copy Markdown
Member

@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]>
@rbradford
rbradford force-pushed the 202607/virtio-iommu-span branch from 190083f to 738e597 Compare July 3, 2026 15:25
@rbradford

Copy link
Copy Markdown
Member Author

@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

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 weltling left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@likebreath likebreath added the bug-fix Bug fix to include in release notes label Jul 6, 2026
@github-project-automation github-project-automation Bot moved this from 🆕 New to 📋 Backlog in Cloud Hypervisor Roadmap Jul 6, 2026
@likebreath
likebreath added this pull request to the merge queue Jul 6, 2026
Merged via the queue into cloud-hypervisor:main with commit 9161b18 Jul 6, 2026
39 checks passed
@github-project-automation github-project-automation Bot moved this from 📋 Backlog to ✅ Done in Cloud Hypervisor Roadmap Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix Bug fix to include in release notes

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants