1 From 6d7d5da7d75c6df676c8b72d32b02ff024438f0c Mon Sep 17 00:00:00 2001
2 From: Magnus Damm <damm@opensource.se>
3 Date: Tue, 22 Oct 2013 17:59:54 +0100
4 Subject: ARM: 7864/1: Handle 64-bit memory in case of 32-bit phys_addr_t
6 From: Magnus Damm <damm@opensource.se>
8 commit 6d7d5da7d75c6df676c8b72d32b02ff024438f0c upstream.
10 Use CONFIG_ARCH_PHYS_ADDR_T_64BIT to determine
11 if ignoring or truncating of memory banks is
12 neccessary. This may be needed in the case of
13 64-bit memory bank addresses but when phys_addr_t
16 Signed-off-by: Magnus Damm <damm@opensource.se>
17 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
18 Cc: Wang Nan <wangnan0@huawei.com>
19 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22 arch/arm/kernel/setup.c | 16 ++++++++++++----
23 1 file changed, 12 insertions(+), 4 deletions(-)
25 --- a/arch/arm/kernel/setup.c
26 +++ b/arch/arm/kernel/setup.c
27 @@ -530,6 +530,7 @@ void __init dump_machine_table(void)
28 int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
30 struct membank *bank = &meminfo.bank[meminfo.nr_banks];
33 if (meminfo.nr_banks >= NR_BANKS) {
34 printk(KERN_CRIT "NR_BANKS too low, "
35 @@ -542,10 +543,16 @@ int __init arm_add_memory(phys_addr_t st
36 * Size is appropriately rounded down, start is rounded up.
38 size -= start & ~PAGE_MASK;
39 - bank->start = PAGE_ALIGN(start);
40 + aligned_start = PAGE_ALIGN(start);
42 -#ifndef CONFIG_ARM_LPAE
43 - if (bank->start + size < bank->start) {
44 +#ifndef CONFIG_ARCH_PHYS_ADDR_T_64BIT
45 + if (aligned_start > ULONG_MAX) {
46 + printk(KERN_CRIT "Ignoring memory at 0x%08llx outside "
47 + "32-bit physical address space\n", (long long)start);
51 + if (aligned_start + size > ULONG_MAX) {
52 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
53 "32-bit physical address space\n", (long long)start);
55 @@ -553,10 +560,11 @@ int __init arm_add_memory(phys_addr_t st
56 * 32 bits, we use ULONG_MAX as the upper limit rather than 4GB.
57 * This means we lose a page after masking.
59 - size = ULONG_MAX - bank->start;
60 + size = ULONG_MAX - aligned_start;
64 + bank->start = aligned_start;
65 bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1);