Fix running user application with too many arguments

Also fix the VM drop process when creating process failure
This commit is contained in:
Hui, Chunyang 2021-11-03 11:14:06 +00:00 committed by Zongmin.Gu
parent fa69b3d0d1
commit 56569e2b8e
3 changed files with 13 additions and 11 deletions

@ -233,7 +233,12 @@ fn new_process_common(
};
let user_stack_base = vm.get_stack_base();
let user_stack_limit = vm.get_stack_limit();
let user_rsp = init_stack::do_init(user_stack_base, 4096, &argv, envp, &mut auxvec)?;
let init_stack_size = min(
max(vm.get_stack_range().size() >> 8, 4096),
vm.get_stack_range().size(),
); // size in [4096, stack_range], by default 1/256 of stack range
let user_rsp =
init_stack::do_init(user_stack_base, init_stack_size, &argv, envp, &mut auxvec)?;
unsafe {
Task::new(
ldso_entry,

@ -269,15 +269,12 @@ impl Drop for ProcessVM {
//
// For the first case, the process VM is cleaned in the exit procedure and nothing is needed. For the second cases, mem_chunks is not empty and should
// be cleaned here.
mem_chunks
.drain_filter(|chunk| chunk.is_single_vma())
.for_each(|chunk| {
USER_SPACE_VM_MANAGER.internal().munmap_chunk(&chunk, None);
});
// In the first case, the current is reset to idle thread
// In the second case, the current thread belongs to parent process
let current = current!();
if current.tid() != 0 {
mem_chunks
.drain_filter(|chunk| chunk.is_single_vma())
.for_each(|chunk| USER_SPACE_VM_MANAGER.free_chunk(&chunk))
}
assert!(mem_chunks.len() == 0);
info!("Process VM dropped");
}

@ -38,7 +38,7 @@ impl VMManager {
&self.range
}
fn internal(&self) -> SgxMutexGuard<InternalVMManager> {
pub fn internal(&self) -> SgxMutexGuard<InternalVMManager> {
self.internal.lock().unwrap()
}
@ -505,7 +505,7 @@ impl VMManager {
});
mem_chunks.clear();
debug_assert!(mem_chunks.len() == 0);
assert!(mem_chunks.len() == 0);
}
}