diff --git a/headers/private/kernel/arch/arm/arm_mmu.h b/headers/private/kernel/arch/arm/arm_mmu.h index 192abf9958..a5debe1a38 100644 --- a/headers/private/kernel/arch/arm/arm_mmu.h +++ b/headers/private/kernel/arch/arm/arm_mmu.h @@ -97,7 +97,7 @@ #define ARM_PTE_ADDRESS_MASK 0xfffff000 #define ARM_PTE_TYPE_MASK 0x00000003 -#define ARM_PTE_PROTECTION_MASK 0x00000231 // AP[2:0], XN +#define ARM_PTE_PROTECTION_MASK 0x00000221 // AP[2:1], XN #define ARM_PTE_MEMORY_TYPE_MASK 0x000001cc // TEX, B, C #endif /* _ARCH_ARM_ARM_MMU_H */ diff --git a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp index 933dfb9c41..253bf1cc51 100644 --- a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp +++ b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp @@ -510,6 +510,7 @@ ARMPagingMethod32Bit::PutPageTableEntryInTable(page_table_entry* entry, | ARM_MMU_L2_TYPE_SMALLNEW | MemoryTypeToPageTableEntryFlags(memoryType) | AttributesToPageTableEntryFlags(attributes) + | ARM_MMU_L2_FLAG_AP0 | (globalPage ? 0 : ARM_MMU_L2_FLAG_NG); // put it in the page table diff --git a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.h b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.h index b36462be2c..422f7f2c83 100644 --- a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.h +++ b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.h @@ -146,25 +146,20 @@ ARMPagingMethod32Bit::ClearPageTableEntryFlags(page_table_entry* entry, uint32 f /*static*/ inline uint32 ARMPagingMethod32Bit::AttributesToPageTableEntryFlags(uint32 attributes) { - int apFlags = 0; + int apFlags; - if ((attributes & B_WRITE_AREA) != 0) { - // kernel rw user rw - apFlags = ARM_MMU_L2_FLAG_AP1 | ARM_MMU_L2_FLAG_AP0; - } else if ((attributes & B_READ_AREA) != 0) { - if ((attributes & B_KERNEL_WRITE_AREA) != 0) { - // kernel rw user ro - apFlags = ARM_MMU_L2_FLAG_AP1; - } else { - // kernel ro user ro - apFlags = ARM_MMU_L2_FLAG_AP2 | ARM_MMU_L2_FLAG_AP1; + if ((attributes & B_READ_AREA) != 0) { + // user accessible + apFlags = ARM_MMU_L2_FLAG_AP1; + if ((attributes & B_WRITE_AREA) == 0) { + apFlags |= ARM_MMU_L2_FLAG_AP2; } - } else if ((attributes & B_KERNEL_WRITE_AREA) != 0) { - // kernel rw - apFlags = ARM_MMU_L2_FLAG_AP0; - } else { + } else if ((attributes & B_KERNEL_WRITE_AREA) == 0) { // kernel ro - apFlags = ARM_MMU_L2_FLAG_AP2 | ARM_MMU_L2_FLAG_AP0; + apFlags = ARM_MMU_L2_FLAG_AP2; + } else { + // kernel rw + apFlags = 0; } if (((attributes & B_KERNEL_EXECUTE_AREA) == 0) && @@ -183,23 +178,15 @@ ARMPagingMethod32Bit::PageTableEntryFlagsToAttributes(uint32 pageTableEntry) if ((pageTableEntry & ARM_MMU_L2_FLAG_AP2) == 0) { if ((pageTableEntry & ARM_MMU_L2_FLAG_AP1) != 0) { - if ((pageTableEntry & ARM_MMU_L2_FLAG_AP0) != 0) - attributes = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA; - else - attributes = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA; + attributes = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA; } else { - if ((pageTableEntry & ARM_MMU_L2_FLAG_AP0) != 0) - attributes = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA; - else - attributes = 0; + attributes = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA; } } else { if ((pageTableEntry & ARM_MMU_L2_FLAG_AP1) != 0) attributes = B_KERNEL_READ_AREA | B_READ_AREA; - else if ((pageTableEntry & ARM_MMU_L2_FLAG_AP0) != 0) - attributes = B_KERNEL_READ_AREA; else - attributes = 0; + attributes = B_KERNEL_READ_AREA; } if ((pageTableEntry & ARM_MMU_L2_FLAG_XN) == 0) {