Skip to contentSkip to conversation

armv8: mmu: fix page table mapping

PATCH In review Peng Fan 3 participants 3 messages Nov 28, 2017 – Dec 4, 2017 Arm (32-bit)

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH 1/1 armv8: mmu: fix page table mapping

To page mapping the lowest 2 bits needs to be 0x3.
If not fix this, the final lowest 3 bits for page mapping is 0x1 which is marked as reserved.

---
 arch/arm/cpu/armv8/cache_v8.c    | 5 ++++-
 arch/arm/include/asm/armv8/mmu.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/cache_v8.c +4 -1
index adc7e1746f..6548f3c912 100644
@@ -230,7 +230,10 @@ 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;
+				if (level == 3)
+					*pte = phys | attrs | PTE_TYPE_PAGE;
+				else
+					*pte = phys | attrs;
 				virt += blocksize;
 				phys += blocksize;
 				size -= blocksize;
arch/arm/include/asm/armv8/mmu.h +1 -0
index 6121aab547..765914c7e2 100644
@@ -43,6 +43,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_TYPE_VALID		(1 << 0)
 
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/1 armv8: mmu: fix page table mapping

Quoted 32 lines · Peng Fan

To page mapping the lowest 2 bits needs to be 0x3.
If not fix this, the final lowest 3 bits for page mapping is 0x1 which is marked as reserved.

---
 arch/arm/cpu/armv8/cache_v8.c    | 5 ++++-
 arch/arm/include/asm/armv8/mmu.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)
arch/arm/cpu/armv8/cache_v8.c +4 -1
index adc7e1746f..6548f3c912 100644
@@ -230,7 +230,10 @@ 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;
+				if (level == 3)
+					*pte = phys | attrs | PTE_TYPE_PAGE;
+				else
+					*pte = phys | attrs;
 				virt += blocksize;
 				phys += blocksize;
 				size -= blocksize;
arch/arm/include/asm/armv8/mmu.h +0 -0
index 6121aab547..765914c7e2 100644

arch/arm/include/asm/armv8/mmu.h line 49

Quoted 7 lines
arch/arm/include/asm/armv8/mmu.h +1 -0
@@ -43,6 +43,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_TYPE_VALID		(1 << 0)
 

This looks familiar. We are lucky not hitting this issue earlier.

#2 lore raw
In reply to Peng Fan
Quoted 6 lines · Peng Fan

To page mapping the lowest 2 bits needs to be 0x3.
If not fix this, the final lowest 3 bits for page mapping is 0x1 which is marked as reserved.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171204/0a68e8be/attachment.sig>