diff --git a/address_space/src/host_mmap.rs b/address_space/src/host_mmap.rs index fa807a80e8b2a306b563e5cca84bf25b05703d06..a8107ba78fcea692ddf1d5daa540dc27f372432f 100644 --- a/address_space/src/host_mmap.rs +++ b/address_space/src/host_mmap.rs @@ -207,8 +207,13 @@ fn touch_pages(start: u64, page_size: u64, nr_pages: u64) { /// * `nr_vcpus` - Number of vcpus. fn mem_prealloc(host_addr: u64, size: u64, nr_vcpus: u8) { trace::trace_scope_start!(pre_alloc, args = (size)); - let page_size = host_page_size(); + let mut page_size = host_page_size(); let threads = max_nr_threads(nr_vcpus); + // If the pagesize of the system is not obtained, we use the granularity + // of 4096 Bytes to allocate memory. + if page_size == 0 { + page_size = 4096; + } let nr_pages = (size + page_size - 1) / page_size; let pages_per_thread = nr_pages / u64::from(threads); let left = nr_pages % u64::from(threads);