diff --git a/headers/private/kernel/arch/arm/arm_mmu.h b/headers/private/kernel/arch/arm/arm_mmu.h index 39abb00ddf..192abf9958 100644 --- a/headers/private/kernel/arch/arm/arm_mmu.h +++ b/headers/private/kernel/arch/arm/arm_mmu.h @@ -38,6 +38,7 @@ // 31 10 9 8 5 432 10 // | page table address |0| domain |000|01| +#define ARM_MMU_L1_FLAG_PXN 0x00000004 // the domain is not used so and the ? is implementation specified... have not // found it in the cortex A8 reference... so I set t to 0 diff --git a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp index 1d0a52649f..933dfb9c41 100644 --- a/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp +++ b/src/system/kernel/arch/arm/paging/32bit/ARMPagingMethod32Bit.cpp @@ -240,8 +240,7 @@ ARMPagingMethod32Bit::PhysicalPageSlotPool::AllocatePool( int32 index = VADDR_TO_PDENT((addr_t)virtualBase); page_directory_entry* entry = &map->PagingStructures32Bit()->pgdir_virt[index]; - PutPageTableInPageDir(entry, physicalTable, - B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); + PutPageTableInPageDir(entry, physicalTable, ARM_MMU_L1_FLAG_PXN); ARMPagingStructures32Bit::UpdateAllPageDirs(index, *entry); // init the pool structure @@ -400,7 +399,8 @@ ARMPagingMethod32Bit::MapEarly(kernel_args* args, addr_t virtualAddress, // put it in the pgdir e = &fKernelVirtualPageDirectory[index]; - PutPageTableInPageDir(e, pgtable_phys, attributes); + PutPageTableInPageDir(e, pgtable_phys, + (virtualAddress < KERNEL_BASE) ? ARM_MMU_L1_FLAG_PXN : 0); } phys_addr_t ptEntryPhys = fKernelVirtualPageDirectory[index] & ARM_PDE_ADDRESS_MASK; @@ -494,7 +494,7 @@ ARMPagingMethod32Bit::PutPageTableInPageDir(page_directory_entry* entry, { dsb(); - *entry = (pgtablePhysical & ARM_PDE_ADDRESS_MASK) | ARM_MMU_L1_TYPE_COARSE; + *entry = (pgtablePhysical & ARM_PDE_ADDRESS_MASK) | ARM_MMU_L1_TYPE_COARSE | attributes; dsb(); isb(); @@ -549,7 +549,7 @@ ARMPagingMethod32Bit::_EarlyPreparePageTables(page_table_entry* pageTables, page_directory_entry* entry = method->KernelVirtualPageDirectory() + VADDR_TO_PDENT(address) + i; PutPageTableInPageDir(entry, physicalTable, - B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA); + (address < KERNEL_BASE) ? ARM_MMU_L1_FLAG_PXN : 0); } } } diff --git a/src/system/kernel/arch/arm/paging/32bit/ARMVMTranslationMap32Bit.cpp b/src/system/kernel/arch/arm/paging/32bit/ARMVMTranslationMap32Bit.cpp index 577df91399..458200e991 100644 --- a/src/system/kernel/arch/arm/paging/32bit/ARMVMTranslationMap32Bit.cpp +++ b/src/system/kernel/arch/arm/paging/32bit/ARMVMTranslationMap32Bit.cpp @@ -187,9 +187,7 @@ ARMVMTranslationMap32Bit::Map(addr_t va, phys_addr_t pa, uint32 attributes, // put it in the pgdir ARMPagingMethod32Bit::PutPageTableInPageDir(&pd[index], pgtable, - attributes - | ((attributes & B_USER_PROTECTION) != 0 - ? B_WRITE_AREA : B_KERNEL_WRITE_AREA)); + (va < KERNEL_BASE) ? ARM_MMU_L1_FLAG_PXN : 0); // update any other page directories, if it maps kernel space if (index >= FIRST_KERNEL_PGDIR_ENT