diff --git a/src/arch/x86_64/mm/physicalmem.rs b/src/arch/x86_64/mm/physicalmem.rs index b9a61312be..01e80a64e8 100644 --- a/src/arch/x86_64/mm/physicalmem.rs +++ b/src/arch/x86_64/mm/physicalmem.rs @@ -108,6 +108,8 @@ fn detect_from_limits() -> Result<(), ()> { return Err(()); } + let total_memory; + // add gap for the APIC if limit > KVM_32BIT_GAP_START { let entry = FreeListEntry::new(mm::kernel_end_address().as_usize(), KVM_32BIT_GAP_START); @@ -115,16 +117,18 @@ fn detect_from_limits() -> Result<(), ()> { if limit > KVM_32BIT_GAP_START + KVM_32BIT_GAP_SIZE { let entry = FreeListEntry::new(KVM_32BIT_GAP_START + KVM_32BIT_GAP_SIZE, limit); PHYSICAL_FREE_LIST.lock().push(entry); - TOTAL_MEMORY.store(limit - KVM_32BIT_GAP_SIZE, Ordering::Relaxed); + total_memory = limit - KVM_32BIT_GAP_SIZE; } else { - TOTAL_MEMORY.store(KVM_32BIT_GAP_START, Ordering::Relaxed); + total_memory = KVM_32BIT_GAP_START; } } else { let entry = FreeListEntry::new(mm::kernel_end_address().as_usize(), limit); PHYSICAL_FREE_LIST.lock().push(entry); - TOTAL_MEMORY.store(limit, Ordering::Relaxed); + total_memory = limit; } + TOTAL_MEMORY.store(total_memory, Ordering::Relaxed); + Ok(()) }