Skip to content

Commit c5eea10

Browse files
committed
secret_freedom: Use fixed size bounce buffer for loading kernel
By using a MaybeBounce with N=0 we are allocating a bounce buffer that matches exactly the number of bytes that need to be copied into guest memory, e.g. the size of the kernel file. This is fairly expensive performance wise, and the spike in memory usage from the firecracker process is also unwanted. Thus, just use a 4096 byte fixed size buffer through which we repeatedly read+memcpy. Signed-off-by: Patrick Roy <roypat@amazon.co.uk>
1 parent 12290e4 commit c5eea10

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/vmm/src/builder.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,10 @@ pub fn build_microvm_for_boot(
267267
vmm.vm.set_memory_private().map_err(VmmError::Vm)?;
268268

269269
let entry_point = load_kernel(
270-
MaybeBounce::new(boot_config.kernel_file.try_clone().unwrap(), secret_free),
270+
MaybeBounce::<_, 4096>::new_persistent(
271+
boot_config.kernel_file.try_clone().unwrap(),
272+
secret_free,
273+
),
271274
vmm.vm.guest_memory(),
272275
)?;
273276
let initrd = match &boot_config.initrd_file {
@@ -279,7 +282,7 @@ pub fn build_microvm_for_boot(
279282

280283
Some(InitrdConfig::from_reader(
281284
vmm.vm.guest_memory(),
282-
MaybeBounce::new(initrd_file.as_fd(), secret_free),
285+
MaybeBounce::<_, 4096>::new_persistent(initrd_file.as_fd(), secret_free),
283286
u64_to_usize(size),
284287
)?)
285288
}

0 commit comments

Comments
 (0)