From 0067a426e7549845ba80e37c62395c1cf1234540 Mon Sep 17 00:00:00 2001 From: Varadarajan Narayanan Date: Thu, 3 Mar 2016 15:14:46 +0530 Subject: arch/armv7: Fix end index calculation in mmu_config_range_kb BUG=chrome-os-partner:49249 TEST=None. Initial code not sure if it will even compile BRANCH=none Change-Id: Ib0fccfe2d103710c006cb3950c65b11b8d596912 Signed-off-by: Patrick Georgi Original-Commit-Id: 9be5f58bb89ec43d4eb264c94c3f745dcade35dd Original-Change-Id: If50efb55d4974dfcab07d3ae6488c2413b505a1f Original-Signed-off-by: Varadarajan Narayanan Original-Reviewed-on: https://chromium-review.googlesource.com/333301 Original-Reviewed-by: Julius Werner Reviewed-on: https://review.coreboot.org/14657 Reviewed-by: Julius Werner Tested-by: build bot (Jenkins) --- src/arch/arm/armv7/mmu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/arch') diff --git a/src/arch/arm/armv7/mmu.c b/src/arch/arm/armv7/mmu.c index 2cf90e75f7..b1c1aac0c0 100644 --- a/src/arch/arm/armv7/mmu.c +++ b/src/arch/arm/armv7/mmu.c @@ -218,8 +218,14 @@ void mmu_config_range_kb(u32 start_kb, u32 size_kb, enum dcache_policy policy) u32 mask = BLOCK_SIZE/KiB - 1; printk(BIOS_DEBUG, "Mapping address range [%#.8x:%#.8x) as %s\n", start_kb * KiB, (start_kb + size_kb) * KiB, attrs[policy].name); + + u32 end_kb = ALIGN_UP((start_kb + size_kb), PAGE_SIZE/KiB) - + (start_kb & ~mask); + + assert(end_kb <= BLOCK_SIZE/KiB); + mmu_fill_table(table, (start_kb & mask) / (PAGE_SIZE/KiB), - div_round_up((start_kb + size_kb) & mask, PAGE_SIZE/KiB), + end_kb / (PAGE_SIZE/KiB), (start_kb & ~mask) * KiB, PAGE_SHIFT, ATTR_PAGE | attr); } -- cgit v1.2.3