]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.10.34/arm-7864-1-handle-64-bit-memory-in-case-of-32-bit-phys_addr_t.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.10.34 / arm-7864-1-handle-64-bit-memory-in-case-of-32-bit-phys_addr_t.patch
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
5
6 From: Magnus Damm <damm@opensource.se>
7
8 commit 6d7d5da7d75c6df676c8b72d32b02ff024438f0c upstream.
9
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
14 is kept 32-bit.
15
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>
20
21 ---
22 arch/arm/kernel/setup.c | 16 ++++++++++++----
23 1 file changed, 12 insertions(+), 4 deletions(-)
24
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)
29 {
30 struct membank *bank = &meminfo.bank[meminfo.nr_banks];
31 + u64 aligned_start;
32
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.
37 */
38 size -= start & ~PAGE_MASK;
39 - bank->start = PAGE_ALIGN(start);
40 + aligned_start = PAGE_ALIGN(start);
41
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);
48 + return -EINVAL;
49 + }
50 +
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);
54 /*
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.
58 */
59 - size = ULONG_MAX - bank->start;
60 + size = ULONG_MAX - aligned_start;
61 }
62 #endif
63
64 + bank->start = aligned_start;
65 bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1);
66
67 /*