armv8: Fix MMU table page descriptor
PATCH 1/1 armv8: Fix MMU table page descriptor
Page descriptor uses different format than block descriptor. Both bit 1 and 0 must be set to indicate a valid page.
---
This issue didn't reveal itself unless we use MMU tables down to page size.
arch/arm/cpu/armv8/cache_v8.c | 2 +- arch/arm/include/asm/armv8/mmu.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/cache_v8.c +1 -1
@@ -230,7 +230,7 @@ static void add_map(struct mm_region *map)/* Page fits, create block PTE */ debug ("Setting PTE %p to block virt=%llx\n" , pte, virt); - *pte = phys | attrs; + *pte = phys | attrs | (level ==3 ?PTE_TYPE_PAGE :0 ); virt += blocksize; phys += blocksize; size -= blocksize;
arch/arm/include/asm/armv8/mmu.h +1 -0
@@ -60,6 +60,7 @@#define PTE_TYPE_MASK (3 << 0)#define PTE_TYPE_FAULT (0 << 0)#define PTE_TYPE_TABLE (3 << 0) +#define PTE_TYPE_PAGE (3 << 0)#define PTE_TYPE_BLOCK (1 << 0)#define PTE_TABLE_PXN (1UL << 59)
Signature · 1 line
2.7.4
PATCH 1/1 armv8: Fix MMU table page descriptor
arch/arm/cpu/armv8/cache_v8.c static void add_map(struct mm_region *map) · line 233
Quoted 11 lines · York Sun
Page descriptor uses different format than block descriptor. Both bit 1 and 0 must be set to indicate a valid page.
arch/arm/cpu/armv8/cache_v8.c +1
-1@@ -230,7 +230,7 @@ static void add_map(struct mm_region *map)/* Page fits, create block PTE */ debug ("Setting PTE %p to block virt=%llx\n" , pte, virt); - *pte = phys | attrs; + *pte = phys | attrs | (level ==3 ?PTE_TYPE_PAGE :0 );
The value of attrs already includes PTE_TYPE_BLOCK. Luckily, the bits set in the value of PTE_TYPE_BLOCK is a strict subset of the bits set in the value of PTE_TYPE_PAGE, so this works fine. Still, it might be clearer to explicitly remove PTE_TYPE_BLOCK before adding in PTE_TYPE_PAGE, or simply add a comment explaining why the code is OK as written.
With one of those fixes,