summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-05-22arm64: kdump: set up kernel image segmentAKASHI Takahiro
On arm64, we can use the same kernel image as 1st kernel, but we have to modify the entry point as well as segments' addresses in the kernel's elf header in order to load them into correct places. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: David Woodhouse <dwmw@amazon.co.uk> Tested-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-05-22arm64: kdump: add elf core header segmentAKASHI Takahiro
Elf core header contains the information necessary for the coredump of the 1st kernel, including its physcal memory layout as well as cpu register states at the panic. The segment is allocated inside the reserved memory of crash dump kernel. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: David Woodhouse <dwmw@amazon.co.uk> Tested-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-05-22arm64: kdump: identify memory regionsAKASHI Takahiro
The following regions need to be identified for later use: a) memory regions which belong to the 1st kernel b) usable memory reserved for crash dump kernel We go through /proc/iomem to find out a) and b) which are marked as "System RAM" and "Crash kernel", respectively. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: David Woodhouse <dwmw@amazon.co.uk> Tested-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-05-22arm64: change return values on error to negativeAKASHI Takahiro
EFAILED is defined "-1" and so we don't need to negate it as a return value. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: David Woodhouse <dwmw@amazon.co.uk> Tested-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-05-22arm64: identify PHYS_OFFSET correctlyAKASHI Takahiro
Due to the kernel patch, commit e7cd190385d1 ("arm64: mark reserved memblock regions explicitly in iomem"), the current code will not be able to identify the correct value of PHYS_OFFSET if some "reserved" memory region, which is likely to be UEFI runtime services code/data, exists at an address below the first "System RAM" regions. This patch fixes this issue. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: David Woodhouse <dwmw@amazon.co.uk> Tested-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-05-22kexec: generalize and rename get_kernel_stext_sym()Pratyush Anand
get_kernel_stext_sym() has been defined for both arm and i386. Other architecture might need some other kernel symbol address. Therefore rewrite this function as generic function to get any kernel symbol address. More over, kallsyms is not arch specific representation, therefore have common function for all arches. Signed-off-by: Pratyush Anand <panand@redhat.com> [created symbols.c] Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: David Woodhouse <dwmw@amazon.co.uk> Tested-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-05-22kexec: extend the semantics of kexec_iomem_for_each_lineAKASHI Takahiro
The current kexec_iomem_for_each_line() counts up all the lines for which a callback function returns zero(0) or positive, and otherwise it stops further scanning. This behavior is inconvenient in some cases. For instance, on arm64, we want to count up "System RAM" entries, but need to skip "reserved" entries. So this patch extends the semantics so that we will continue to scan succeeding entries but not count lines for which a callback function returns positive. The current users of kexec_iomem_for_each_line(), arm, sh and x86, will not be affected by this change because * arm The callback function only returns -1 or 0, and the return value of kexec_iomem_for_each_line() will never be used. * sh, x86 The callback function may return (-1 for sh,) 0 or 1, but always returns 1 once we have reached the maximum number of entries allowed. Even so the current kexec_iomem_for_each_line() counts them up. This change actually fixes this bug. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Tested-by: David Woodhouse <dwmw@amazon.co.uk> Tested-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-04-08Fix broken Xen support in configure.acEric DeVolder
Commit 2cf7cb9a "kexec: implemented XEN KEXEC STATUS to determine if an image is loaded" added configure-time detection of the kexec_status() call, but in doing so had the unintended side effect of disabling support for Xen altogether due to the missing HAVE_LIBXENCTRL=1. This corrects the broken behavior while still maintaining the original intention of detecting support for kexec_status() call. Reported-and-Tested-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-24x86: Support large number of memory rangesXunlei Pang
We got a problem on one SGI 64TB machine, the current kexec-tools failed to work due to the insufficient ranges(MAX_MEMORY_RANGES) allowed which is defined as 1024(less than the ranges on the machine). The kcore header is insufficient due to the same reason as well. To solve this, this patch simply doubles "MAX_MEMORY_RANGES" and "KCORE_ELF_HEADERS_SIZE". Signed-off-by: Xunlei Pang <xlpang@redhat.com> Tested-by: Frank Ramsay <frank.ramsay@hpe.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-20crashdump: Remove stray get_crashkernel_region() declarationDaniel Kiper
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-20ppc: Fix format warning with die()Jussi Kukkonen
Enable compiling kexec-tools for ppc with -Werror=format-security. Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-14x86/x86_64: Fix format warning with die()Pratyush Anand
Fedora koji uses gcc version 7.0.1-0.12.fc27, and it generates a build warning kexec/arch/i386/kexec-elf-x86.c:299:3: error: format not a string literal and no format arguments [-Werror=format-security] die(error_msg); ^~~ cc1: some warnings being treated as errors error_msg can have a format specifier as well in string. In such cases, if there is no other arguments for the format variable then code will try to access a non existing argument. Therefore, use 1st argument as format specifier for string print and pass error_msg as the string to be printed. While doing that,also use const qualifier before "char *error_msg". Signed-off-by: Pratyush Anand <panand@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
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>
2017-03-13vmcore-dmesg: Define _GNU_SOURCEKhem Raj
loff_t is guarded with _GNU_SOURCE on some C library implementations e.g. musl since this type is not defined by POSIX. Define _GNU_SOURCE to include this define, it should help compiling on musl while nothing changes for glibc based systems since there _GNU_SOURCE is already defined Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-13arm64: add uImage supportDavid Woodhouse
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-13uImage: use 'char *' instead of 'unsigned char *' for uImage_probe()David Woodhouse
... and friends. Again, PPC never cared about the difference, while ARM had to add an explicit cast to work around it, which we can remove now. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-13uImage: use 'char *' instead of 'unsigned char *' for uImage_load()David Woodhouse
This was only ever used on PPC, where they are equivalent and we never saw the resulting -Wpointer-sign warnings. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-13uImage: Add new IH_ARCH_xxx definitionsDavid Woodhouse
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-13uImage: Fix uImage_load() for little-endian machinesDavid Woodhouse
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-13uImage: fix realloc() pointer confusionDavid Woodhouse
We carefully avoid the realloc() API trap by *not* using the 'ptr = realloc(ptr, new_size)' idiom which can lead to leaks on failure. Very commendable, even though all we're going to do is exit() on failure so it wouldn't have mattered. What *does* matter is that we then ask zlib to continue decompression... just past the end of the *old* buffer that just got freed. Oops. Apparently nobody has *ever* tested this code by booting a uImage with a compressed payload larger than 10MiB. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-13build_mem_phdrs(): check if p_paddr is invalidPratyush Anand
Currently, all the p_paddr of PT_LOAD headers are assigned to 0, which is not correct and could be misleading, since 0 is a valid physical address. Upstream kernel commit "464920104bf7 /proc/kcore: update physical address for kcore ram and text" fixed it and now invalid PT_LOAD is assigned as -1. kexec/arch/i386/crashdump-x86.c:get_kernel_vaddr_and_size() uses kcore interface and so calls build_mem_phdrs() for kcore PT_LOAD headers. This patch fixes build_mem_phdrs() to check if p_paddr is invalid. Signed-off-by: Pratyush Anand <panand@redhat.com> Acked-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-10Only print debug message when failed to serach for kernel symbol from ↵Baoquan He
/proc/kallsyms Kernel symbol page_offset_base could be unavailable when mm KASLR code is not compiled in kernel. It's inappropriate to print out error message when failed to search for page_offset_base from /proc/kallsyms. Seems now there is not a way to find out if mm KASLR is compiled in or not. An alternative approach is only printing out debug message in get_kernel_sym if failed to search a expected kernel symbol. Do it in this patch, a simple fix. Signed-off-by: Baoquan He <bhe@redhat.com> Reviewed-by: Pratyush Anand <panand@redhat.com> Acked-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-06gitignore: add two generated files in purgatoryEric DeVolder
This patch adds the two generated files below to .gitignore. purgatory/purgatory.map purgatory/purgatory.ro.sym Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/sh: Add get_crash_kernel_load_range() functionDaniel Kiper
Implement get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/s390: Add get_crash_kernel_load_range() functionDaniel Kiper
Implement get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/ppc64: Add get_crash_kernel_load_range() functionDaniel Kiper
Implement get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/ppc: Add get_crash_kernel_load_range() functionDaniel Kiper
Implement get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/mips: Add get_crash_kernel_load_range() functionDaniel Kiper
Implement get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/m68k: Add get_crash_kernel_load_range() functionDaniel Kiper
Provide stub get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/ia64: Add get_crash_kernel_load_range() functionDaniel Kiper
Implement get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/cris: Add get_crash_kernel_load_range() functionDaniel Kiper
Provide stub get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/arm64: Add get_crash_kernel_load_range() functionEric DeVolder
Provide stub get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02crashdump/arm: Add get_crash_kernel_load_range() functionDaniel Kiper
Implement get_crash_kernel_load_range() in support of print crash kernel region size option. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-03-02kexec: Add option to get crash kernel region sizeDaniel Kiper
Crash kernel region size is available via sysfs on Linux running on bare metal. However, this does not work when Linux runs as Xen dom0. In this case Xen crash kernel region size should be established using __HYPERVISOR_kexec_op hypercall (Linux kernel kexec functionality does not make a lot of sense in Xen dom0). Sadly hypercalls are not easily accessible using shell scripts or something like that. Potentially we can check "xl dmesg" output for crashkernel option but this is not nice. So, let's add this functionality, for Linux running on bare metal and as Xen dom0, to kexec-tools. This way kdump scripts may establish crash kernel region size in one way regardless of platform. All burden of platform detection lies on kexec-tools. Figure (and unit) displayed by this new kexec-tools functionality is the same as one taken from /sys/kernel/kexec_crash_size. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-01-31purgatory: Add purgatory.map and purgatory.ro.sym to clean recipeDaniel Kiper
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-01-31kexec: Remove redundant space from help messageDaniel Kiper
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-01-26kexec: implemented XEN KEXEC STATUS to determine if an image is loadedEric DeVolder
Instead of the scripts having to poke at various fields we can provide that functionality via the -S parameter. kexec_loaded/kexec_crash_loaded exposes Linux kernel kexec/crash state. It does not say anything about Xen kexec/crash state. So, we need a special approach to get the latter. Though for compatibility we provide similar functionality in kexec-tools for the former. This change enables the --status or -S option to work either with or without Xen. Returns 0 if the payload is loaded. Can be used in combination with -l or -p to get the state of the proper kexec image. Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Signed-off-by: Eric DeVolder <eric.devolder@oracle.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-01-24alpha: add missing __NR_kexec_load definitionSimon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2017-01-24kexec: Increase the upper limit for RAM segmentsSameer Goel
On a newer UEFI based Qualcomm target the number of system ram regions retrieved from /proc/iomem are ~40. So increasing the current hardcoded values to 64 from 16. Signed-off-by: Sameer Goel <sgoel@codeaurora.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2017-01-24ppc64: Reduce number of ELF LOAD segmentsPetr Tesarik
The number of program header table entries (e_phnum) is an Elf64_Half, which is a 16-bit entity, i.e. the limit is 65534 entries (one entry is reserved for NOTE). This is a hard limit, defined by the ELF standard. It is possible that more LMBs (Logical Memory Blocks) are needed to represent all RAM on some machines, and this field overflows, causing an incomplete /proc/vmcore file. This has actually happened on a machine with 31TB of RAM and an LMB size of 256MB. However, since there is usually no memory hole between adjacent LMBs, the map can be "compressed", combining multiple adjacent into a single LOAD segment. Signed-off-by: Petr Tesarik <ptesarik@suse.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-20kexec-tools 2.0.14.gitSimon Horman
Add .git to version so it doesn't look like a release. This is just so when people build code from git it can be identified as such from the version string. Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-20kexec-tools 2.0.14Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-12kexec-tools 2.0.14-rc1Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-12arm: do not build iomem.o target with no soruceSimon Horman
Header files should be added to the distribution but not used to derive targets for compilation. In this an attempt was made to build iomem.o, but iomem.c does not exist so this fails. Fixes: 1574ff1aae4f ("arm: include phys_to_virt.h and iomem.h in distribution") Signed-off-by: Simon Horman <horms@verge.net.au> Reviewed-by: Pratyush Anand <panand@redhat.com>
2016-12-09ia64: ehdr is not UNUSED in machine_apply_elf_relSimon Horman
The ehdr parameter of machine_apply_elf_rel() is used. This resolves a build regression. Fixes: 4a2ae3a39c64 ("Pass struct mem_sym into machine_apply_elf_rel()") Signed-off-by: Simon Horman <horms@verge.net.au> Reviewed-by: Pratyush Anand <panand@redhat.com>
2016-12-09arm64: Fix initrd requierementsMatthias Brugger
The initrd doesn't need to be aligend to 1 GB, which breaks kexec for system with RAM <= 1 GB. Instead the memory size between the kernel start rounded down to 1 GB and the end of the initrd rounded up to 1 GB can't be bigger then 32 GB. Signed-off-by: Matthias Brugger <mbrugger@suse.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-09mips: add option to load initrd from a specified fileMarcin Nowakowski
Use kexec's existing infrastrucutre for supporting initrd loading. The initrd image is loaded into a buffer after the dtb and its details passed through the device tree, so it's supported on newer platforms that make use of the device tree passed from kexec. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-09mips: add dtb loading supportMarcin Nowakowski
Kexec for MIPS currently does not support loading devicetrees, unless they are embedded in the kernel elf file. Add an option to either pass a new dtb file or - if not specified - to be generated from existing device tree on the device. As new generic platforms require a dtb to be passed separately this is required for such platforms and will be ignored by the kernel otherwise. Generic kexec infrastructure for dtb support is used. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-09mips: crashdump: add little-endian supportMarcin Nowakowski
Elf header for crashdump has until now been hardcoded as big-endian. Change that to use the native endianness for the compile target so that the crashdumps are generated properly for each CPU type. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-09mips: move arch option parsing from elf loader to common arch codeMarcin Nowakowski
At the moment only commandline handling is implemented and there is nothing elf-specific about it, so all of the commandline parsing logic can be moved to common arch code. getopt() options are moved to KEXEC_ARCH_OPTIONS macro (as many platforms currently do) to avoid unnecessary duplication. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Signed-off-by: Simon Horman <horms@verge.net.au>