summaryrefslogtreecommitdiff
path: root/kexec/kexec.c
AgeCommit message (Collapse)Author
2013-03-15kexec: use _ALIGN* to make the logic clearZhang Yanfei
By replacing all the explicit align opertion with marco _ALIGN*, the code logic could more clear. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-14kexec: check size before trying the mallocZhang Yanfei
If size is zero, it is unnecessary to do the malloc operation. So checking size first is better than doing malloc first. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-03-05kexec: use dbgprintf instead of #if 0 for debug printingZhang Yanfei
Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> [ horms@verge.net.au: Applied manually due to conflict ] Signed-off-by: Simon Horman <horms@verge.net.au>
2013-01-30kexec: add additional check when getting memory infoZhang Yanfei
This check makes sure that we indeed get the memory information. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-12-23die: Use const for fmtSimon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2012-12-14fix comment typo in locate_holeOlaf Hering
Signed-off-by: Olaf Hering <olaf@aepfle.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-07-13kexec: simply pass LINUX_REBOOT_CMD_KEXEC to rebootmaximilian attems
While trying to port kexec cleanly to klibc, came across this syscall usage for reboot(2). Calling reboot directly simplifies the code. Signed-off-by: maximilian attems <max@stro.at> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-06-27Fix format strings of die()Aleksey Makarov
One of them caused crash when user specifies a file that does not exist. Signed-off-by: Aleksey Makarov <aleksey.makarov@gmail.com> Removed trailing whitespace. Signed-off-by: Simon Horman <horms@verge.net.au>
2012-03-29Add a descriptive error message for kexec load failureKhalid Aziz
kexec-tools package for debian includes a patch that adds a more descriptive error message when someone tries to laod a crash kernel and didn't remember to boot up with crashkernel= parameter. This patch would be of general interest. This patch was originally written by Alastair McKinstry. Please apply. Signed-off-by: Khalid Aziz <khalid.aziz@hp.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-03-15Add generic debug optionCong Wang
Currently the debugging code is under #ifdef DEBUG, which means when we want to debug, we have to re-compile the source code with -DDEBUG. This is not convenient, we want to have a generic --debug option so that we can enable debugging code without re-compiling. This patch moves the arch-specific --debug to generic place and moves code under #ifdef DEBUG to --debug on x86. BTW, the size of kexec binary increases very little after this patch. Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2012-02-01kexec: make some functions staticCong Wang
The following functions/variables can become static. Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-11-09remove unnecessary check code for hole_alignDave Young
hole_align == 0 check is not neccesary, because it will be set to pagesize if it's zero. Just remove it here. Signed-off-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-03-30Remove assigned but otherwise unused variablesSimon Horman
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-09-08kexec: Kill arch_initEric W. Biederman
The function only had one user, the error checking was wrong, and the functions it performed are best done elsewhere so remove the tempation of a problemenatic hook. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
2010-05-19kexec-tools: Fix option/argument parsingMatt Evans
The argument parsing is currently a bit broken as main()'s getopt_long() knows nothing about either the architecture-specific options or, even more specifically, the architecture-and-loader-specific options. This patch introduces new #defines for all architectures, KEXEC_ALL_OPTIONS and KEXEC_ALL_OPT_STR. These contain all possible options for a given build, and the getopt_long() passes in main() and arch_process_options() will now recognise arch- and loader-specific options; these will not be re-ordered in argv[], there is no confusion over which argv[] entry is the kernel filename, and using '--opt=foo' and '--opt foo' both work. All architectures have command line options (and #define OPT_BLAHs) consolidated into their include/arch/option.h files. x86_64 builds parts of i386/ as well, so now both share a single option.h file (with a symlink). Signed-off-by: Matt Evans <matt@ozlabs.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-04-01Merge branch 'ppc32' of git://git.breakpoint.cc/bigeasy/kexec-toolsSimon Horman
2010-03-11kexec: Figure out our native architecture before loadEric W. Biederman
This moves the computing of our native archtecture earlier so that load can use it, as arch/i386/crashdump-x86.c has been trying to. Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-03-11Refix concat_cmdlineEric W. Biederman
When removing the potential leak the logic was flipped which mean we never reached the case for handling when both parameters were set. Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-03-07slurpfile: use lseek() on character nodes instead of fstat() for file sizeSebastian Andrzej Siewior
fstat() is used to determine the filesize before read() and it requires a filesystem. That means that it can not be used on character nodes. This makes it impossible to obtains the kernel from a char node like mtd or more likely ubi. We can't use this in every case because files in /proc don't support lseek(). This is required by the powerpc part to read some device-tree entries. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
2010-02-18x86_64: use correct PAGE_OFFSETSimon Horman
This fixes a bug when using gdb with vmcore as explained by Dave Anderson: The kexec/arch/x86_64/crashdump-x86_64.h file contains a stale PAGE_OFFSET value. In 2.6.27 it was changed from 0xffff810000000000UL to 0xffff880000000000UL. This is only a problem when using gdb with the vmlinux/vmcore pair, because gdb relies upon the PT_LOAD segment's p_vaddr values in the ELF header to be correct. Cc: Dave Anderson <anderson@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-02-02Cast when making signed/unsigned comparison in locate_hole()Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2010-02-02don't leak in concat_cmdlineSimon Horman
Cc: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2010-02-02Fix --reuse-cmdline so it is usable.Eric W. Biederman
A colleague of mine implemented kdump and it used --reuse-cmdline with some rather interesting and unexpected results. Update the getopt specification so that --reuse-cmdline does not attempt to take an argument that it will not use. Update the processing of --append so that --reuse-cmdline followed by --append actually appends the parameters specified by --reuse-cmdline. Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
2009-11-30add support for loading lzma compressed kernelsFlorian Fainelli
This patch allows one to load a lzma compressed kernel using kexec -l. As I wanted the lzma code to be very similar to the existing zlib slurp_decompress I took lzread and associated routines from the cpio lzma support. Tested on my x86 laptop using the following commands: lzma e bzImage bzImage.lzma kexec -l bzImage.lzma Having lzma support is particularly useful on some embedded systems on which we have the kernel already lzma compressed and available on a mtd partition. Signed-off-by: Florian Fainelli <florian@openwrt.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2009-11-27kexec.c: workaround getline and fscanf to make it *libc agnostic. Tested ↵Andrea Adami
against klibc and dietlibc. Based on a patch by Andrea Adami and Yuri Bushmelev I have: * Cleaned up indentation * Rearranged the logic in get_command_line() * Increased the buffer for reading the command line from 1024 to 2048 bytes as this is now possible on x86 Only compile tested against glibc. Cc: Andrea Adami <andrea.adami@gmail.com> Cc: Yuri Bushmelev <jay4mail@gmail.com> Cc: Bernhard Walle <bernhard@bwalle.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2009-03-18kexec jump: use add_segment_phys_virt()Magnus Damm
Since /proc/iomem contains physical addresses, use add_segment_phys_virt(xxx, 0) instead of add_segment() in add_backup_segments(). This fix is needed for kexec jump on SuperH where add_segment() only takes virtual addresses. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Simon Horman <horms@verge.net.au>
2009-01-16entry wants to be void *Milton Miller
The kexec info struct defines entry to be a void *, so pass around the user supplied value as one. This fixes the following warning: gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/ -I./kexec/arch/ppc64/include -c -MD -o kexec/kexec.o kexec/kexec.c kexec/kexec.c: In function ‘my_load’: kexec/kexec.c:773: warning: assignment makes pointer from integer without a cast Signed-off-by: Milton Miller <miltonm@bga.com> Tested-by: M. Mohan Kumar <mohan@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-11-17Fix spell error in help outputBernhard Walle
This patch just fixes a spell error. Found by Dave Plater. Signed-off-by: Bernhard Walle <bwalle@suse.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-10-31kexec jump support for kexec-toolsHuang Ying
To support memory backup/restore an option named --load-preserve-context is added to kexec. When it is specified toggether with --mem-max, most segments for crash dump support are loaded, and the memory range between mem_min to mem_max which has no segments loaded are loaded as backup segments. To support jump back from kexeced, options named --load-jump-back-helper and --entry are added to load a helper image with specified entry to jump back. Signed-off-by: Huang Ying <ying.huang@intel.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-06-13Fix wrong remove_parameter() callsBernhard Walle
When --reuse-cmdline is specified, kexec automatically removes some command line parameter that are *known* to break the kexec'd target. That patch corrects that behaviour: 1. BOOT_IMAGE should be removed always when --reuse-cmdline is specified since it's likely that the kernel is not the same as the running kernel. As only lilo-like bootloaders (i.e. not GRUB) adds that parameter, there's no need to add a BOOT_IMAGE here. 2. crashkernel should be only removed when 'kexec -p' is called. For the normal kexec, the crashkernel parameter can be passed as in the running kernel. The mistake has been introduced by commit 3c5bb06948881b3e31c783c19edef74275794280 by myself. Signed-off-by: Bernhard Walle <bwalle@suse.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-05-28Specify the arch on kexec_unload.Bernhard Walle
This fixes the problem in kexec-tools that the patch http://article.gmane.org/gmane.linux.kernel/685027 tries to fix in kernel. The fix in userspace is correct. Signed-off-by: Bernhard Walle <bwalle@suse.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-05-21Factor uname-based native architecture detection into a common function.Jamey Sharp
This code was copy-pasted into every architecture and was basically identical. Besides producing a nice net reduction in code, this factors a portability challenge into a single function that can be easily replaced at build-time. Signed-off-by: Jamey Sharp <jamey@thetovacompany.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-05-21Open slurped files in binary mode, on systems where that matters.Jamey Sharp
Signed-off-by: Jamey Sharp <jamey@thetovacompany.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-05-21Prototype ifdown() in kexec.h, not nested in main().Jamey Sharp
Signed-off-by: Jamey Sharp <jamey@thetovacompany.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-05-21Add --reuse-cmdlineBernhard Walle
This patch adds an option "--reuse-cmdline" for people that are lazy in typing --append="$(cat /proc/cmdline)". The advantage of "--reuse-cmdline" is also that it strips off BOOT_IMAGE (since it may not be correct any more) from lilo and other boot loaders, and, more important, the crashkernel option in case a panic kernel is loaded. If you like the option I can also add it for really all architectures. Tested only with x86-bzImage both the kexec and kdump case. Signed-off-by: Bernhard Walle <bwalle@suse.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-04-24Die on early EOF in slurp_file, instead of infinite-looping.Jamey Sharp
Signed-off-by: Jamey Sharp <jamey@thetovacompany.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-04-24Simplify initialization of argument list for `shutdown`.Jamey Sharp
Signed-off-by: Jamey Sharp <jamey@thetovacompany.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-04-24Replace weak definitions with source filename overriding.Jamey Sharp
This reduces the kexec-tools' demands on the capabilities of the toolchain, and improves standards conformance, without really changing maintenance complexity. Signed-off-by: Jamey Sharp <jamey@thetovacompany.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-04-24Fix all gcc warnings for ARCH=i386 builds.Jamey Sharp
Signed-off-by: Jamey Sharp <jamey@thetovacompany.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-03-06kexec-tools: mipsel: Remove #ifdef __MIPSEL__ from kexec/kexec.cSimon Horman
On all architectures except mipsel add_buffer() expects add_segment() to work with the virtual address passed. On mipsel it is expected that add_segment() converts the virtual address to a physical address first. add_buffer_virt() is porvided on mipsel for the handful of cases that don't want the address to be converted. This patch maintains that behaviour, but without the need for #ifdef __MIPSEL__ from kexec/kexec.c and much duplicated code. Signed-off-by: Simon Horman <horms@verge.net.au>
2008-03-06kexec-tools: mipsel: mipsel portFrancesco Chiechi
Hello, We developed a patch to port kexec-tools to mips arch and included support for command line passing through elf boot notes. We did it for a customer of ours on a specific platform derived from toshiba tx4938 (so we think it should work at least for tx4938 evaluation board also). We would like to contribute it in case somebody else needs it or wants to improve it. This patch works for us but the assembler part in particular, should be considered as a starting point because my assembly knowledge is not too deep. As this is the first time I submit a patch I tried to guess reading tpp.txt if this is the right way to submit. Please let me know about any mistakes I may have made. Signed-off-by: Simon Horman <horms@verge.net.au>
2008-02-27fix valid_memory_range region mergingMichael Neuling
Check the next region we are including is type RANGE_RAM as well. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-02-19Use zlib if presentSimon Horman
Hi, This fixes a minor regression that occured with Jeremy's recent reworking of the build system. I guess he wasn't dealing with compressed images and thus didn't notice that zlib support had been disabled. The fix involves updating an #ifdef to use the new symbol, and ensuring that -lz is passed to the linker as neccessary. Cc: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2007-12-19Use config.h for definesJeremy Kerr
Instead of putting a heap of -D directives in CPPFLAGS, use a config.h header. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2007-10-08Use fclose() to close the file pointerBernhard Walle
Just use fclose() instead of close() to close a pointer of type FILE *. That fixes the compile warning kexec/kexec.c: In function 'check_reuse_initrd': kexec/kexec.c:793: warning: passing argument 1 of 'close' makes integer from pointer without a cast Signed-off-by: Bernhard Walle <bwalle@suse.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2007-06-11minor cleanup in check_reuse_initrdMichael Neuling
Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2007-05-01kexec: Added generic --reuseinitrd optionMichael Neuling
Adds a generic --reuseinitrd option and performs some sanity checks on it. Can be used with the retain_initrd kernel option. Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2007-03-19Move memory range variablesMagnus Damm
Move memory range variables The common kexec code is currently using two global variables to keep track of memory ranges. Other data is kept in a per-instance structure. This mix is of per-instance and global variables is confusing and leads to messy code in general. So let's not. This patch moves the global variables into struct kexec_info and makes sure that structure is passed along where needed. No logic is changed. Signed-off-by: Magnus Damm <magnus@valinux.co.jp> Signed-off-by: Simon Horman <horms@verge.net.au>
2007-02-13Patch from Bernhard Walle to fix up the help message a bit.Bernhard Walle
Signed-off-by: Simon Horman <horms@verge.net.au> kexec/kexec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
2007-02-02Use xmalloc instead of malloc in locate_hole() to standardise behaviour on errorSimon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>