[PATCH 2/2] ARM: MMU: fixed calculation of number of PTEs
Enrico Scholz
enrico.scholz at sigma-chemnitz.de
Thu Sep 17 03:45:11 PDT 2015
barebox uses 4KiB pages so that number of PTEs is 'size >> 12', not
'size >> 10'.
Thie 'size >> 10' limit is not an immediate problem because it allocates
too much PTEs only which are not used. But it can overflow an integer
multiplication ('i * PAGE_SIZE') which causes undefined behaviour with
gcc5.
Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
---
arch/arm/cpu/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 8ceb450..014bba2 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -213,7 +213,7 @@ static int arm_mmu_remap_sdram(struct memory_bank *bank)
unsigned long phys = (unsigned long)bank->start;
unsigned long ttb_start = phys >> 20;
unsigned long ttb_end = (phys >> 20) + (bank->size >> 20);
- unsigned long num_ptes = bank->size >> 10;
+ unsigned long num_ptes = bank->size >> 12;
int i, pte;
u32 *ptes;
--
2.4.3
More information about the barebox
mailing list