Skip to content

[SH] use UFFDIO_COPY to resolve UFFD faults#5734

Open
kalyazin wants to merge 4 commits intofirecracker-microvm:feature/secret-hidingfrom
kalyazin:int_sh_2026-02-20_mike_uffd
Open

[SH] use UFFDIO_COPY to resolve UFFD faults#5734
kalyazin wants to merge 4 commits intofirecracker-microvm:feature/secret-hidingfrom
kalyazin:int_sh_2026-02-20_mike_uffd

Conversation

@kalyazin
Copy link
Contributor

@kalyazin kalyazin commented Mar 4, 2026

Changes

  • Register RegisterMode::MISSING in Firecracker
  • Update on-demand and fault-all handlers to use UFFDIO_COPY
  • Skip test_cache_topology temporarily on ARM due to changes in guest cache topology sysfs files

Reason

  • Migrate from UFFDIO_CONTINUE to UFFDIO_COPY for handling major faults

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.

kalyazin added 4 commits March 4, 2026 16:40
This is because guest_memfd now supports both modes.
We still need minor handling in case prepopulation logic adds a page in
the page cache and the VMM accesses it later via user mappings.

Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com>
Now that guest_memfd has support for major faults, we can resolve all
on-demand user mapping faults with UFFDIO_COPY.  Remove the code that
uses memcpy memory population.

Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com>
With adding major fault support in guest_memfd, when a major fault is
generated, no page is added in the page cache by the kernel.  It means
that proactive population with write() will succeed for the entire
region but possibly one page (kvmclock on x86).  We just need to call
UFFDIO_CONTINUE in response to such a major fault because we already
populated the faulting page via write() earlier.

Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com>
This is because when upgrading the guest kernel from 6.1.155 to 6.1.163,
/sys/devices/system/cpu/cpu?/cache/* files disappeared.

Signed-off-by: Nikita Kalyazin <kalyazin@amazon.com>
@kalyazin kalyazin changed the title [SH] use UFFDIO_COPY to respond to resolve UFFD faults [SH] use UFFDIO_COPY to resolve UFFD faults Mar 4, 2026
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.00%. Comparing base (b73c0f9) to head (71da6fa).

Files with missing lines Patch % Lines
src/vmm/src/persist.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           feature/secret-hiding    #5734      +/-   ##
=========================================================
- Coverage                  82.04%   82.00%   -0.04%     
=========================================================
  Files                        277      277              
  Lines                      30092    30093       +1     
=========================================================
- Hits                       24688    24677      -11     
- Misses                      5404     5416      +12     
Flag Coverage Δ
5.10-m5n.metal 82.16% <0.00%> (-0.06%) ⬇️
5.10-m6a.metal 81.47% <0.00%> (-0.01%) ⬇️
5.10-m6g.metal 79.04% <0.00%> (-0.01%) ⬇️
5.10-m6i.metal 82.17% <0.00%> (+<0.01%) ⬆️
5.10-m7a.metal-48xl 81.46% <0.00%> (-0.01%) ⬇️
5.10-m7g.metal 79.04% <0.00%> (?)
5.10-m7i.metal-24xl 82.14% <0.00%> (?)
5.10-m7i.metal-48xl ?
5.10-m8g.metal-24xl ?
5.10-m8g.metal-48xl 79.03% <0.00%> (-0.01%) ⬇️
6.1-m5n.metal 82.20% <0.00%> (+<0.01%) ⬆️
6.1-m6a.metal 81.50% <0.00%> (-0.02%) ⬇️
6.1-m6g.metal 79.03% <0.00%> (-0.01%) ⬇️
6.1-m6i.metal 82.19% <0.00%> (-0.02%) ⬇️
6.1-m7a.metal-48xl ?
6.1-m7g.metal 79.04% <0.00%> (-0.01%) ⬇️
6.1-m7i.metal-24xl 82.20% <0.00%> (-0.06%) ⬇️
6.1-m7i.metal-48xl 82.20% <0.00%> (-0.01%) ⬇️
6.1-m8g.metal-24xl 79.03% <0.00%> (-0.01%) ⬇️
6.18-m5n.metal 82.19% <0.00%> (-0.01%) ⬇️
6.18-m6a.metal 81.50% <0.00%> (+<0.01%) ⬆️
6.18-m6g.metal 79.03% <0.00%> (-0.01%) ⬇️
6.18-m6i.metal 82.19% <0.00%> (-0.02%) ⬇️
6.18-m7a.metal-48xl 81.49% <0.00%> (-0.01%) ⬇️
6.18-m7g.metal ?
6.18-m7i.metal-24xl 82.21% <0.00%> (-0.01%) ⬇️
6.18-m7i.metal-48xl 82.20% <0.00%> (-0.02%) ⬇️
6.18-m8g.metal-24xl ?
6.18-m8g.metal-48xl 79.03% <0.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 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