Commit e5ab8580 authored by Will Deacon's avatar Will Deacon Committed by Russell King

ARM: 7382/1: mm: truncate memory banks to fit in 4GB space for classic MMU

If a bank of memory spanning the 4GB boundary is added on a !CONFIG_LPAE
kernel then we will hang early during boot since the memory bank will
have wrapped around to zero.

This patch truncates memory banks for !LPAE configurations when the end
address is not representable in 32 bits.
Acked-by: default avatarNicolas Pitre <nico@linaro.org>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent 9f855503
...@@ -523,6 +523,20 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size) ...@@ -523,6 +523,20 @@ int __init arm_add_memory(phys_addr_t start, unsigned long size)
*/ */
size -= start & ~PAGE_MASK; size -= start & ~PAGE_MASK;
bank->start = PAGE_ALIGN(start); bank->start = PAGE_ALIGN(start);
#ifndef CONFIG_LPAE
if (bank->start + size < bank->start) {
printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
"32-bit physical address space\n", (long long)start);
/*
* To ensure bank->start + bank->size is representable in
* 32 bits, we use ULONG_MAX as the upper limit rather than 4GB.
* This means we lose a page after masking.
*/
size = ULONG_MAX - bank->start;
}
#endif
bank->size = size & PAGE_MASK; bank->size = size & PAGE_MASK;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment