summaryrefslogtreecommitdiff
path: root/kexec
AgeCommit message (Collapse)Author
2013-11-19kexec/xen: require libxc from Xen 4.4David Vrabel
libxc from Xen 4.4 added xc_kexec_load() which will be required to load images into Xen in the future. Remove all the #ifdef'ery for older versions of libxc. Signed-off-by: David Vrabel <david.vrabel@citrix.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-11-19kexec/ppc64: bring up new ppc64le architectureLaurent Dufour
This patch provides support for the new Power PC litte endian (LE) mode. The LE mode only differs in the way the instructions and data are stored in memory thus there is no real need to duplicate the ppc64 code. However some compilation's options, especially for the purgatory, differ between little and big endian mode's support. A new "SUBARCH" build variable is introduced which is currently only used for PPC64 to specify the endianness. Another set of changes in this patch is fixing minor endianess issues in the ppc64 code and fix an alignment issue raised on Power7 little endian mode. Among these fixes, the check on the kernel binary endianess is removed, since we can imagine kexecing a LE kernel from a BE environment, as far as the specified root filesystem and initrd file are containing the right binaries. This patch depends on the patch "kexec/ppc64: use common architecture fs2dt.c file" I sent earlier on the kexec mailing list. Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-11-19kexec/ppc64: use common architecture fs2dt.c fileLaurent Dufour
Following the commit 'b3c2962 fs2dt: Add a generic copy of fs2dt' which introduced a generic fs2dt file, this patch is removing the ppc64 architecture's one. Tests have been done successfully on Power 7 plateform. Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-11-14arm: add command line option for the total image sizeDaniel Mack
Currently, kexec on arm assumes that it's safe to place binary images such as atags, dtb or initrd at an estimated offset after the load address. That estimated offset is set to 4 times the size of the compressed image, hence assuming a minimum compression ratio of 1:4. While that assumption matches what the in-kernel compressors are able to achive, it doesn't take into account the .bss section the kernel image carries, and which can grow to arbitrary sizes while not accounting to the compressed image size. After decompression, and before the execution of the compressed kernel, the .bss area is initialized to zeros, trampeling over the binary images in case they happen to live in that piece of memory. Unfortunately, determining the full image size is not easiliy possible at runtime, as it would include doing all possible ways of decompression and then walk the ELF sections by hand. For now, allow users to override the static offset with a new, arm specific command line argument. Users are supposed to set this, and determine a sane value by using 'arm-linux-size vmlinux'. Signed-off-by: Daniel Mack <zonque@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-10-17kexec/fs2dt: fix endianess conversionLaurent Dufour
While reviewing fs2dt.c in the common kexec directory, in order to use it to support little endian ppc64 architecture, I found some endianess conversion's issues. In dt_reserve, dt_base is a pointer and thus should not be converted. In checkprop, values read from the device tree are big endian encoded and should be converted if CPU is running in little endian mode. In add_dyn_reconf_usable_mem_property__, fix extraneous endianess conversion of rlen which should be natively used to increase the dt pointer. Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-10-04kexec: Handle read errors in fs2dt setupGeoff Levand
The putnode() routine in fs2dt.c was not checking for errors returned from calls to read(). Add checks for these errors and abort the setup of printing from purgatory if the checks fail. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-10-04kexec: Fix return value build warningsGeoff Levand
Add a local variable 'result' to the putnode() routine of ds2dt and use it to hold return values of calls to read(). Fixes build warnings like these: kexec/fs2dt.c: warning: ignoring return value of ‘read’ Signed-off-by: Geoff Levand <geoff@infradead.org> for Huawei, Linaro Signed-off-by: Simon Horman <horms@verge.net.au>
2013-10-03kexec: Fix off-by-one errors in locate_hole()Geert Uytterhoeven
When calling locate_hole() with "hole_size" equal to the size of an available memory block, it fails to use that memory block. "end" and "hole_max" point to the last byte within the range, hence - "size = end - start" is one less than "hole_size", - "hole_base + hole_size" is one more than "hole_max". Subtract one from "hole_size" when doing the comparison (adding 1 to "size" could overflow in case of one big range covering the whole address space). But explicitly check if "hole_size" is zero first, to handle this case without causing underflows. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-10-03kexec: Fix uninitialized build warningGeoff Levand
Initialize a local variable to zero. Fixes build warnings like these: kexec/kexec-elf-rel.c: warning: ‘rel.r_offset’ may be used uninitialized in this function Signed-off-by: Geoff Levand <geoff@infradead.org> for Huawei, Linaro Signed-off-by: Simon Horman <horms@verge.net.au>
2013-10-03kexec: Remove unused -? option handlingGeoff Levand
The main kexec option code handles the -? option. Remove all the duplicate -? handlers in the arch code which are never used. Signed-off-by: Geoff Levand <geoff@infradead.org> for Huawei, Linaro Signed-off-by: Simon Horman <horms@verge.net.au>
2013-10-03kexec: Fix the -? optionGeoff Levand
Add '?' to the short option string. Fixes runtime errors like these: kexec: invalid option -- '?' Signed-off-by: Geoff Levand <geoff@infradead.org> for Huawei, Linaro Signed-off-by: Simon Horman <horms@verge.net.au>
2013-09-25kexec/ppc: Check for a uImage initrd with ELF kernelSuzuki K. Poulose
We should check if the initrd is in uImage format, when the kernel might be in ELF. Signed-off-by : Suzuki K Poulose <suzuki@in.ibm.com> Signed-off-by : Athira Rajeev<atrajeev@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-09-25kexec/ppc: Add nodes for initrd in dtbSuzuki K. Poulose
If the primary kernel doesn't use an initrd, we may not have linux,initrd-* entries in the device-tree, and hence the initial flat tree may not contain them. Make sure we add the entries in the dtb if the second kernel needs an initrd. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Athira Rajeev<atrajeev@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-09-19kexec/kexec.c: Prefix hex numbers by 0xGeert Uytterhoeven
It's confusing that some pointers are printed as hex numbers prefixed with 0x, while some other values are printed as hex numbers without prefixes. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-09-19cris: is_crashkernel_mem_reserved() should return 0Geert Uytterhoeven
Cris doesn't have support for crash kernels yet. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-09-19kexec: Fix cris/superh comment mixupsGeert Uytterhoeven
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-09-19cris/mips: Remove unused setup_simple_* declarationsGeert Uytterhoeven
Presumably these had been copied from ppc. Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-07-26kexec -p fails on kernel versions of form x.yKhalid Aziz
"kexec -p" fails to load kernels with version of the form x.y instead of x.y.z with an error message similar to "Unsupported utsname.release: 3.10-1-amd64". Code in kernel_version() also checks the wrong variable name for error return value from strtoul() for "minor" and "patch", and hence possibly missing a real error. These changes fix both of these problems. Signed-off-by: Khalid Aziz <khalid@gonehiking.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-21arm: Fix out of tree build errorGeoff Levand
Prefix local include paths with $(srcdir)/. Fixes build errors like these when building for ARM out of the source tree: cc1: fatal error: kexec/arch/arm/crashdump-arm.h: No such file or directory Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-10kexec-tools: sh: Remove saved_max_memZhang Yanfei
saved_max_mem is used to calculate the amount of memory that the previous kernel used. It seems in sh, we just calculate this variable, but we never use it. So remove it. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-10kexec-tools: ppc64: Remove saved_max_memZhang Yanfei
saved_max_mem is used to calculate the amount of memory that the previous kernel used. And passed to the dump-capture kernel by kernel commandline parameter "savemaxmem=". But in the dump-capture kernel, we never use this parameter now, so remove saved_max_mem and don't add "savemaxmem=" to new kernel commandline. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-10kexec-tools: ppc: Remove saved_max_memZhang Yanfei
saved_max_mem is used to calculate the amount of memory that the previous kernel used. And passed to the dump-capture kernel by kernel commandline parameter "savemaxmem=". But in the dump-capture kernel, we never use this parameter now, so remove saved_max_mem and don't add "savemaxmem=" to new kernel commandline. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-10kexec-tools: mips: Remove saved_max_memZhang Yanfei
saved_max_mem is used to calculate the amount of memory that the previous kernel used. And passed to the dump-capture kernel by kernel commandline parameter "savemaxmem=". But in the dump-capture kernel, we never use this parameter now, so remove saved_max_mem and don't add "savemaxmem=" to new kernel commandline. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-10add missed options to man pageBaoquan He
several options are missed in man page, add it now. They are --reuseinitrd, --load-preserve-context, --load-jump-back-helper and --entry=<addr>. Signed-off-by: Baoquan He <bhe@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-10add description for entry option in help and man pageBaoquan He
"--entry" option is used to specify jump back entry address, but lack description in help message and man page. Now add it. Signed-off-by: Baoquan He <bhe@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-06-10kexec man page change for debug optionBaoquan He
In commit 28d4ab53, the arch-specific --debug are moved to generic place, but the relevant description was not updated accordingly in man page. Here change it. Signed-off-by: Baoquan He <bhe@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-05-26kexec-tools: ppc/ppc64: cleanup: Remove never reached returnZhang Yanfei
The return will never be reached, so remove it. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-05-26kexec/s390: cleanup: Remove non-existent header file includeZhang Yanfei
There is no elf.h in this directory, so remove the useless include. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-05-26kexec/s390: cleanup: Fix a mistaken commentZhang Yanfei
When borrowing codes from ia64 architecture, this comment was forgotten to be change. So fix it. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-05-15kexec: check if memory is reserved only when loading kdump kernel.WANG Chao
When memory for crashkernel isn't reserved, it's confusing that kexec spits error message for unloading kdump kernel as if we were loading it: # kexec -p -u Memory for crashkernel is not reserved Please reserve memory by passing "crashkernel=X@Y" parameter to the kernel Then try loading kdump kernel # echo $? 1 It's more appropriate to test if memory is reserved only when loading kdump kernel. With this patch: # kexec -p -u # echo $? 0 It's also the same behavior with the case of trying to unload kernel from unloaded state. Signed-off-by: WANG Chao <chaowang@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-05-14kexec: Replace printf() with die() to error out to stderrWANG Chao
Error messages are mixed stderr with stdout when we use die() along with printf(). So use die() to keep error out consistent. Signed-off-by: WANG Chao <chaowang@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-30kexec: Parse percpu note size from kernelZhang Yanfei
We used 1024 as the percpu crash note size. But for new kernel that exports the real crash note size, we should parse it instead of using 1024. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-30kexec: cleanup: make add_backup_segments staticZhang Yanfei
The function add_backup_segments is only called by my_load and they are in the same file. So unnecessary to export it. Make it static. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-30Revert "kexec: include reserved e820 sections in crash kernel"Zhang Yanfei
This reverts commit e35aa29fb40b37bf86d980b2e19af5e01c2d2549. This patch is based on the commit 49320340f705694e387d794f7f19d407ad9baefa "kexec: lengthen the kernel command line image" Since the latter commit has been reverted due to its useless, this patch should be reverted too. Besides, This patch also changed a kernel restriction of max segments from 16 to 70. Though kexec-tools could have more segments, more than 16, the kexec_load syscall will still fail for the kernel side has a restriction of 16. Cc: Cliff Wickman <cpw@sgi.com> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-26kdump, x86: Process multiple Crash kernel in /proc/iomemYinghai Lu
Vivek found specical handling crashkernel low in not good. We should extend kexec-tools to handle multiple Crash kernel instead. Extend crash_reserved_mem to array instead and use kexec_iomem_for_each_line directly. After that we can drop crashkernel low. -v2: fix left over calling of parse_iomem_single() found by Vivek. Suggested-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-25kexec/uImage: probe to identify a corrupted imageSuzuki K. Poulose
Teach uImage_probe_xxx() to return the information about a corrupted image. This is required to prevent the loading of a corrupted ramdisk, where we don't have strict checking for the other formats, unlike the kernel. So, we should abort the operation than causing a problem with the new kernel. Without this patch, a corrupted uImage ramdisk is treated as a plain ramdisk where there is no format check involved. # kexec -l uImage --initrd romfs-initrd.corrupt The data CRC does not match. Computed: 867e73f7 expected 8f097cc0 # echo $? 0 # kexec -e Starting new kernel Bye! Reserving 55MB of memory at 70MB for crashkernel (System RAM: 256MB) Using Xilinx Virtex440 machine description Linux version 3.6.0-rc3 (root@suzukikp) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (GCC) ) #66 Tue Apr 16 06:36:56 UTC 2013 Found initrd at 0xcf5f8000:0xcfff8040 ... NET: Registered protocol family 17 RAMDISK: Couldn't find valid RAM disk image starting at 0. List of all partitions: No filesystem could mount root, tried: ext2 cramfs Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(1,0) With this patch : # kexec -l uImage --initrd romfs-initrd.corrupt uImage: The data CRC does not match. Computed: 867e73f7 expected 8f097cc0 uImage: Corrupted ramdisk file romfs-initrd With a corrupted kernel image(the behaviour remains the same) : # kexec -l uImage.corrupt --initrd romfs-initrd uImage: The data CRC does not match. Computed: 285787b7 expected e37f65ad Cannot determine the file type of uImage.corrupt Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-17kexec, i386, bzImage: Remove unnecessary symbol value getZhang Yanfei
We needn't get the initial values for every regs in regs32 from symbol entry32_regs for we will manually initialize them one by one next: /* * Initialize the 32bit start information. */ regs32.eax = 0; /* unused */ regs32.ebx = 0; /* 0 == boot not AP processor start */ regs32.ecx = 0; /* unused */ regs32.edx = 0; /* unused */ regs32.esi = setup_base; /* kernel parameters */ regs32.edi = 0; /* unused */ regs32.esp = elf_rel_get_addr(&info->rhdr, "stack_end"); /* stack, unused */ regs32.ebp = 0; /* unused */ regs32.eip = kernel32_load_addr; /* kernel entry point */ Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-17kexec:i386/kexec-[bzImage|elf-x86]:x86_64/kexec-bzImage64: Use "\0" as ↵Wang YanQing
command line instead of empty command line This patch prevents the problems to happen below: In setup_linux_bootloader_parameters_high 120 cmdline_ptr = ((char *)real_mode) + cmdline_offset; 121 memcpy(cmdline_ptr, cmdline, cmdline_len); 122 cmdline_ptr[cmdline_len - 1] = '\0'; if cmdline_len == 0, Line 122 will corrupt kernel16 buf just before the commandline. And in do_bzImage_load, for example, 369 cmdline_end = setup_base + kern16_size_needed + command_line_len - 1; 370 elf_rel_set_symbol(&info->rhdr, "cmdline_end", &cmdline_end, 371 sizeof(unsigned long)); Line 369 will go wrong, too. Signed-off-by: Wang YanQing <udknight@gmail.com> Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-16kexec/powerpc: Handle buffer overflow in kernel command lineSuzuki K. Poulose
Enforce size check for kernel command line to make sure it doesn't overflow COMMAND_LINE_SIZE. Reported-by: Nathan D. Miller <nathanm2@us.ibm.com> Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-16Add --dtb option to ppc64Geoff Levand
All other architectures use the command line option --dtb to pass a dtb file name. For consistency add that option to ppc64. Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-04-08kexec, i386: Fix build warning of size_t printZhang Yanfei
When compile kexec-tools in i386, we got the following warnings: kexec/kexec-elf-rel.c: In function ‘elf_rel_set_symbol’: kexec/kexec-elf-rel.c:517: warning: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘size_t’ kexec/kexec-elf-rel.c: In function ‘elf_rel_get_symbol’: kexec/kexec-elf-rel.c:541: warning: format ‘%ld’ expects type ‘long int’, but argument 4 has type ‘size_t’ This is because the two functions output a size_t value as %ld when it should be %zd, resulting in this warning. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-29kexec: i386: Add cmdline_add_memmap_internal() to reduce the code duplicationZhang Yanfei
Functions: - cmdline_add_memmap() - cmdline_add_memmap_acpi() - cmdline_add_memmap_reserved() is kind of similar, So add a new function cmdline_add_memmap_internal() to hold the common codes, reducing the duplication. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: ppc: Use die() instead of fatal()Zhang Yanfei
fatal() nearly does the same thing as die() does, so this is kind of duplicate. Remove fatal() and use die() instead. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: Use die() to simplify codeZhang Yanfei
Use die() to simplify code. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: fix a minor mistake in an error messageZhang Yanfei
when specified a wrong --entry option, it outputs the error message: "Bad option value in --load-jump-back-helper=%s\n" which is obviously wrong, it should be: "Bad option value in --entry=%s\n" Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: x86_64: elf: fix possible memory leak in elf_x86_64_loadZhang Yanfei
In elf_x86_64_load, allocated memory may not be free'd if the code exits abnormally, by calling die() or return. So the patch fixes the possible memory leak. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: x86_64: elf: fix memory leak caused by get_command_lineZhang Yanfei
Since get_command_line returns dynamically allocated memory, it is easy for the caller to forget freeing the memory. Here fixes a memory leak caused by this function. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: x86_64: bzImage64: fix memory leak caused by get_command_lineZhang Yanfei
Since get_command_line returns dynamically allocated memory, it is easy for the caller to forget freeing the memory. Here fixes a memory leak caused by this function. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: ppc: uImage: fix memory leak caused by get_command_lineZhang Yanfei
Since get_command_line returns dynamically allocated memory, it is easy for the caller to forget freeing the memory. Here fixes a memory leak caused by this function. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-27kexec: ppc: uImage: fix possible memory leak in ppc_load_bare_bitsZhang Yanfei
In ppc_load_bare_bits, allocated memory may not be free'd if the code exits abnormally, by calling die() or return. So the patch fixes the possible memory leak. This patch is also a preparation for patch10. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>