Skip to content

[VFIO] Chapter 2, Section 3: BAR areas and mappings - #6114

Merged
ShadowCurse merged 5 commits into
firecracker-microvm:feature/vfiofrom
ShadowCurse:vfio_part_2_3
Sep 2, 2026
Merged

ShadowCurse merged 5 commits into
firecracker-microvm:feature/vfiofrom
ShadowCurse:vfio_part_2_3

Conversation

@ShadowCurse

Copy link
Copy Markdown
Contributor

Changes

Another set of commits taken from #6055 PR. Here we add logic for calculating mappable areas of BARs (taking into account the holes left by the MSIX tables) and actually doing the actual map operations.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license. For more information on following Developer
Certificate of Origin and signing off your commits, please check
CONTRIBUTING.md.

PR Checklist

  • I have read and understand CONTRIBUTING.md.
  • I have run tools/devtool checkbuild --all to verify that the PR passes
    build checks on all supported architectures.
  • I have run tools/devtool checkstyle to verify that the PR passes the
    automated style checks.
  • I have described what is done in these changes, why they are needed, and
    how they are solving the problem in a clear and encompassing way.
  • I have updated any relevant documentation (both in code and in the docs)
    in the PR.
  • I have mentioned all user-facing changes in CHANGELOG.md.
  • If a specific issue led to this PR, this PR closes the issue.
  • When making API changes, I have followed the
    Runbook for Firecracker API changes.
  • I have tested all new and changed functionalities in unit tests and/or
    integration tests.
  • I have linked an issue to every new TODO.

  • This functionality cannot be added in rust-vmm.

@codecov

codecov Bot commented Aug 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.41935% with 101 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.77%. Comparing base (8c8fc63) to head (1f9ff59).

Files with missing lines Patch % Lines
src/vmm/src/vfio.rs 64.18% 101 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           feature/vfio    #6114      +/-   ##
================================================
- Coverage         82.85%   82.77%   -0.08%     
================================================
  Files               280      280              
  Lines             31115    31413     +298     
================================================
+ Hits              25781    26003     +222     
- Misses             5334     5410      +76     
Flag Coverage Δ
5.10-m5n.metal 83.00% <67.41%> (-0.09%) ⬇️
5.10-m6a.metal 82.37% <67.41%> (-0.09%) ⬇️
5.10-m6g.metal 79.87% <67.41%> (-0.06%) ⬇️
5.10-m6i.metal 83.00% <67.41%> (-0.10%) ⬇️
5.10-m7a.metal-48xl 82.36% <67.41%> (-0.09%) ⬇️
5.10-m7g.metal 79.87% <67.41%> (-0.07%) ⬇️
5.10-m7i.metal-24xl 82.97% <67.41%> (-0.11%) ⬇️
5.10-m7i.metal-48xl 82.98% <67.41%> (-0.10%) ⬇️
5.10-m8g.metal-24xl 79.87% <67.41%> (-0.06%) ⬇️
5.10-m8g.metal-48xl 79.87% <67.41%> (-0.06%) ⬇️
5.10-m8i.metal-48xl 82.97% <67.41%> (-0.10%) ⬇️
5.10-m8i.metal-96xl 82.98% <67.41%> (-0.09%) ⬇️
6.1-m5n.metal 83.02% <67.41%> (-0.10%) ⬇️
6.1-m6a.metal 82.39% <67.41%> (-0.10%) ⬇️
6.1-m6g.metal 79.87% <67.41%> (-0.07%) ⬇️
6.1-m6i.metal 83.02% <67.41%> (-0.10%) ⬇️
6.1-m7a.metal-48xl 82.38% <67.41%> (-0.09%) ⬇️
6.1-m7g.metal 79.87% <67.41%> (-0.06%) ⬇️
6.1-m7i.metal-24xl 83.03% <67.41%> (-0.10%) ⬇️
6.1-m7i.metal-48xl 83.04% <67.41%> (-0.10%) ⬇️
6.1-m8g.metal-24xl 79.87% <67.41%> (-0.07%) ⬇️
6.1-m8g.metal-48xl 79.87% <67.41%> (-0.07%) ⬇️
6.1-m8i.metal-48xl 83.04% <67.41%> (-0.10%) ⬇️
6.1-m8i.metal-96xl 83.04% <67.41%> (-0.10%) ⬇️
6.18-m5n.metal 83.03% <67.41%> (-0.10%) ⬇️
6.18-m6a.metal 82.39% <67.41%> (-0.09%) ⬇️
6.18-m6g.metal 79.87% <67.41%> (-0.06%) ⬇️
6.18-m6i.metal 83.02% <67.41%> (-0.10%) ⬇️
6.18-m7a.metal-48xl 82.38% <67.41%> (-0.10%) ⬇️
6.18-m7g.metal 79.88% <67.41%> (-0.06%) ⬇️
6.18-m7i.metal-24xl 83.04% <67.41%> (-0.10%) ⬇️
6.18-m7i.metal-48xl 83.04% <67.41%> (-0.11%) ⬇️
6.18-m8g.metal-24xl 79.87% <67.41%> (-0.06%) ⬇️
6.18-m8g.metal-48xl 79.87% <67.41%> (-0.07%) ⬇️
6.18-m8i.metal-48xl 83.04% <67.41%> (-0.10%) ⬇️
6.18-m8i.metal-96xl 83.04% <67.41%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ShadowCurse
ShadowCurse force-pushed the vfio_part_2_3 branch 3 times, most recently from 7cfcfd7 to 3acd6b7 Compare August 18, 2026 09:34
Make `arrayvec` non optional as it will be used in the future VFIO
commits.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse
ShadowCurse marked this pull request as ready for review August 19, 2026 10:41
Add new utility functions for dealing with alignment of addresses.
These will be used in the following commits.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse ShadowCurse self-assigned this Aug 19, 2026
@ShadowCurse ShadowCurse added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Aug 19, 2026
Comment thread src/vmm/src/utils/mod.rs
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
@ShadowCurse
ShadowCurse force-pushed the vfio_part_2_3 branch 3 times, most recently from 476cade to 825b501 Compare September 1, 2026 13:41
Manciukic
Manciukic previously approved these changes Sep 1, 2026

@Manciukic Manciukic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just a followup we should track and a missing test (non-blocking).

Also a few typos: "emualted" (:572), "kerneld" (:731), "provied" (:748), "regon" (:802), "correspoinding" (:923).

Comment thread src/vmm/src/vfio.rs
Comment thread src/vmm/src/vfio.rs Outdated
ilstam
ilstam previously approved these changes Sep 1, 2026
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs Outdated
Comment thread src/vmm/src/vfio.rs
Comment thread src/vmm/src/vfio.rs
@ShadowCurse
ShadowCurse dismissed stale reviews from ilstam and Manciukic via fb15d96 September 1, 2026 16:34
@ShadowCurse
ShadowCurse force-pushed the vfio_part_2_3 branch 2 times, most recently from fb15d96 to 8c51e99 Compare September 1, 2026 16:39
Instead of widening results to `u64`s, return smaller `u32`/`u16`
directly and let the caller widening them if needed.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
ilstam
ilstam previously approved these changes Sep 1, 2026
Calculate areas of BARs which either should be mmapped and provided to
the guest or fully emulated.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
After calculating the DMA areas of BARs, map them into the guest. This
involves `mmap`ing the device BAR into Firecracker virtual space, and
creating KVM slots for them.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Comment thread src/vmm/src/vfio.rs
@ShadowCurse
ShadowCurse merged commit fb33146 into firecracker-microvm:feature/vfio Sep 2, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Awaiting review Indicates that a pull request is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants