kernel/arm/paging: use simplified permission model
Change-Id: Ie0ed357ee9ca5bee4c10c6cbf74eaba77acdd179 Reviewed-on: https://review.haiku-os.org/c/haiku/+/6435 Reviewed-by: Fredrik Holmqvist <[email protected]> Tested-by: Commit checker robot <[email protected]> Reviewed-by: David Karoly <[email protected]>
This commit is contained in:
@@ -97,7 +97,7 @@
|
|||||||
#define ARM_PTE_ADDRESS_MASK 0xfffff000
|
#define ARM_PTE_ADDRESS_MASK 0xfffff000
|
||||||
#define ARM_PTE_TYPE_MASK 0x00000003
|
#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
|
#define ARM_PTE_MEMORY_TYPE_MASK 0x000001cc // TEX, B, C
|
||||||
|
|
||||||
#endif /* _ARCH_ARM_ARM_MMU_H */
|
#endif /* _ARCH_ARM_ARM_MMU_H */
|
||||||
|
|||||||
@@ -510,6 +510,7 @@ ARMPagingMethod32Bit::PutPageTableEntryInTable(page_table_entry* entry,
|
|||||||
| ARM_MMU_L2_TYPE_SMALLNEW
|
| ARM_MMU_L2_TYPE_SMALLNEW
|
||||||
| MemoryTypeToPageTableEntryFlags(memoryType)
|
| MemoryTypeToPageTableEntryFlags(memoryType)
|
||||||
| AttributesToPageTableEntryFlags(attributes)
|
| AttributesToPageTableEntryFlags(attributes)
|
||||||
|
| ARM_MMU_L2_FLAG_AP0
|
||||||
| (globalPage ? 0 : ARM_MMU_L2_FLAG_NG);
|
| (globalPage ? 0 : ARM_MMU_L2_FLAG_NG);
|
||||||
|
|
||||||
// put it in the page table
|
// put it in the page table
|
||||||
|
|||||||
@@ -146,25 +146,20 @@ ARMPagingMethod32Bit::ClearPageTableEntryFlags(page_table_entry* entry, uint32 f
|
|||||||
/*static*/ inline uint32
|
/*static*/ inline uint32
|
||||||
ARMPagingMethod32Bit::AttributesToPageTableEntryFlags(uint32 attributes)
|
ARMPagingMethod32Bit::AttributesToPageTableEntryFlags(uint32 attributes)
|
||||||
{
|
{
|
||||||
int apFlags = 0;
|
int apFlags;
|
||||||
|
|
||||||
if ((attributes & B_WRITE_AREA) != 0) {
|
if ((attributes & B_READ_AREA) != 0) {
|
||||||
// kernel rw user rw
|
// user accessible
|
||||||
apFlags = ARM_MMU_L2_FLAG_AP1 | ARM_MMU_L2_FLAG_AP0;
|
apFlags = ARM_MMU_L2_FLAG_AP1;
|
||||||
} else if ((attributes & B_READ_AREA) != 0) {
|
if ((attributes & B_WRITE_AREA) == 0) {
|
||||||
if ((attributes & B_KERNEL_WRITE_AREA) != 0) {
|
apFlags |= ARM_MMU_L2_FLAG_AP2;
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
} else if ((attributes & B_KERNEL_WRITE_AREA) != 0) {
|
} else if ((attributes & B_KERNEL_WRITE_AREA) == 0) {
|
||||||
// kernel rw
|
|
||||||
apFlags = ARM_MMU_L2_FLAG_AP0;
|
|
||||||
} else {
|
|
||||||
// kernel ro
|
// 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) &&
|
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_AP2) == 0) {
|
||||||
if ((pageTableEntry & ARM_MMU_L2_FLAG_AP1) != 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;
|
||||||
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;
|
|
||||||
} else {
|
} else {
|
||||||
if ((pageTableEntry & ARM_MMU_L2_FLAG_AP0) != 0)
|
attributes = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA;
|
||||||
attributes = B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA;
|
|
||||||
else
|
|
||||||
attributes = 0;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((pageTableEntry & ARM_MMU_L2_FLAG_AP1) != 0)
|
if ((pageTableEntry & ARM_MMU_L2_FLAG_AP1) != 0)
|
||||||
attributes = B_KERNEL_READ_AREA | B_READ_AREA;
|
attributes = B_KERNEL_READ_AREA | B_READ_AREA;
|
||||||
else if ((pageTableEntry & ARM_MMU_L2_FLAG_AP0) != 0)
|
|
||||||
attributes = B_KERNEL_READ_AREA;
|
|
||||||
else
|
else
|
||||||
attributes = 0;
|
attributes = B_KERNEL_READ_AREA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pageTableEntry & ARM_MMU_L2_FLAG_XN) == 0) {
|
if ((pageTableEntry & ARM_MMU_L2_FLAG_XN) == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user