From 799d89d70ac35144f7f767c11526243126d9496b Mon Sep 17 00:00:00 2001 From: Nathan Whyte Date: Thu, 20 Apr 2023 11:13:24 -0500 Subject: [PATCH] Replace use of internal syscalls --- src/syscalls/interfaces/uhyve.rs | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/syscalls/interfaces/uhyve.rs b/src/syscalls/interfaces/uhyve.rs index b63542fc8a..435a8eb388 100644 --- a/src/syscalls/interfaces/uhyve.rs +++ b/src/syscalls/interfaces/uhyve.rs @@ -1,3 +1,4 @@ +use alloc::alloc::{alloc, Layout}; use alloc::boxed::Box; use alloc::vec::Vec; use core::mem; @@ -141,10 +142,12 @@ impl SyscallInterface for Uhyve { let mut argv = Box::new(Vec::with_capacity(syscmdsize.argc as usize)); let mut argv_phy = Vec::with_capacity(syscmdsize.argc as usize); for i in 0..syscmdsize.argc as usize { - argv.push( - crate::__sys_malloc(syscmdsize.argsz[i] as usize * mem::size_of::(), 1) - .cast_const(), - ); + let layout = + Layout::from_size_align(syscmdsize.argsz[i] as usize * mem::size_of::(), 1) + .unwrap(); + + argv.push(unsafe { alloc(layout).cast_const() }); + argv_phy.push( paging::virtual_to_physical(VirtAddr(argv[i] as u64)) .unwrap() @@ -156,10 +159,11 @@ impl SyscallInterface for Uhyve { let mut env = Box::new(Vec::with_capacity(syscmdsize.envc as usize + 1)); let mut env_phy = Vec::with_capacity(syscmdsize.envc as usize + 1); for i in 0..syscmdsize.envc as usize { - env.push( - crate::__sys_malloc(syscmdsize.envsz[i] as usize * mem::size_of::(), 1) - .cast_const(), - ); + let layout = + Layout::from_size_align(syscmdsize.envsz[i] as usize * mem::size_of::(), 1) + .unwrap(); + env.push(unsafe { alloc(layout).cast_const() }); + env_phy.push( paging::virtual_to_physical(VirtAddr(env[i] as u64)) .unwrap()