Age | Commit message (Collapse) | Author |
|
dbgprint_mem_range is used for printing the given memory range under
debugging mode.
Signed-off-by: WANG Chao <chaowang@redhat.com>
Tested-by: Linn Crosetto <linn@hp.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
Fix an off-by-one in locate_hole() that can cause it to return a range
that was previously allocated.
In upgrading to kexec-tools 2.0.5 I first got the error "Overlapping
memory segments at 0xbeff000"
Adding some debugging I found locate_hole was returning incorrect
values. The below is from the debug I added:
XXXMDF: look for hole size 100000, cur range [52b3000, bffffff] size 6d4cfff
XXXMDF: look for hole memsz=100000, found beff000
Hmm, if we wanted 0x100000 bytes ending at 0xbffffff, that should be
0xbf00000, not 0xbef000. Continuing to the second invocation:
XXXMDF: look for hole size 1000, cur range [52b3000, befefff] size 6c4bfff
XXXMDF: look for hole size 1000, cur range [bfff000, bffffff] size fff
XXXMDF: look for hole memsz=1000, found bffe000
Now we die with overlapping ranges, since the 0x100000 bytes at
0xbeff000 overlaps 0x1000 bytes at 0xbffe000.
Signed-off-by: Matthew Fleming <mdf356@gmail.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
Currently kexec will use the kernel image type when probe function return
value >=0. It looks odd, but previously it works. Since commit bf06cf2095
it does not work anymore.
During my testing for arm zImage, in 2nd kernel the atags pointer and the
machine_id are not valid, I did a lot of debugging in kernel, finally I found
this is caused by a kexec tools bug instead.
Because uImage will be probed before zImage, also the uImage probe return 1
instead of -1 since bf06cf2095, thus kexec will mistakenly think it is uImage.
Fix this issue by regarding it's valid only when probe return 0.
Signed-off-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
Factor out the common part of slurp_file() and slurp_file_len() into
a new helper function slurp_fd().
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Dave Young <dyoung@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
Add an optional output parameter to slurp_file_len() so it can return the
actual number of bytes read.
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
Xen 4.4 has an improvided kexec hypercall ABI that allows images to be
loaded and executed without any kernel involvement. Use the API
provided by libxc to load images when running in a Xen guest.
Support for loading images via the kexec_load syscall in non-upstream
("classic") Xen kernels is no longer supported.
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>
|
|
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>
|
|
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>
|
|
"--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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
If the if test is ok, then it will call die() to exit the process,
so freeing line will not be reached, causing memory leak. Fix this.
Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
Signed-off-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
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>
|
|
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>
|
|
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
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>
|
|
Signed-off-by: Jamey Sharp <jamey@thetovacompany.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
Signed-off-by: Jamey Sharp <jamey@thetovacompany.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
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>
|
|
Signed-off-by: Jamey Sharp <jamey@thetovacompany.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
|