/* * kexec.c - kexec system call * Copyright (C) 2002-2004 Eric Biederman <ebiederm@xmission.com> * * This source code is licensed under the GNU General Public License, * Version 2. See the file COPYING for more details. */#include <linux/capability.h>#include <linux/mm.h>#include <linux/file.h>#include <linux/slab.h>#include <linux/fs.h>#include <linux/kexec.h>#include <linux/mutex.h>#include <linux/list.h>#include <linux/highmem.h>#include <linux/syscalls.h>#include <linux/reboot.h>#include <linux/ioport.h>#include <linux/hardirq.h>#include <linux/elf.h>#include <linux/elfcore.h>#include <generated/utsrelease.h>#include <linux/utsname.h>#include <linux/numa.h>#include <linux/suspend.h>#include <linux/device.h>#include <linux/freezer.h>#include <linux/pm.h>#include <linux/cpu.h>#include <linux/console.h>#include <linux/vmalloc.h>#include <linux/swap.h>#include <linux/syscore_ops.h>#include <asm/page.h>#include <asm/uaccess.h>#include <asm/io.h>#include <asm/sections.h>/* Per cpu memory for storing cpu states in case of system crash. */
note_buf_t __percpu *crash_notes;/* vmcoreinfo stuff */static unsigned char vmcoreinfo_data[VMCOREINFO_BYTES];
u32 vmcoreinfo_note[VMCOREINFO_NOTE_SIZE/4];size_t vmcoreinfo_size;size_t vmcoreinfo_max_size =sizeof(vmcoreinfo_data);/* Location of the reserved area for the crash kernel */struct resource crashk_res = {.name ="Crash kernel",.start =0,.end =0,.flags = IORESOURCE_BUSY | IORESOURCE_MEM
};intkexec_should_crash(struct task_struct *p){if(in_interrupt() || !p->pid ||is_global_init(p) || panic_on_oops)return1;return0;}/* * When kexec transitions to the new kernel there is a one-to-one * mapping between physical and virtual addresses. On processors * where you can disable the MMU this is trivial, and easy. For * others it is still a simple predictable page table to setup. * * In that environment kexec copies the new kernel to its final * resting place. This means I can only support memory whose * physical address can fit in an unsigned long. In particular * addresses where (pfn << PAGE_SHIFT) > ULONG_MAX cannot be handled. * If the assembly stub has more restrictive requirements * KEXEC_SOURCE_MEMORY_LI