fix: move INITRD_MAP_BASE past LAPIC MMIO region - #94
Merged
Conversation
Signed-off-by: danbugs <danilochiarlone@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts the host-side initrd guest mapping base address to avoid overlapping the x86 LAPIC MMIO region, which can cause KVM_SET_USER_MEMORY_REGION to fail with EEXIST when mapping very large initrds.
Changes:
- Move
INITRD_MAP_BASEfrom0xC000_0000to0xFEF0_0000for zero-copy initrd mapping inSandbox::evolve_mapped. - Move
INITRD_MAP_BASEfrom0xC000_0000to0xFEF0_0000for initrd re-mapping when restoring from snapshot (from_snapshot_file_fullinitrd path). - Add an explanatory comment describing the LAPIC overlap failure mode and why the new address is chosen.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+2532
to
2535
| const INITRD_MAP_BASE: u64 = 0xFEF0_0000; | ||
| if let Some(ref initrd_path) = initrd { | ||
| inner.map_file_cow(initrd_path, INITRD_MAP_BASE, Some("initrd"))?; | ||
| } |
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Signed-off-by: danbugs <danilochiarlone@gmail.com>
Contributor
There was a problem hiding this comment.
Linux Benchmarks
Details
| Benchmark suite | Current: e06d5b6 | Previous: f51e9da | Ratio |
|---|---|---|---|
hello_world (median) |
20 ms |
20 ms |
1 |
pandas (median) |
90 ms |
110 ms |
0.82 |
density (per VM) |
12 MB |
11 MB |
1.09 |
snapshot (disk) |
656 MiB |
656 MiB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
Contributor
There was a problem hiding this comment.
Windows Benchmarks
Details
| Benchmark suite | Current: e06d5b6 | Previous: f51e9da | Ratio |
|---|---|---|---|
hello_world (median) |
345 ms |
294 ms |
1.17 |
pandas (median) |
978 ms |
749 ms |
1.31 |
density (per VM) |
656 MB |
656 MB |
1 |
snapshot (disk) |
664 MiB |
664 MiB |
1 |
This comment was automatically generated by workflow using github-action-benchmark.
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
INITRD_MAP_BASEconstants from0xC000_0000(3 GiB) to0xFEF0_0000(just past the LAPIC MMIO page at0xFEE0_0000)When the initrd exceeds ~1 GiB (as it does in v0.9.0's python-agent-driver), the mapping at
0xC000_0000spans the LAPIC MMIO region at0xFEE0_0000. On kernels whereKVM_CREATE_IRQCHIPreserves that range,KVM_SET_USER_MEMORY_REGIONrejects the mapping withEEXIST.The corresponding guest-side constant in Unikraft is updated in unikraft/unikraft#1850.
Fixes: microsoft/mxc#525
Test plan
kraft-hyperlight buildpydriver-runwith the patched kernel + host against a ~1.07 GiB initrdstracethat the initrd slot maps atguest_phys_addr=0xfef00000(past the LAPIC)