]> Pileus Git - ~andy/linux/commitdiff
ARM: ignore memory below PHYS_OFFSET
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sat, 11 Jan 2014 11:22:18 +0000 (11:22 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 21 Jan 2014 16:42:12 +0000 (16:42 +0000)
If the kernel is loaded higher in physical memory than normal, and we
calculate PHYS_OFFSET higher than the start of RAM, this leads to
boot problems as we attempt to map part of this RAM into userspace.
Rather than struggle with this, just truncate the mapping.

Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/kernel/setup.c

index 7a2dd4689a75c9b112d577eccfca1a44d9a3faf6..061cea820e3fdbe264ec7ff1d30fe07e33498d09 100644 (file)
@@ -660,6 +660,20 @@ int __init arm_add_memory(u64 start, u64 size)
        }
 #endif
 
+       if (aligned_start < PHYS_OFFSET) {
+               if (aligned_start + size <= PHYS_OFFSET) {
+                       pr_info("Ignoring memory below PHYS_OFFSET: 0x%08llx-0x%08llx\n",
+                               aligned_start, aligned_start + size);
+                       return -EINVAL;
+               }
+
+               pr_info("Ignoring memory below PHYS_OFFSET: 0x%08llx-0x%08llx\n",
+                       aligned_start, (u64)PHYS_OFFSET);
+
+               size -= PHYS_OFFSET - aligned_start;
+               aligned_start = PHYS_OFFSET;
+       }
+
        bank->start = aligned_start;
        bank->size = size & ~(phys_addr_t)(PAGE_SIZE - 1);