From edaaaae8cdaa75bad7e35b06e310b9ef163eb755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Sat, 21 Aug 2010 02:12:25 +0000 Subject: [PATCH] ppc: Implement arch_vm_translation_map_is_kernel_page_accessible() This remedies "Current thread pointer [...] is an address we can't read from." on entering KDL. Closes ticket #6163. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38293 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../arch/ppc/arch_vm_translation_map.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/arch/ppc/arch_vm_translation_map.cpp b/src/system/kernel/arch/ppc/arch_vm_translation_map.cpp index 9a29113b47..3eb31e3a6a 100644 --- a/src/system/kernel/arch/ppc/arch_vm_translation_map.cpp +++ b/src/system/kernel/arch/ppc/arch_vm_translation_map.cpp @@ -887,6 +887,20 @@ bool arch_vm_translation_map_is_kernel_page_accessible(addr_t virtualAddress, uint32 protection) { - // TODO: Implement! - return false; + VMAddressSpace *addressSpace = VMAddressSpace::Kernel(); + + PPCVMTranslationMap* map = static_cast( + addressSpace->TranslationMap()); + + phys_addr_t physicalAddress; + uint32 flags; + if (map->Query(virtualAddress, &physicalAddress, &flags) != B_OK) + return false; + + if ((flags & PAGE_PRESENT) == 0) + return false; + + // present means kernel-readable, so check for writable + return (protection & B_KERNEL_WRITE_AREA) == 0 + || (flags & B_KERNEL_WRITE_AREA) != 0; }