Repository navigation
Conversation
Only the first byte of the buffer was translated and the rest was accessed at physical + i. A buffer crossing a page boundary is not physically contiguous unless the guest is identity-mapped, so its tail was written into an unrelated physical page. StartInfo now holds (physical address, length) pieces. A size variable that crosses into a non-contiguous page is rejected at start. Fixes intel#487
Wenzel
force-pushed
the
fix/testcase-buffer-page-cross-487
branch
from
November 24, 2026 21:38
8bf5ba1 to
ee23a31
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
At the start harness only the first byte of the testcase buffer was translated to a physical address. Every later read and write used
physical + i. A buffer that crosses a page boundary is not physically contiguous unless the guest is identity-mapped, so its tail was written into an unrelated physical page and the target never saw it.The three magic start variants and the manual start now share
translate_rangeandstart_info, which is why the diff ofsrc/arch/mod.rsremoves more than it adds.A size variable that crosses into a page that is not physically adjacent is rejected with an error at start, not split.
One integration test,
x86_64_magic_page_cross_latest, with a new targettests/rsrc/x86_64-uefi/test-page-cross.c.Fixes #487
Evidence
UEFI is identity-mapped, so the target builds its own page tables: a two-page window whose pages map to physical frames 0 and 2 of a static array. The buffer starts 8 bytes before the end of the first page. Frame 1, which follows the first page in physical memory but is not part of the buffer, holds a canary.
It prints
NEIGHBOUR_CLOBBEREDwhen the canary changed andTAIL_WRITTENwhen testcase bytes reached frame 2. Linux, QSP x86-64, 20 iterations, number of lines in the output:main(ed67e1c)NEIGHBOUR_CLOBBERED16,TAIL_WRITTEN0 (test FAILED)NEIGHBOUR_CLOBBERED0,TAIL_WRITTEN14 (test ok)NEIGHBOUR_CLOBBERED16,TAIL_WRITTEN0NEIGHBOUR_CLOBBERED0,TAIL_WRITTEN14Iterations that print neither had a testcase of 8 bytes or less.
On Simics 7 the test runs through
cargo test. On Simics 6 the same test script was run by hand in a project with the module built withSIMICS_BASE=simics-6.0.185, as the test harness here only knows the Simics 7 install.On this branch: lib unit tests 48 passed, 1 ignored.
cargo clippy -ris clean.Not run: the manual start path, architectures other than x86-64, a Linux or Windows guest, the rest of the integration suite.
Merge Danger
Door: two-way
Blast Radius: moderate
Every start harness and manual start goes through the rewritten code, on all architectures. For an identity-mapped buffer the result is one piece, the same addresses as before.
The page step is fixed at 4 KiB, the smallest page size of the supported architectures. Larger pages cost extra translations at start, not correctness.
A buffer whose later pages are not mapped is now an error at start. Before, the bytes were written to whatever followed the first page.
🤖 Generated with Claude Code