From 61d2b06c401da76573c7fdace35d5a87b728ed8f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sat, 12 Jun 2010 15:11:53 +0000 Subject: [PATCH] Use PAE only when there's memory beyond the 4G limit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37115 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../arch/x86/arch_vm_translation_map.cpp | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/system/kernel/arch/x86/arch_vm_translation_map.cpp b/src/system/kernel/arch/x86/arch_vm_translation_map.cpp index fff6230906..e46df82117 100644 --- a/src/system/kernel/arch/x86/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/x86/arch_vm_translation_map.cpp @@ -73,12 +73,28 @@ arch_vm_translation_map_init(kernel_args *args, #endif #if B_HAIKU_PHYSICAL_BITS == 64 - if (x86_check_feature(IA32_FEATURE_PAE, FEATURE_COMMON) - /* TODO: && if needed */) { + bool paeAvailable = x86_check_feature(IA32_FEATURE_PAE, FEATURE_COMMON); + bool paeNeeded = false; + for (uint32 i = 0; i < args->num_physical_memory_ranges; i++) { + phys_addr_t end = args->physical_memory_range[i].start + + args->physical_memory_range[i].size; + if (end > 0x100000000LL) { + paeNeeded = true; + break; + } + } + + if (paeAvailable && paeNeeded) { + dprintf("using PAE paging\n"); gX86PagingMethod = new(&sPagingMethodBuffer) X86PagingMethodPAE; - } else -#endif + } else { + dprintf("using 32 bit paging (PAE not %s)\n", + paeNeeded ? "available" : "needed"); gX86PagingMethod = new(&sPagingMethodBuffer) X86PagingMethod32Bit; + } +#else + gX86PagingMethod = new(&sPagingMethodBuffer) X86PagingMethod32Bit; +#endif return gX86PagingMethod->Init(args, _physicalPageMapper); }