summaryrefslogtreecommitdiff
path: root/kexec/crashdump.c
AgeCommit message (Collapse)Author
2017-03-14Don't use %L width specifier with integer valuesPhilip Prindeville
MUSL doesn't support %L except for floating-point arguments; therefore, %ll must be used instead with integer arguments. Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2014-06-05Fix mistaken check of stat(2) return valueTakao Indoh
get_crash_notes_per_cpu() should return -1 if return value of stat(2) is zero (on success). Signed-off-by: Takao Indoh <indou.takao@jp.fujitsu.com> Reviewed-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Acked-by: WANG Chao <chaowang@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2013-11-19kexec/xen: switch to use xc_kexec_get_range for get_xen_vmcoreinfo.Don Slutz
Signed-off-by: Don Slutz <Don@CloudSwitch.com> 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-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-03-05kexec: fix some compiler warningsZhang Yanfei
I got the following warnings when I compiled kexec-tools: kexec/kexec-elf-rel.c: In function 'elf_rel_load': kexec/kexec-elf-rel.c:367: warning: format '%lx' expects type 'long unsigned int', but argument 6 has type 'unsigned int' kexec/kexec-elf-rel.c:367: warning: format '%lx' expects type 'long unsigned int', but argument 7 has type 'long long unsigned int' kexec/kexec-elf-rel.c:367: warning: format '%lx' expects type 'long unsigned int', but argument 8 has type 'long long unsigned int' kexec/arch/i386/crashdump-x86.c: In function 'get_kernel_paddr': kexec/arch/i386/crashdump-x86.c:99: warning: format '%016Lx' expects type 'long long unsigned int', but argument 3 has type 'uint64_t' kexec/arch/i386/crashdump-x86.c: In function 'get_kernel_vaddr_and_size': kexec/arch/i386/crashdump-x86.c:171: warning: format '%lx' expects type 'long unsigned int', but argument 3 has type 'long long unsigned int' kexec/arch/i386/crashdump-x86.c: In function 'get_crash_notes': kexec/arch/i386/crashdump-x86.c:781: warning: format '%Lx' expects type 'long long unsigned int', but argument 3 has type 'uint64_t' kexec/arch/i386/crashdump-x86.c: In function 'load_crashdump_segments': kexec/arch/i386/crashdump-x86.c:905: warning: 'nr_ranges' may be used uninitialized in this function The patch fix above warnings. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.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-01-10Correct magic varible of function name in debug codeHan Pingtian
The magic varible of function name should be uppercase. Signed-off-by: Han Pingtian <hanpt@linux.vnet.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2011-11-18kexec: improve the debug printf in get_crash_notes_per_cpu()WANG Cong
Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com> 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-07-11kexec/crashdump.c: remove useless codeWANG Cong
I think we don't need to print fopen errors when stat fails. Signed-off-by: WANG Cong <wangcong@zeuux.org> Cc: Simon Horman <horms@verge.net.au> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-06-27kexec/crashdump.c: remove file descriptor leaks; make kdump_info argument to ↵WANG Cong
get_vmcoreinfo() const Add the missing fclose(). Constify a char pointer. Signed-off-by: WANG Cong <wangcong@zeuux.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2008-04-02extract vmcoreinfo from /proc/vmcore for XenItsuro ODA
This patch is for kexec-tools-testing-20080324. 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>
2007-10-19Pass vmcoreinfo's address and size #2Ken'ichi Ohmichi
There is a compatibility problem that the kexec command fails on kernels which don't have /sys/kernel/vmcoreinfo: # ls /sys/kernel/ debug kexec_crash_loaded kexec_loaded security uevent_helper uevent_seqnum # (There is not /sys/kernel/vmcoreinfo.) # # kexec -p --args-linux vmlinuz --initrd=initrd.img Could not open "/sys/kernel/vmcoreinfo": No such file or directory # To fix the problem, could you please apply the attached patch ? The fixed part is the same as the patch in the following mail. Cc: "Ken'ichi Ohmichi" <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Simon Horman <horms@verge.net.au>
2007-10-18Pass vmcoreinfo's address and sizeKen'ichi Ohmichi
The patch is for kexec-tools-testing-20070330. (http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/) The kexec command gets the address and size of the vmcoreinfo data from /sys/kernel/vmcoreinfo, and passes them to the second kernel through ELF header of /proc/vmcore. When the second kernel is booting, the kernel gets them from the ELF header and creates vmcoreinfo's PT_NOTE segment into /proc/vmcore. Signed-off-by: Dan Aloni <da-x@monatomic.org> Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Simon Horman <horms@verge.net.au>
2007-03-19Set crash dump ELF header e_machine field based on underlying hypervisor ↵Ian Campbell
architecture. This is necessary when running Xen with a 64 bit hypervisor and 32 bit domain 0 since the CPU crash notes will be 64 bit. Detecting the hypervisor archiecture requires libxenctrl and therefore this support is optional and disabled by default. Signed-off-by: Ian Campbell <ian.campbell@xensource.com> Acked-by: Magnus Damm <magnus@valinux.co.jp> Signed-off-by: Simon Horman <horms@verge.net.au>
2006-12-21kexec-tool: Use the appropriate format in debug print statementsHorms
Use the appropriate format in debug print statements. This is kind of messy because the same code is compiled with different definitions of the PHDR type. The solution below is the best I can think of at this time. Cc: Magnus Damm <magnus.damm@gmail.com> Cc: Sachin P. Sant <sachinp@in.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2006-11-27kexec-tools: Introduce crashdump-elf.c and crash_create_elf32/64_headers() V2Magnus Damm
kexec-tools: Introduce crashdump-elf.c and crash_create_elf32/64_headers() V2 This patch adds the new file crashdump-elf.c that implements a single generic function which is used to create elf headers. The file gets included twice by crash.c to create two functions from the same source. These two functions are named crash_create_elf32_headers() and crash_create_elf64_headers(). The new code differs from prepare_crash_memory_elf32/64_headers() in the sense that both allocation and setup now are done in the same function. This patch only adds the new code, following patches make sure the different architecture-specific files make use of the new code. This version contains a new comment as suggested by Vivek, together with that the alignment now is fixed at 1024 regardless of architecture. The cpu elf note callback code has been slightly reworked to become cleaner. Also, FUNCTION has been renamed to FUNC. Signed-off-by: Magnus Damm <magnus@valinux.co.jp> Removed trainling whitespace Signed-off-by: Simon Horman <horms@verge.net.au>
2006-11-27kexec-tools: Add length parameter to get_crash_notes_per_cpu()Magnus Damm
kexec-tools: Add length parameter to get_crash_notes_per_cpu() Let get_crash_notes_per_cpu() pass both physical base address and length. Under Xen we export this information from the hypervisor, and it would be a nice improvement for the kernel to actually export the size too. So let's change the framework to use both base address and length. Signed-off-by: Magnus Damm <magnus@valinux.co.jp> Removed trainling whitespace Signed-off-by: Simon Horman <horms@verge.net.au>
2006-11-20kexec-tools: remove bogus stderr from die() callHorms
I introduced a stray stderr argument to one of the die() calls in the patch to get_crash_notes_per_cpu() that I posted yesterday. This should fix that problem. Signed-Off-By: Simon Horman <horms@verge.net.au>
2006-11-17kexec-tools: remove unneccessary includes in kexec/crashdump.cHorms
Remove unneccessary includes in kexec/crashdump.c Cc: Magnus Damm <magnus.damm@gmail.com> Signed-Off-By: Simon Horman <horms@verge.net.au>
2006-11-17kexec-tools: fix various bugs in get_crash_notes_per_cpuHorms
My colleague Magnus Damm pointed out the following problem * errno is returned if the sysfs file could not be opened and sysfs is mounted (according to the currently bogus stat check). But errno may be any value, and is typically > 0, but the callers check for < 0. So basically, the callers will think that get_crash_notes_per_cpu() has suceeded. Just return -1 instead, which satifies the needs of the callers.. In the course of looking at this I noticed the following problems * The code testing stat() != 0 for the the non-existence of a file. The correc check, notation asside, is !stat() && errno == ENOENT * fp is leaked if the sysfs file is successfully opened * if fgets() fails *addr will be invalid * if fgets() fails *addr the wrong return value is given Cc: Magnus Damm <magnus.damm@gmail.com> Signed-Off-By: Simon Horman <horms@verge.net.au>
2006-07-27kexec-tools: i386 sys interface changes compatibilityVivek Goyal
On Wed, Dec 14, 2005 at 02:50:52PM -0600, Milton Miller wrote: [..] > >>(2) why do you stat the files instead of just trying to open them and > >>check for ENOENT? > >> > >>milton > >> > > > >I wanted to differentiate between two cases. One being sysfs not > >mounted > >and other being file not being present (Due to kernel bug or cpu not > >present), hence used stat(). In case of sysfs not being mounted, we > >simply exit after giving an error message. In other case we continue > >to loop through other cpus and ignore cpu, which is not present. > > > > Ok, but try to open the file first. IF you want to do this diagnostic > after the open fails, that is ok. But don't do this check n times (n = > number of cpus) when the file exists. > I have moved the sysfs mounted check in failure condition. > > > > >On Tue, Dec 13, 2005 at 09:36:26AM -0800, Haren Myneni wrote: > >>Vivek, I believe, we should push this func into arch independent code. > >>Otherwise, we have to copy it for every platform. > >> > > > >We have reworked the patch and moved this code to architecture > >independent > >portion. > > > > > Only the x86 code has the fallback the old name, not the genric code. > Only i386 port of kdump was available when crash_notes was exported through /sys/kernel/crash_notes. Rest of the architectures see new arch- independent percpu crash_notes sysfs interface only. Hence thought no point copying backward compatibility code in generic code. > > Also, there are error paths that do not set the address, others that > zero it. > The error paths which do not set address to zero are non return path. They call die() which inturn calls exit(1) after printing appropriate error messasge. > What happens if the base kernel is too old for kexec-panic, where > neiter file will exist? > In that case kexec will fail much earlier. There will be no reserved memory area for loading second kernel (crashkernel=X&Y) hence attempt to load the second kernel will fail and control will not reach this place at all. Modifed patch appended. Thanks Vivek o This patch moves per cpu interface to retrieve crash_notes address to architecture independent section. (As suggested by Haren) o For i386, kernels older than 2.6.15-rc1-mm2 used to export crash_notes through /sys/kernel/crash_notes. This patch also provides backward compatibility with older kernel versions. o Definition of MAX_NOTE_BYTES moved to architecture independent header file as everybody is using same definition. o Definition of MAX_LINE moved to architecture independent header file. Seems to be a better option than defining it in many C files. Signed-off-by: Maneesh Soni <maneesh@in.ibm.com> Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com> Signed-off-by: Maneesh Soni <maneesh@in.ibm.com>