Skip to content

fix(virtio): respect PAGE_POISON in balloon config and free page reporting - #542

Merged
Lencerf merged 1 commit into
google:mainfrom
Lencerf:fix/balloon-page-poison
Dec 2, 2026
Merged

Lencerf merged 1 commit into
google:mainfrom
Lencerf:fix/balloon-page-poison

Conversation

@Lencerf

@Lencerf Lencerf commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Support 32-bit aligned driver writes to BalloonConfig::poison_val alongside BalloonConfig::actual via BalloonConfig::LAYOUT_POISON_VAL, while continuing to reject writes to read-only fields (num_pages, free_page_hint_cmd_id), sub-word or unaligned accesses, invalid access widths, and out-of-bounds offsets.
  • Track negotiated BalloonFeature bits on Balloon during VirtioMio::activate, and clear driver_feature, actual, and poison_val on VirtioMio::reset.
  • Respect Virtio v1.4 Sec 5.5.6.6 (Free Page Reporting) when VIRTIO_BALLOON_F_PAGE_POISON is negotiated: skip madvise(..., MADV_DONTNEED) when poison_val != 0 so reported free pages are not overwritten with zeroes, while continuing to reclaim reported pages when PAGE_POISON is not negotiated or poison_val == 0.
  • Add unit tests in alioth/src/virtio/dev/balloon_test.rs covering BalloonConfigMmio read/write validation, free_reporting under all PAGE_POISON / poison_val combinations, and device reset + re-activation on both 4 KiB and 16 KiB page hosts.

Verification

  • cargo +nightly fmt --check
  • cargo test -p alioth virtio::dev::balloon
  • cargo clippy --all-targets -- -D warnings
  • cargo clippy --all-targets --target x86_64-unknown-linux-gnu -- -D warnings

@coveralls

coveralls commented Nov 11, 2026 •

Copy link
Copy Markdown

Coverage Report for CI Build 46822394635

Coverage increased (+0.7%) to 47.522%

Details

  • Coverage increased (+0.7%) from the base build.
  • Patch coverage: 2 uncovered changes across 1 file (32 of 34 lines covered, 94.12%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
alioth/src/virtio/dev/balloon.rs 34 32 94.12%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 17083
Covered Lines: 7900
Line Coverage: 46.24%
Relevant Branches: 1988
Covered Branches: 1163
Branch Coverage: 58.5%
Branches in Coverage %: Yes
Coverage Strength: 964.43 hits per line

💛 - Coveralls

@Lencerf
Lencerf force-pushed the fix/balloon-page-poison branch from 4e2b04e to 973e6d5 Compare December 2, 2026 06:05
…rting

VIRTIO_BALLOON_F_PAGE_POISON is offered by the balloon device, so the
guest may write `poison_val` in the device configuration space and
expect reported free pages to retain that value (Virtio v1.4 Sec
5.5.6.6). Previously, writes to `poison_val` were rejected and free page
reporting unconditionally discarded pages, overwriting non-zero poison
patterns with zeroes.

Allow driver writes to `poison_val`, reset driver-written state on
device reset, and keep reported free pages intact when PAGE_POISON is
negotiated with a non-zero `poison_val`.

Signed-off-by: Changyuan Lyu <changyuanl@google.com>
@Lencerf
Lencerf force-pushed the fix/balloon-page-poison branch from 973e6d5 to 6f04440 Compare December 2, 2026 06:09
@Lencerf
Lencerf added this pull request to the merge queue Dec 2, 2026
Merged via the queue into google:main with commit 2bc6c70 Dec 2, 2026
20 checks passed
@Lencerf
Lencerf deleted the fix/balloon-page-poison branch December 2, 2026 06:23
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.

2 participants