]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
mips: reserve elfcorehdr
authorCorey Minyard <cminyard@mvista.com>
Tue, 12 Feb 2013 19:41:48 +0000 (19:41 +0000)
committerJohn Crispin <blogic@openwrt.org>
Tue, 19 Feb 2013 08:36:23 +0000 (09:36 +0100)
/proc/vmcore wasn't showing up in kdump kernels.  It turns that that
for Octeon, the memory used by elfcorehdr wasn't being set aside
properly and it was getting clobbered before /proc/vmcore could get
it.  So reserve the memory if it shows up in a memory area managed
by the kernel.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Acked-by: David Daney <ddaney@caviumnetworks.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Patchwork: http://patchwork.linux-mips.org/patch/4936/

arch/mips/kernel/setup.c

index 53462500c3cdae4d63fb866c2e2171b46cf0f62c..795f4379c0b6f0e3bde4cead6f2e1d47c4329ab8 100644 (file)
@@ -480,6 +480,37 @@ static int __init early_parse_mem(char *p)
 }
 early_param("mem", early_parse_mem);
 
+#ifdef CONFIG_PROC_VMCORE
+unsigned long setup_elfcorehdr, setup_elfcorehdr_size;
+static int __init early_parse_elfcorehdr(char *p)
+{
+       int i;
+
+       setup_elfcorehdr = memparse(p, &p);
+
+       for (i = 0; i < boot_mem_map.nr_map; i++) {
+               unsigned long start = boot_mem_map.map[i].addr;
+               unsigned long end = (boot_mem_map.map[i].addr +
+                                    boot_mem_map.map[i].size);
+               if (setup_elfcorehdr >= start && setup_elfcorehdr < end) {
+                       /*
+                        * Reserve from the elf core header to the end of
+                        * the memory segment, that should all be kdump
+                        * reserved memory.
+                        */
+                       setup_elfcorehdr_size = end - setup_elfcorehdr;
+                       break;
+               }
+       }
+       /*
+        * If we don't find it in the memory map, then we shouldn't
+        * have to worry about it, as the new kernel won't use it.
+        */
+       return 0;
+}
+early_param("elfcorehdr", early_parse_elfcorehdr);
+#endif
+
 static void __init arch_mem_addpart(phys_t mem, phys_t end, int type)
 {
        phys_t size;
@@ -547,6 +578,14 @@ static void __init arch_mem_init(char **cmdline_p)
        }
 
        bootmem_init();
+#ifdef CONFIG_PROC_VMCORE
+       if (setup_elfcorehdr && setup_elfcorehdr_size) {
+               printk(KERN_INFO "kdump reserved memory at %lx-%lx\n",
+                      setup_elfcorehdr, setup_elfcorehdr_size);
+               reserve_bootmem(setup_elfcorehdr, setup_elfcorehdr_size,
+                               BOOTMEM_DEFAULT);
+       }
+#endif
 #ifdef CONFIG_KEXEC
        if (crashk_res.start != crashk_res.end)
                reserve_bootmem(crashk_res.start,