[arch][tests] add a way to query some arch mmu features
Allow asking the arch layer if it supports NX pages or NS pages. Have the arch mmu test code test accordingly. Also tweak the tests to pass on arm32 mmu, which does not precisely match the return semantics of the rest of the mmu routines on map/unmap.
This commit is contained in:
@@ -572,6 +572,9 @@ int arch_mmu_map(arch_aspace_t *aspace, vaddr_t vaddr, paddr_t paddr, uint count
|
||||
|
||||
DEBUG_ASSERT(aspace);
|
||||
|
||||
if (flags & (ARCH_MMU_FLAG_PERM_NO_EXECUTE | ARCH_MMU_FLAG_NS))
|
||||
return ERR_INVALID_ARGS;
|
||||
|
||||
if ((!IS_ALIGNED(paddr, PAGE_SIZE)) || (!IS_ALIGNED(vaddr, PAGE_SIZE)))
|
||||
return ERR_INVALID_ARGS;
|
||||
|
||||
@@ -588,6 +591,9 @@ int arch_mmu_map(arch_aspace_t *aspace, vaddr_t vaddr, paddr_t paddr, uint count
|
||||
return (x86_mmu_map_range(X86_PHYS_TO_VIRT(current_cr3_val), &range, flags));
|
||||
}
|
||||
|
||||
bool arch_mmu_supports_nx_mappings(void) { return false; }
|
||||
bool arch_mmu_supports_ns_mappings(void) { return false; }
|
||||
|
||||
void x86_mmu_early_init(void) {
|
||||
volatile uint32_t cr0;
|
||||
|
||||
|
||||
@@ -654,6 +654,9 @@ int arch_mmu_map(arch_aspace_t *aspace, vaddr_t vaddr, paddr_t paddr, uint count
|
||||
|
||||
LTRACEF("aspace %p, vaddr 0x%lx paddr 0x%lx count %u flags 0x%x\n", aspace, vaddr, paddr, count, flags);
|
||||
|
||||
if (flags & ARCH_MMU_FLAG_NS)
|
||||
return ERR_INVALID_ARGS;
|
||||
|
||||
if ((!x86_mmu_check_paddr(paddr)))
|
||||
return ERR_INVALID_ARGS;
|
||||
|
||||
@@ -673,6 +676,9 @@ int arch_mmu_map(arch_aspace_t *aspace, vaddr_t vaddr, paddr_t paddr, uint count
|
||||
return (x86_mmu_map_range(X86_PHYS_TO_VIRT(current_cr3_val), &range, flags));
|
||||
}
|
||||
|
||||
bool arch_mmu_supports_nx_mappings(void) { return true; }
|
||||
bool arch_mmu_supports_ns_mappings(void) { return false; }
|
||||
|
||||
void x86_mmu_early_init(void) {
|
||||
volatile uint64_t efer_msr, cr0, cr4;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user