diff --git a/src/vmm/src/vstate/memory.rs b/src/vmm/src/vstate/memory.rs index 52c7f41737f5..ddaada0bd8f0 100644 --- a/src/vmm/src/vstate/memory.rs +++ b/src/vmm/src/vstate/memory.rs @@ -495,40 +495,12 @@ mod tests { use super::*; - fn fork_and_run(function: &dyn Fn(), expect_sigsegv: bool) { - let pid = unsafe { libc::fork() }; - match pid { - 0 => { - function(); - } - child_pid => { - let mut child_status: i32 = -1; - let pid_done = unsafe { libc::waitpid(child_pid, &mut child_status, 0) }; - assert_eq!(pid_done, child_pid); - - if expect_sigsegv { - // Asserts that the child process terminated because - // it received a signal that was not handled. - assert!(libc::WIFSIGNALED(child_status)); - // Signal code should be a SIGSEGV - assert_eq!(libc::WTERMSIG(child_status), libc::SIGSEGV); - } else { - assert!(libc::WIFEXITED(child_status)); - // Signal code should be a SIGSEGV - assert_eq!(libc::WEXITSTATUS(child_status), 0); - } - } - }; - } - fn validate_guard_region(region: &GuestMmapRegion) { let read_mem = |addr| unsafe { std::ptr::read_volatile::(addr) }; let write_mem = |addr, val| unsafe { std::ptr::write(addr, val); }; - let page_size = get_page_size().unwrap(); - // Check that the created range allows us to write inside it let region_first_byte = region.as_ptr(); let region_last_byte = unsafe { region_first_byte.add(region.size() - 1) }; @@ -540,16 +512,6 @@ mod tests { // Write and read from the end of the region write_mem(region_last_byte, 0x69); assert_eq!(read_mem(region_last_byte), 0x69); - - // Try a read/write operation against the left guard border of the range - let left_border_first_byte = unsafe { region_first_byte.sub(page_size) }; - fork_and_run(&|| write_mem(left_border_first_byte, 0x69), true); - fork_and_run(&|| _ = read_mem(left_border_first_byte), true); - - // Try a read/write operation against the right guard border of the range - let right_border_first_byte = unsafe { region_last_byte.add(1) }; - fork_and_run(&|| write_mem(right_border_first_byte, 0x69), true); - fork_and_run(&|| _ = read_mem(right_border_first_byte), true); } #[test]