From 7b31871a364090f8edfe53abf51458985db0d5b3 Mon Sep 17 00:00:00 2001 From: Bo Chen Date: Mon, 17 Oct 2022 18:22:31 -0700 Subject: [PATCH] fuzz: mem: Avoid using hugepages The kernel will trigger a SIGBUS upon hugetlb page faults when there is no huge pages available. We neither have a way to ensure enough huge pages available on the host system, nor have a way to gracefully report the lack of huge pages in advance from Cloud Hypervisor. For these reasons, we have to avoid using huge pages from the virtio-mem fuzzer to avoid SIGBUS errors. Signed-off-by: Bo Chen --- fuzz/fuzz_targets/mem.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/fuzz/fuzz_targets/mem.rs b/fuzz/fuzz_targets/mem.rs index 7e47b00c9..c53bd3eb8 100644 --- a/fuzz/fuzz_targets/mem.rs +++ b/fuzz/fuzz_targets/mem.rs @@ -22,7 +22,7 @@ macro_rules! align { }}; } -const VIRTIO_MEM_DATA_SIZE: usize = 2; +const VIRTIO_MEM_DATA_SIZE: usize = 1; const QUEUE_DATA_SIZE: usize = 4; // The size of the guest memory for the virtio-mem region const MEM_SIZE: usize = 128 * 1024 * 1024; @@ -124,8 +124,7 @@ impl VirtioInterrupt for NoopVirtioInterrupt { // Create a dummy virtio-mem device for fuzzing purpose only fn create_dummy_virtio_mem(bytes: &[u8; VIRTIO_MEM_DATA_SIZE]) -> (Mem, Arc) { - let hugepages = bytes[0] % 2 != 0; - let numa_id = if bytes[1] % 2 != 0 { Some(0) } else { None }; + let numa_id = if bytes[0] % 2 != 0 { Some(0) } else { None }; let region = vmm::memory_manager::MemoryManager::create_ram_region( &None, @@ -134,7 +133,7 @@ fn create_dummy_virtio_mem(bytes: &[u8; VIRTIO_MEM_DATA_SIZE]) -> (Mem, Arc (Mem, Arc