[IA64] CONFIG_KEXEC/CONFIG_CRASH_DUMP permutations

Actually, on reflection I think that there is a good case for
keeping the options separate. I am thinking particularly of people
who want a very small crashdump kernel and thus don't want to compile
in kexec.

The patch below should fix things up so that all valid combinations of
KEXEC, CRASH_DUMP and VMCORE compile cleanly - VMCORE depends on
CRASH_DUMP which is why I said valid combinations. In a nutshell
it just untangles unrelated code and switches around a few defines.

Please note that it creats a new file, arch/ia64/kernel/crash_dump.c
This is in keeping with the i386 implementation.

Signed-off-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by Horms and committed by Tony Luck 45a98fc6 adf142e3

+73 -25
+1
arch/ia64/kernel/Makefile
··· 29 29 obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o 30 30 obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o 31 31 obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o crash.o 32 + obj-$(CONFIG_CRASH_DUMP) += crash_dump.o 32 33 obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o 33 34 obj-$(CONFIG_AUDIT) += audit.o 34 35 obj-$(CONFIG_PCI_MSI) += msi_ia64.o
-22
arch/ia64/kernel/crash.c
··· 19 19 20 20 #include <asm/kdebug.h> 21 21 #include <asm/mca.h> 22 - #include <asm/uaccess.h> 23 22 24 23 int kdump_status[NR_CPUS]; 25 24 atomic_t kdump_cpu_freezed; 26 25 atomic_t kdump_in_progress; 27 26 int kdump_on_init = 1; 28 - ssize_t 29 - copy_oldmem_page(unsigned long pfn, char *buf, 30 - size_t csize, unsigned long offset, int userbuf) 31 - { 32 - void *vaddr; 33 - 34 - if (!csize) 35 - return 0; 36 - vaddr = __va(pfn<<PAGE_SHIFT); 37 - if (userbuf) { 38 - if (copy_to_user(buf, (vaddr + offset), csize)) { 39 - return -EFAULT; 40 - } 41 - } else 42 - memcpy(buf, (vaddr + offset), csize); 43 - return csize; 44 - } 45 27 46 28 static inline Elf64_Word 47 29 *append_elf_note(Elf64_Word *buf, char *name, unsigned type, void *data, ··· 207 225 static int 208 226 machine_crash_setup(void) 209 227 { 210 - char *from = strstr(saved_command_line, "elfcorehdr="); 211 228 static struct notifier_block kdump_init_notifier_nb = { 212 229 .notifier_call = kdump_init_notifier, 213 230 }; 214 231 int ret; 215 - if (from) 216 - elfcorehdr_addr = memparse(from+11, &from); 217 - saved_max_pfn = (unsigned long)-1; 218 232 if((ret = register_die_notifier(&kdump_init_notifier_nb)) != 0) 219 233 return ret; 220 234 #ifdef CONFIG_SYSCTL
+48
arch/ia64/kernel/crash_dump.c
··· 1 + /* 2 + * kernel/crash_dump.c - Memory preserving reboot related code. 3 + * 4 + * Created by: Simon Horman <horms@verge.net.au> 5 + * Original code moved from kernel/crash.c 6 + * Original code comment copied from the i386 version of this file 7 + */ 8 + 9 + #include <linux/errno.h> 10 + #include <linux/types.h> 11 + 12 + #include <linux/uaccess.h> 13 + 14 + /** 15 + * copy_oldmem_page - copy one page from "oldmem" 16 + * @pfn: page frame number to be copied 17 + * @buf: target memory address for the copy; this can be in kernel address 18 + * space or user address space (see @userbuf) 19 + * @csize: number of bytes to copy 20 + * @offset: offset in bytes into the page (based on pfn) to begin the copy 21 + * @userbuf: if set, @buf is in user address space, use copy_to_user(), 22 + * otherwise @buf is in kernel address space, use memcpy(). 23 + * 24 + * Copy a page from "oldmem". For this page, there is no pte mapped 25 + * in the current kernel. We stitch up a pte, similar to kmap_atomic. 26 + * 27 + * Calling copy_to_user() in atomic context is not desirable. Hence first 28 + * copying the data to a pre-allocated kernel page and then copying to user 29 + * space in non-atomic context. 30 + */ 31 + ssize_t 32 + copy_oldmem_page(unsigned long pfn, char *buf, 33 + size_t csize, unsigned long offset, int userbuf) 34 + { 35 + void *vaddr; 36 + 37 + if (!csize) 38 + return 0; 39 + vaddr = __va(pfn<<PAGE_SHIFT); 40 + if (userbuf) { 41 + if (copy_to_user(buf, (vaddr + offset), csize)) { 42 + return -EFAULT; 43 + } 44 + } else 45 + memcpy(buf, (vaddr + offset), csize); 46 + return csize; 47 + } 48 +
+1 -1
arch/ia64/kernel/mca.c
··· 1239 1239 } else { 1240 1240 /* Dump buffered message to console */ 1241 1241 ia64_mlogbuf_finish(1); 1242 - #ifdef CONFIG_CRASH_DUMP 1242 + #ifdef CONFIG_KEXEC 1243 1243 atomic_set(&kdump_in_progress, 1); 1244 1244 monarch_cpu = -1; 1245 1245 #endif
+15
arch/ia64/kernel/setup.c
··· 434 434 } 435 435 early_param("nomca", setup_nomca); 436 436 437 + #ifdef CONFIG_PROC_VMCORE 438 + /* elfcorehdr= specifies the location of elf core header 439 + * stored by the crashed kernel. 440 + */ 441 + static int __init parse_elfcorehdr(char *arg) 442 + { 443 + if (!arg) 444 + return -EINVAL; 445 + 446 + elfcorehdr_addr = memparse(arg, &arg); 447 + return 0; 448 + } 449 + early_param("elfcorehdr", parse_elfcorehdr); 450 + #endif /* CONFIG_PROC_VMCORE */ 451 + 437 452 void __init 438 453 setup_arch (char **cmdline_p) 439 454 {
+2 -2
arch/ia64/kernel/smp.c
··· 157 157 case IPI_CPU_STOP: 158 158 stop_this_cpu(); 159 159 break; 160 - #ifdef CONFIG_CRASH_DUMP 160 + #ifdef CONFIG_KEXEC 161 161 case IPI_KDUMP_CPU_STOP: 162 162 unw_init_running(kdump_cpu_freeze, NULL); 163 163 break; ··· 219 219 send_IPI_single(smp_processor_id(), op); 220 220 } 221 221 222 - #ifdef CONFIG_CRASH_DUMP 222 + #ifdef CONFIG_KEXEC 223 223 void 224 224 kdump_smp_send_stop() 225 225 {
+6
arch/ia64/mm/contig.c
··· 174 174 reserve_bootmem(bootmap_start, bootmap_size); 175 175 176 176 find_initrd(); 177 + 178 + #ifdef CONFIG_CRASH_DUMP 179 + /* If we are doing a crash dump, we still need to know the real mem 180 + * size before original memory map is * reset. */ 181 + saved_max_pfn = max_pfn; 182 + #endif 177 183 } 178 184 179 185 #ifdef CONFIG_SMP