summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
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>
2016-12-09mips: use arch_options for both 32 and 64 bit variantsMarcin Nowakowski
At the moment arch_options structure is defined for 64-bit only and is used exclusively in ifdef'ed code. Remove the ifdefs around the uses of the structure and define it for all code variants as it will be used for passing more arch options in the followup commits. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-09mips: remove incorrect arch_usage stringMarcin Nowakowski
arch_usage shows '--elf32-core-headers' as an option, but this is not implemented. Signed-off-by: Marcin Nowakowski <marcin.nowakowski@imgtec.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-08kexec-tools/x86: get_kernel_vaddr_and_size off-by-one fixDave Young
I got below error while tesing kexec -p: "Can't find kernel text map area from kcore" The case is the pt_load start addr was same as stext_sym. The checking code should really be saddr <= stext_sym so that the right pt_load area includes stext_sym can be matched. This was not reported by people previously because it will fail over to use hardcode X86_64__START_KERNEL_map to match the pt_load areas again in later code and it sometimes succeeds because of kernel address randomization. With this change according to my test stext_sym checking can garantee falling into right pt_load area if we get correct stext_sym. Signed-off-by: Dave Young <dyoung@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-12-02purgatory: Change default sha256 optimization to -O2Geoff Levand
Change the default purgatory sha256 code optimization from -O0 to -O2, and add a new arch specific makefile variable $(ARCH)_PURGATORY_SHA256_CFLAGS which can over ride this default. Set ia64_PURGATORY_SHA256_CFLAGS to -O0 to retain the previous optimization level for ia64. The purgatory sha256 code needs the be built with -O0 for the ia64 architecture. Currently this code is built with -O0 for all architectures, which slows down the calculations for architectures which could otherwise use -O2. On arm64, it takes around 20 second to verify SHA in purgatory when vmlinuz image is around 13MB and initramfs is around 30M with -O2 enabled. Otherwise, it takes more than 2 minutes. Cc: Pratyush Anand <panand@redhat.com> Signed-off-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-11-07arm64: Add support of R_AARCH64_PREL32 relocation in purgatoryPratyush Anand
gcc version in fedora koji is 6.2.1-2.fc25. kexec-tools compiled with this gcc produced another relocation error: machine_apply_elf_rel: ERROR Unknown type: 261 This patch fixes the above error. Signed-off-by: Pratyush Anand <panand@redhat.com> Reviewed-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-11-07arm64: Add support for additional relocations in the kexec purgatory codeCatalin Marinas
When compiling the kexec-tools with gcc6, the following additional reolcations are generated in the purgatory.ro file: R_AARCH64_ADR_PREL_PG_HI21 R_AARCH64_ADD_ABS_LO12_NC R_AARCH64_LDST64_ABS_LO12_NC This patch modifies the arm64 machine_apply_elf_rel() function to handle these relocations. Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Geoff Levand <geoff@infradead.org> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-10-13arm64: Add missing kexec dist filesGeoff Levand
Signed-off-by: Geoff Levand <geoff@infradead.org> Reviewed-by: Matthias Brugger <mbrugger@suse.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-10-13arm64: Cleanup kexec MakefileGeoff Levand
Put files in alphabetical order, reformat whitspace. Signed-off-by: Geoff Levand <geoff@infradead.org> Reviewed-by: Matthias Brugger <mbrugger@suse.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2016-10-07kexec/fs2dt: Check for NULL pointer in dt_copy_old_root_param()Madhavan Srinivasan
In dt_copy_old_root_param(), FILE * returned from fopen is not checked for NULL pointer before passinig to fclose(). This could trigger a segfault. Patch to fix the same. Signed-off-by: Madhavan Srinivasan <maddy@linux.vnet.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>