diff --git a/src/arch/x86_64/mm/physicalmem.rs b/src/arch/x86_64/mm/physicalmem.rs index 11c6ff94f8..2b6a8b86a0 100644 --- a/src/arch/x86_64/mm/physicalmem.rs +++ b/src/arch/x86_64/mm/physicalmem.rs @@ -8,8 +8,8 @@ use multiboot::information::{MemoryType, Multiboot}; use crate::arch::x86_64::kernel::{get_fdt, get_limit, get_mbinfo}; use crate::arch::x86_64::mm::paging::{BasePageSize, PageSize}; use crate::arch::x86_64::mm::{MultibootMemory, PhysAddr, VirtAddr}; -use crate::mm; use crate::mm::freelist::{FreeList, FreeListEntry}; +use crate::{env, mm}; static PHYSICAL_FREE_LIST: InterruptTicketMutex = InterruptTicketMutex::new(FreeList::new()); @@ -102,12 +102,13 @@ fn detect_from_multiboot_info() -> Result<(), ()> { Ok(()) } -fn detect_from_limits() -> Result<(), ()> { - let limit = get_limit(); - if limit == 0 { +fn detect_from_uhyve() -> Result<(), ()> { + if !env::is_uhyve() { return Err(()); } + let limit = get_limit(); + assert_ne!(limit, 0); let mut free_list = PHYSICAL_FREE_LIST.lock(); let total_memory; @@ -136,7 +137,7 @@ fn detect_from_limits() -> Result<(), ()> { pub fn init() { detect_from_fdt() .or_else(|_e| detect_from_multiboot_info()) - .or_else(|_e| detect_from_limits()) + .or_else(|_e| detect_from_uhyve()) .unwrap(); }