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

Skip to content

misc: return errors from IOMMU address translation instead of panic… - #8023

Merged
rbradford merged 1 commit into
cloud-hypervisor:mainfrom
dgreid:topic/iommu_xlate
Apr 15, 2026
Merged

rbradford merged 1 commit into
cloud-hypervisor:mainfrom
dgreid:topic/iommu_xlate

Conversation

@dgreid

@dgreid dgreid commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

The only thing the guest can do here is crash it's own VMM, but I'd still rather return an error or exit cleanly. WDYT? Luckily all callers were already fallible, so it only took one level of map_err? additions.

@dgreid
dgreid requested a review from a team as a code owner April 14, 2026 21:58
@dgreid
dgreid force-pushed the topic/iommu_xlate branch from 145f91c to 0b90c92 Compare April 14, 2026 21:59

@rbradford rbradford 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.

nit: The prefix on the commit summary should be "virtio-devices:" or if that's too long "misc:"

The address that is passed from the guest should be treated as
untrusted. Currently an invalid address will panic the VMM. This only
allows the guest to hurt itself, but we shouldn't have the VMM crashing.
Instead let's return an error if possible or invalidate the queue if it
happen during setup.

The data flow from guest to translate_gva/translate_gpa is:

  1. Guest writes a raw u64 address into a virtio descriptor in the
     shared descriptor table (guest memory).
  2. The virtio-queue crate reads this descriptor via read_obj() and
     returns the addr field as-is in a GuestAddress — no validation.
  3. Device code calls .translate_gva(access_platform, len) on the
     GuestAddress.
  4. With IOMMU (access_platform is Some): the address is an IOVA that
     must be translated to a GPA via the IOMMU mapping table. If the
     guest provides an unmapped IOVA, translation returns Err.
     Previously, .unwrap() here panicked the VMM.
  5. Without IOMMU (access_platform is None): translate_gva is a no-op
     (returns self). The raw address flows to GuestMemory::read_obj()
     which validates it — out-of-range addresses return
     Err(InvalidGuestAddress), so no host memory corruption is possible.

Signed-off-by: Dylan Reid <[email protected]>
@rbradford rbradford changed the title virtio: return errors from IOMMU address translation instead of panic… misc: return errors from IOMMU address translation instead of panic… Apr 14, 2026
@rbradford
rbradford enabled auto-merge April 14, 2026 22:35
@rbradford

Copy link
Copy Markdown
Member

nit: The prefix on the commit summary should be "virtio-devices:" or if that's too long "misc:"

I just updated it to misc - it should now land now.

@rbradford
rbradford added this pull request to the merge queue Apr 14, 2026
Merged via the queue into cloud-hypervisor:main with commit a6d3901 Apr 15, 2026
38 checks passed
@rbradford rbradford moved this to ✅ Done in Cloud Hypervisor Roadmap Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

2 participants