summaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/setup.c
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2013-10-22 18:59:54 +0200
committerRussell King <rmk+kernel@arm.linux.org.uk>2013-10-29 12:06:30 +0100
commit6d7d5da7d75c6df676c8b72d32b02ff024438f0c (patch)
treef527a2fd59de0da7fdbc6a13b2e697de99581792 /arch/arm/kernel/setup.c
parentARM: 7863/1: Let arm_add_memory() always use 64-bit arguments (diff)
downloadlinux-6d7d5da7d75c6df676c8b72d32b02ff024438f0c.tar.xz
linux-6d7d5da7d75c6df676c8b72d32b02ff024438f0c.zip
ARM: 7864/1: Handle 64-bit memory in case of 32-bit phys_addr_t
Use CONFIG_ARCH_PHYS_ADDR_T_64BIT to determine if ignoring or truncating of memory banks is neccessary. This may be needed in the case of 64-bit memory bank addresses but when phys_addr_t is kept 32-bit. Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/kernel/setup.c')
-rw-r--r--arch/arm/kernel/setup.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 5ec4443af08b..53c3901f7ee3 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -624,6 +624,7 @@ void __init dump_machine_table(void)
int __init arm_add_memory(u64 start, u64 size)
{
struct membank *bank = &meminfo.bank[meminfo.nr_banks];
+ u64 aligned_start;
if (meminfo.nr_banks >= NR_BANKS) {
printk(KERN_CRIT "NR_BANKS too low, "
@@ -636,10 +637,16 @@ int __init arm_add_memory(u64 start, u64 size)
* Size is appropriately rounded down, start is rounded up.
*/
size -= start & ~PAGE_MASK;
- bank->start = PAGE_ALIGN(start);
+ aligned_start = PAGE_ALIGN(start);
-#ifndef CONFIG_ARM_LPAE
- if (bank->start + size < bank->start) {
+#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT
+ if (aligned_start > ULONG_MAX) {
+ printk(KERN_CRIT "Ignoring memory at 0x%08llx outside "
+ "32-bit physical address space\n", (long long)start);
+ return -EINVAL;
+ }
+
+ if (aligned_start + size > ULONG_MAX) {
printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
"32-bit physical address space\n", (long long)start);
/*
@@ -647,10 +654,11 @@ int __init arm_add_memory(u64 start, u64 size)
* 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;
+ size = ULONG_MAX - aligned_start;
}
#endif
+ bank->start = aligned_start;
bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1);
/*