Skip to content

[VFIO] Chapter 2, Section 4: VfioDevice and its traits - #6183

Draft
ShadowCurse wants to merge 3 commits into
firecracker-microvm:feature/vfiofrom
ShadowCurse:vfio_part_2_4
Draft

[VFIO] Chapter 2, Section 4: VfioDevice and its traits#6183
ShadowCurse wants to merge 3 commits into
firecracker-microvm:feature/vfiofrom
ShadowCurse:vfio_part_2_4

Conversation

@ShadowCurse

Copy link
Copy Markdown
Contributor

Changes

Another set of commits taken from #6055 PR. Here we add finally add VfioDevice and implement BusDevice and PciDevice traits for it

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.

Combine all previous steps to create a VfioDevice type.
One minor change is the removal of VfioBarMappings wrapper. Instead
just store the vector of VfioBarMapping directly inside VfioDevice and
unmap them in VfioDevice::drop.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Implement emulation for the BAR accesses of the VfioDevice. The
emulation only needs to happen for Msix table/pba, but since they may be
smaller than host page region, the code has to handle full host page
sized regions. If access does not hit any Msix table/pba, it is
forwarded to the device directly.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
Implement emulatino logic for the guest accesses to the configuration
space of the device. Emulation only touches some registers like BARs,
Msix, masked registers. Everything else is forwarded to the device.

Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
@ShadowCurse ShadowCurse self-assigned this Sep 2, 2026
@codecov

codecov Bot commented Sep 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 14.41441% with 285 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.34%. Comparing base (fb33146) to head (c070c7c).
⚠️ Report is 134 commits behind head on feature/vfio.

Files with missing lines Patch % Lines
src/vmm/src/vfio.rs 14.86% 275 Missing ⚠️
src/vmm/src/pci/msix.rs 0.00% 10 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           feature/vfio    #6183      +/-   ##
================================================
- Coverage         82.77%   82.34%   -0.44%     
================================================
  Files               280      280              
  Lines             31413    32114     +701     
================================================
+ Hits              26002    26443     +441     
- Misses             5411     5671     +260     
Flag Coverage Δ
5.10-m5n.metal 82.49% <14.41%> (-0.52%) ⬇️
5.10-m6a.metal 81.85% <14.41%> (-0.52%) ⬇️
5.10-m6g.metal 79.39% <14.41%> (-0.49%) ⬇️
5.10-m6i.metal 82.49% <14.41%> (-0.52%) ⬇️
5.10-m7a.metal-48xl 81.84% <14.41%> (-0.52%) ⬇️
5.10-m7g.metal 79.39% <14.41%> (-0.49%) ⬇️
5.10-m7i.metal-24xl 82.46% <14.41%> (-0.52%) ⬇️
5.10-m7i.metal-48xl 82.47% <14.41%> (-0.52%) ⬇️
5.10-m8g.metal-24xl 79.39% <14.41%> (-0.48%) ⬇️
5.10-m8g.metal-48xl 79.39% <14.41%> (-0.49%) ⬇️
5.10-m8i.metal-48xl 82.47% <14.41%> (-0.51%) ⬇️
5.10-m8i.metal-96xl 82.47% <14.41%> (-0.52%) ⬇️
5.10-m9g.metal-48xl 79.39% <14.41%> (?)
6.1-m5n.metal 82.51% <14.41%> (-0.52%) ⬇️
6.1-m6a.metal 81.88% <14.41%> (-0.52%) ⬇️
6.1-m6g.metal 79.39% <14.41%> (-0.48%) ⬇️
6.1-m6i.metal 82.51% <14.41%> (-0.52%) ⬇️
6.1-m7a.metal-48xl 81.87% <14.41%> (-0.52%) ⬇️
6.1-m7g.metal 79.39% <14.41%> (-0.48%) ⬇️
6.1-m7i.metal-24xl 82.53% <14.41%> (-0.52%) ⬇️
6.1-m7i.metal-48xl 82.53% <14.41%> (-0.52%) ⬇️
6.1-m8g.metal-24xl 79.39% <14.41%> (-0.48%) ⬇️
6.1-m8g.metal-48xl 79.39% <14.41%> (-0.48%) ⬇️
6.1-m8i.metal-48xl 82.53% <14.41%> (-0.52%) ⬇️
6.1-m8i.metal-96xl 82.53% <14.41%> (-0.52%) ⬇️
6.1-m9g.metal-48xl 79.39% <14.41%> (?)
6.18-m5n.metal 82.51% <14.41%> (-0.51%) ⬇️
6.18-m6a.metal 81.88% <14.41%> (-0.52%) ⬇️
6.18-m6g.metal 79.49% <14.41%> (-0.38%) ⬇️
6.18-m6i.metal 82.51% <14.41%> (-0.51%) ⬇️
6.18-m7a.metal-48xl 81.87% <14.41%> (-0.52%) ⬇️
6.18-m7g.metal 79.49% <14.41%> (-0.38%) ⬇️
6.18-m7i.metal-24xl 82.53% <14.41%> (-0.52%) ⬇️
6.18-m7i.metal-48xl 82.53% <14.41%> (-0.51%) ⬇️
6.18-m8g.metal-24xl 79.49% <14.41%> (-0.39%) ⬇️
6.18-m8g.metal-48xl 79.49% <14.41%> (-0.38%) ⬇️
6.18-m8i.metal-48xl 82.53% <14.41%> (-0.52%) ⬇️
6.18-m8i.metal-96xl 82.53% <14.41%> (-0.51%) ⬇️
6.18-m9g.metal-48xl 79.49% <14.41%> (?)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant