kernel/arm/paging: use simplified permission model

Change-Id: Ie0ed357ee9ca5bee4c10c6cbf74eaba77acdd179
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6435
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: David Karoly <karolyd577@gmail.com>
This commit is contained in:
David Karoly 2023-05-10 20:23:25 +02:00
parent c10c49daf7
commit 84745ade1b
3 changed files with 16 additions and 28 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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) {