From 6dee6653c26736f534abdda6886219ab56503533 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 18 Sep 2013 00:37:51 +0200 Subject: [PATCH] When switching to PAE don't copy not needed PTEs Now we check whether the virtual address corresponding to the PTE lies in an allocated virtual address range. This fixes a cause of #8345: The assertion would trigger when such an entry was encountered. There might be other causes that trigger the same assertion, though. --- .../arch/x86/paging/pae/X86PagingMethodPAE.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp index 6e1da996c2..e4ee9bccb0 100644 --- a/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp +++ b/src/system/kernel/arch/x86/paging/pae/X86PagingMethodPAE.cpp @@ -195,7 +195,8 @@ private: pae_page_table_entry* paeEntry = paeTable; for (uint32 i = 0; i < kPAEPageTableEntryCount; i++, entry++, paeEntry++) { - if ((*entry & X86_PTE_PRESENT) != 0) { + if ((*entry & X86_PTE_PRESENT) != 0 + && _IsVirtualAddressAllocated(virtualBase + i * B_PAGE_SIZE)) { // Note, we use the fact that the PAE flags are defined to the // same values. *paeEntry = *entry & (X86_PTE_PRESENT @@ -311,6 +312,20 @@ private: return page; } + bool _IsVirtualAddressAllocated(addr_t address) const + { + for (uint32 i = 0; i < fKernelArgs->num_virtual_allocated_ranges; i++) { + addr_t start = fKernelArgs->virtual_allocated_range[i].start; + addr_t end = start + fKernelArgs->virtual_allocated_range[i].size; + if (address < start) + return false; + if (address <= end - 1) + return true; + } + + return false; + } + private: kernel_args* fKernelArgs; page_table_entry* fPageHole;