mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-16 06:07:15 +00:00
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 <chen.bo@intel.com>
This commit is contained in:
parent
1b58c63734
commit
7b31871a36
@ -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;
|
const QUEUE_DATA_SIZE: usize = 4;
|
||||||
// The size of the guest memory for the virtio-mem region
|
// The size of the guest memory for the virtio-mem region
|
||||||
const MEM_SIZE: usize = 128 * 1024 * 1024;
|
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
|
// Create a dummy virtio-mem device for fuzzing purpose only
|
||||||
fn create_dummy_virtio_mem(bytes: &[u8; VIRTIO_MEM_DATA_SIZE]) -> (Mem, Arc<GuestRegionMmap>) {
|
fn create_dummy_virtio_mem(bytes: &[u8; VIRTIO_MEM_DATA_SIZE]) -> (Mem, Arc<GuestRegionMmap>) {
|
||||||
let hugepages = bytes[0] % 2 != 0;
|
let numa_id = if bytes[0] % 2 != 0 { Some(0) } else { None };
|
||||||
let numa_id = if bytes[1] % 2 != 0 { Some(0) } else { None };
|
|
||||||
|
|
||||||
let region = vmm::memory_manager::MemoryManager::create_ram_region(
|
let region = vmm::memory_manager::MemoryManager::create_ram_region(
|
||||||
&None,
|
&None,
|
||||||
@ -134,7 +133,7 @@ fn create_dummy_virtio_mem(bytes: &[u8; VIRTIO_MEM_DATA_SIZE]) -> (Mem, Arc<Gues
|
|||||||
MEM_SIZE,
|
MEM_SIZE,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
hugepages,
|
false,
|
||||||
None,
|
None,
|
||||||
numa_id,
|
numa_id,
|
||||||
None,
|
None,
|
||||||
@ -150,7 +149,7 @@ fn create_dummy_virtio_mem(bytes: &[u8; VIRTIO_MEM_DATA_SIZE]) -> (Mem, Arc<Gues
|
|||||||
SeccompAction::Allow,
|
SeccompAction::Allow,
|
||||||
numa_id.map(|i| i as u16),
|
numa_id.map(|i| i as u16),
|
||||||
0,
|
0,
|
||||||
hugepages,
|
false,
|
||||||
EventFd::new(EFD_NONBLOCK).unwrap(),
|
EventFd::new(EFD_NONBLOCK).unwrap(),
|
||||||
blocks_state.clone(),
|
blocks_state.clone(),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user