]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/sh/kernel/setup.c
sh: convert kexec crash kernel management to LMB.
[karo-tx-linux.git] / arch / sh / kernel / setup.c
index 8870d6ba64bfaf3fac5b8d003a050475ef7dd25e..d67a8a386907cb4c17097cad2142035c30a08a5d 100644 (file)
@@ -39,6 +39,7 @@
 #include <asm/irq.h>
 #include <asm/setup.h>
 #include <asm/clock.h>
+#include <asm/smp.h>
 #include <asm/mmu_context.h>
 
 /*
@@ -144,48 +145,62 @@ static void __init register_bootmem_low_pages(void)
        free_bootmem(PFN_PHYS(curr_pfn), PFN_PHYS(pages));
 }
 
-#ifdef CONFIG_KEXEC
-static void __init reserve_crashkernel(void)
+static void __init check_for_initrd(void)
 {
-       unsigned long long free_mem;
-       unsigned long long crash_size, crash_base;
-       void *vp;
-       int ret;
-
-       free_mem = ((unsigned long long)max_low_pfn - min_low_pfn) << PAGE_SHIFT;
-
-       ret = parse_crashkernel(boot_command_line, free_mem,
-                       &crash_size, &crash_base);
-       if (ret == 0 && crash_size) {
-               if (crash_base <= 0) {
-                       vp = alloc_bootmem_nopanic(crash_size);
-                       if (!vp) {
-                               printk(KERN_INFO "crashkernel allocation "
-                                      "failed\n");
-                               return;
-                       }
-                       crash_base = __pa(vp);
-               } else if (reserve_bootmem(crash_base, crash_size,
-                                       BOOTMEM_EXCLUSIVE) < 0) {
-                       printk(KERN_INFO "crashkernel reservation failed - "
-                                       "memory is in use\n");
-                       return;
-               }
-
-               printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
-                               "for crashkernel (System RAM: %ldMB)\n",
-                               (unsigned long)(crash_size >> 20),
-                               (unsigned long)(crash_base >> 20),
-                               (unsigned long)(free_mem >> 20));
-               crashk_res.start = crash_base;
-               crashk_res.end   = crash_base + crash_size - 1;
-               insert_resource(&iomem_resource, &crashk_res);
+#ifdef CONFIG_BLK_DEV_INITRD
+       unsigned long start, end;
+
+       /*
+        * Check for the rare cases where boot loaders adhere to the boot
+        * ABI.
+        */
+       if (!LOADER_TYPE || !INITRD_START || !INITRD_SIZE)
+               goto disable;
+
+       start = INITRD_START + __MEMORY_START;
+       end = start + INITRD_SIZE;
+
+       if (unlikely(end <= start))
+               goto disable;
+       if (unlikely(start & ~PAGE_MASK)) {
+               pr_err("initrd must be page aligned\n");
+               goto disable;
        }
-}
-#else
-static inline void __init reserve_crashkernel(void)
-{}
+
+       if (unlikely(start < PAGE_OFFSET)) {
+               pr_err("initrd start < PAGE_OFFSET\n");
+               goto disable;
+       }
+
+       if (unlikely(end > lmb_end_of_DRAM())) {
+               pr_err("initrd extends beyond end of memory "
+                      "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
+                      end, (unsigned long)lmb_end_of_DRAM());
+               goto disable;
+       }
+
+       /*
+        * If we got this far inspite of the boot loader's best efforts
+        * to the contrary, assume we actually have a valid initrd and
+        * fix up the root dev.
+        */
+       ROOT_DEV = Root_RAM0;
+
+       /*
+        * Address sanitization
+        */
+       initrd_start = (unsigned long)__va(__pa(start));
+       initrd_end = initrd_start + INITRD_SIZE;
+
+       reserve_bootmem(__pa(initrd_start), INITRD_SIZE, BOOTMEM_DEFAULT);
+
+       return;
+
+disable:
+       pr_info("initrd disabled\n");
+       initrd_start = initrd_end = 0;
 #endif
+}
 
 void __cpuinit calibrate_delay(void)
 {
@@ -276,26 +291,7 @@ void __init setup_bootmem_allocator(unsigned long free_pfn)
 
        sparse_memory_present_with_active_regions(0);
 
-#ifdef CONFIG_BLK_DEV_INITRD
-       ROOT_DEV = Root_RAM0;
-
-       if (LOADER_TYPE && INITRD_START) {
-               unsigned long initrd_start_phys = INITRD_START + __MEMORY_START;
-
-               if (initrd_start_phys + INITRD_SIZE <= PFN_PHYS(max_low_pfn)) {
-                       reserve_bootmem(initrd_start_phys, INITRD_SIZE,
-                                       BOOTMEM_DEFAULT);
-                       initrd_start = (unsigned long)__va(initrd_start_phys);
-                       initrd_end = initrd_start + INITRD_SIZE;
-               } else {
-                       printk("initrd extends beyond end of memory "
-                              "(0x%08lx > 0x%08lx)\ndisabling initrd\n",
-                              initrd_start_phys + INITRD_SIZE,
-                              (unsigned long)PFN_PHYS(max_low_pfn));
-                       initrd_start = 0;
-               }
-       }
-#endif
+       check_for_initrd();
 
        reserve_crashkernel();
 }
@@ -459,9 +455,7 @@ void __init setup_arch(char **cmdline_p)
        if (likely(sh_mv.mv_setup))
                sh_mv.mv_setup(cmdline_p);
 
-#ifdef CONFIG_SMP
        plat_smp_setup();
-#endif
 }
 
 /* processor boot mode configuration */