Skip to content

Commit 96021d9

Browse files
authored
fix: move INITRD_MAP_BASE past LAPIC MMIO region (#94)
* fix: move INITRD_MAP_BASE past LAPIC MMIO region Signed-off-by: danbugs <danilochiarlone@gmail.com> * fix: update doc comment to reflect new INITRD_MAP_BASE address Signed-off-by: danbugs <danilochiarlone@gmail.com> * fix: bump ILCompiler to 9.0.17 to match SDK 9.0-alpine Signed-off-by: danbugs <danilochiarlone@gmail.com> --------- Signed-off-by: danbugs <danilochiarlone@gmail.com>
1 parent 414bd2a commit 96021d9

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

examples/dotnet-nativeaot/HelloNativeAot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
<InvariantGlobalization>true</InvariantGlobalization>
88
</PropertyGroup>
99
<ItemGroup>
10-
<PackageReference Include="runtime.linux-musl-x64.Microsoft.DotNet.ILCompiler" Version="9.0.16" />
10+
<PackageReference Include="runtime.linux-musl-x64.Microsoft.DotNet.ILCompiler" Version="9.0.17" />
1111
</ItemGroup>
1212
</Project>

host/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,9 +2282,11 @@ impl Sandbox {
22822282
let mut usbox = UninitializedSandbox::new(env, Some(config.sandbox_config()))?;
22832283

22842284
// Map the initrd file (zero-copy via mmap)
2285-
// Place at 3 GiB — high enough to not overlap any reasonable
2286-
// primary shared memory region, within the 4 GiB identity map.
2287-
const INITRD_MAP_BASE: u64 = 0xC000_0000; // 3 GiB
2285+
// Place past the x86 LAPIC MMIO page (0xFEE0_0000) so that
2286+
// large initrds (>1 GiB) don't overlap it and trigger EEXIST
2287+
// from KVM_SET_USER_MEMORY_REGION on kernels where in-kernel
2288+
// IRQCHIP reserves that range.
2289+
const INITRD_MAP_BASE: u64 = 0xFEF0_0000;
22882290
if let Some(path) = initrd_path {
22892291
usbox.map_file_cow(path, INITRD_MAP_BASE, Some("initrd"))?;
22902292
}
@@ -2467,7 +2469,7 @@ impl Sandbox {
24672469
}
24682470

24692471
/// Load a snapshot with an initrd file re-mapped at the standard
2470-
/// guest VA (0xC000_0000). Required when the snapshot was taken
2472+
/// guest VA (0xFEF0_0000). Required when the snapshot was taken
24712473
/// from a cpiovfs-backed guest whose VFS nodes point into the
24722474
/// initrd region.
24732475
pub fn from_snapshot_file_with_initrd<P: AsRef<Path>, I: AsRef<Path>>(
@@ -2527,7 +2529,7 @@ impl Sandbox {
25272529

25282530
let mut inner = MultiUseSandbox::from_snapshot(arc.clone(), host_funcs, None)?;
25292531

2530-
const INITRD_MAP_BASE: u64 = 0xC000_0000;
2532+
const INITRD_MAP_BASE: u64 = 0xFEF0_0000;
25312533
if let Some(ref initrd_path) = initrd {
25322534
inner.map_file_cow(initrd_path, INITRD_MAP_BASE, Some("initrd"))?;
25332535
}

0 commit comments

Comments
 (0)