feat: detect and diagnose hvisor memory region overlap with root zone#311
Open
Inquisitor-201 wants to merge 2 commits into
Open
feat: detect and diagnose hvisor memory region overlap with root zone#311Inquisitor-201 wants to merge 2 commits into
Inquisitor-201 wants to merge 2 commits into
Conversation
Add two mitigations for the recurring "memory stomping" problem where hvisor's physical memory falls within root zone MEM_TYPE_RAM regions: 1. Compile-time overlap check (tools/check_hv_mem_overlap.py): Post-link script that reads skernel/__hv_end from the ELF, parses ROOT_ZONE_MEMORY_REGIONS from board.rs, and fails the build if any MEM_TYPE_RAM region overlaps hvisor's range. 2. Runtime diagnostic in aarch64 trap handler: When handle_dabt gets a stage-2 fault whose address falls within hvisor's physical memory range [skernel, __hv_end), it prints the actual cause before panicking instead of the generic error. Closes: #310 Related: #309 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
7ffb20e to
4a4ec24
Compare
…8 and riscv64 qemu-plic Split overlapping MEM_TYPE_RAM regions in board.rs to prevent memory stomping where Linux in the root zone would write to pages owned by hvisor (page tables, heap), causing unrecoverable panics. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
c8c8e72 to
5457167
Compare
dallasxy
approved these changes
May 20, 2026
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
The root zone's
ROOT_ZONE_MEMORY_REGIONSoften overlaps with hvisor's own physical memory[skernel, __hv_end). This causes Linux to allocate and write to hvisor's page tables and heap, manifesting as seemingly random "unhandled MMIO fault" panics. This problem has appeared at least 10 times and is tracked in #310.Changes
1. Compile-time overlap check (
tools/check_hv_mem_overlap.py, integrated intomake all)skerneland__hv_endfrom the built ELFROOT_ZONE_MEMORY_REGIONSfromboard.rs(comment-aware)MEM_TYPE_RAMregion overlaps hvisor's range2. Runtime diagnostic (
check_fault_in_hvisor_mem()insrc/arch/aarch64/trap.rs)handle_dabtencounters a stage-2 fault address within[skernel, __hv_end), prints:Testing
Closes: #310
Related: #309