summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2021-09-24ppc64: Fix memory leak problem in zImage_ppc64_load()Kai Song
When the function exits abnormally,ph should be freed. Signed-off-by: Kai Song <songkai01@inspur.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-09-24i386: Remove unused local variable in get_kernel_page_offset()Kai Song
In get_kernel_page_offset(),the local variable kv is unused,remove it. Signed-off-by: Kai Song <songkai01@inspur.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-09-14multiboot2: Accept x86-64 imagesZhaofeng Li
Signed-off-by: Zhaofeng Li <hello@zhaofeng.li> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-09-14multiboot2: Avoid first 0x500 bytesZhaofeng Li
In some cases, add_buffer will actually try to allocate the buffer at 0x0, which may not be acceptable by some kernels. Let's avoid the first 0x500 bytes so we don't screw up the IVT and BDA. Signed-off-by: Zhaofeng Li <hello@zhaofeng.li> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-09-14multiboot2: Use rel_min and rel_max for buffer destinationsZhaofeng Li
This would segfault if mhi.rel_tag didn't exist. Signed-off-by: Zhaofeng Li <hello@zhaofeng.li> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-09-14multiboot2: Correct MBI size calculationZhaofeng Li
tag_load_base_addr is dependent on rel_tag, and tag_framebuffer was not accounted for. Signed-off-by: Zhaofeng Li <hello@zhaofeng.li> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-09-14x86: Consolidate elf_x86_probe routinesZhaofeng Li
Signed-off-by: Zhaofeng Li <hello@zhaofeng.li> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-09-13Refer FDT tokens with symbolic namesSourabh Jain
Replace hardcoded FDT structure block tokens with proper names to improve code readability. Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-06-06arm64/crashdump-arm64: deduce the paddr of _textPingfan Liu
Since kernel commit e2a073dde921 ("arm64: omit [_text, _stext) from permanent kernel mapping"), the physical address of 'Kernel code' in /proc/iomem is mapped from _text, instead, from _stext. Taking the compatibility into account, it had better deduce the paddr of _text despite of the unavailability through /proc/iomem. It can be achieved by utilizing the fact _text aligned on 2MB. Signed-off-by: Pingfan Liu <piliu@redhat.com> Cc: Simon Horman <horms@verge.net.au> To: kexec@lists.infradead.org Signed-off-by: Simon Horman <horms@verge.net.au>
2021-05-02kexec-tools: Remove duplicate definition of ramdiskPetr Tesarik
The ramdisk variable is defined in kexec/arch/ppc/kexec-ppc.c. This other definition is not needed and breaks build with -fno-common. Signed-off-by: Petr Tesarik <ptesarik@suse.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-05-02kexec-tools 2.0.21.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>
2021-05-02kexec-tools 2.0.22Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-26kexec-tools 2.0.22-rc1Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-17arm: do not copy magic 4 bytes of appended DTB in zImageAlexander Egorenkov
If the passed zImage happens to have a DTB appended, then the magic 4 bytes of the DTB are copied together with the kernel image. This leads to failed kexec boots because the decompressor finds the aforementioned DTB magic and falsely tries to replace the DTB passed in the register r2 with the non-existent appended one. Signed-off-by: Alexander Egorenkov <egorenar-dev@posteo.net> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-17kexec: Remove the error prone kernel_version functionEric W. Biederman
During kexec there are two kernel versions at play. The version of the running kernel and the version of the kernel that will be booted. On powerpc it appears people have been using the version of the running kernel to attempt to detect properties of the kernel to be booted which is just wrong. As the linux kernel version that is being detected is a no longer supported kernel just remove that buggy and confused code. On x86_64 the kernel_version is used to compute the starting virtual address of the running kernel so a proper core dump may be generated. Using the kernel_version stopped working a while ago when the starting virtual address became randomized. The old code was kept for the case where the kernel was not built with randomization support, but there is nothing in reading /proc/kcore that won't work to detect the starting virtual address even there. In fact /proc/kcore must have the starting virtual address or a debugger can not make sense of the running kernel. So just make computing the starting virtual address on x86_64 unconditional. With a hard coded fallback just in case something went wrong. Doing something with kernel_version() has become important as recent stable kernels have seen the minor version to > 255. Just removing kernel_version() looks like the best option. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-07Shrink segments to fit alignment instead of throwing them awayHongyan Xia
We risk throwing an entire large chunk away if it is just slightly unaligned which then causes the crash kernel to run out of RAM. Keep them and shrink them to alignment. Signed-off-by: Hongyan Xia <hongyxia@amazon.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-07Fix where the real mode interrupt vector endsHongyan Xia
The real mode ends at 0x400, not 0x100. The code intentionally excludes the IVT as RAM, so use the correct address. Also, 0x100 is not 1K aligned and will be rejected by add_memmap(). We have observed problems that after a multiboot2 kexec, the next kexec will throw away such unaligned chunks, losing memory for the next next kernel. In some corner cases, such loss of memory can actually cause OOM during boot. Signed-off-by: Hongyan Xia <hongyxia@amazon.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02github: initial workflowSimon Horman
Initial github workflow which builds kexec on a range of architectures. Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02build: add distcheck targetSimon Horman
Add distcheck target which aims to exercise build, install and uninstall using distribution tarball. Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02build: simplify uninstall targetSimon Horman
This appears to have been copied from some generated code. Simplify it by rolling repetitive operations into a for loop. Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02build: use DESTDIR in uninstall targetSimon Horman
For symmetry with the install target, also use DESTDIR in the uninstall target. Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02build: uninstall kexec_testSimon Horman
kexec_test is installed but not uninstalled. Correct this oversight. Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02build: add dist make targetSimon Horman
This provides a familiar alias for the existing tarball target. The result is a tar.gz file. Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02build: create tarball without self-referential hard linksSimon Horman
The current method of creating the tarball, which is to the hard-link the source directory to the target directory, results in self-referential hardlinks which can be observed using tar xf. This patch resolves this by using an intermediate tarball, held in memory, which collects files to be distributed. This is then unpacked in the target directory which is finally packed into the distribution tarball, a file. Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02crashdump/x86: increase CRASH_MAX_MEMORY_RANGES to 32kDavid Hildenbrand
virtio-mem in Linux adds/removes individual memory blocks (e.g., 128 MB each). Linux merges adjacent memory blocks added by virtio-mem devices, but we can still end up with a very sparse memory layout when unplugging memory in corner cases. Let's increase the maximum number of crash memory ranges from ~2k to 32k. 32k should be sufficient for a very long time. e_phnum field in the header is 16 bits wide, so we can fit a maximum of ~64k entries in there, shared with other entries (i.e., CPU). Therefore, using up to 32k memory ranges is fine. (if we ever need more than ~64k, we can switch to the sh_info field) Move the temporary xen ranges off the stack, dynamically allocating memory for them. Note: We don't have to increase MAX_MEMORY_RANGES, because virtio-mem added memory is driver managed and always detected and added by a driver in the kexec'ed kernel; for ordinary kexec, we must not expose these ranges in the firmware-provided memmap. Cc: Simon Horman <horms@verge.net.au> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02crashdump/x86: iterate only over actual crash memory rangesDavid Hildenbrand
No need to iterate over empty entries. Cc: Simon Horman <horms@verge.net.au> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02crashdump/x86: dump any kind of "System RAM"David Hildenbrand
Traditionally, we had "System RAM" only on the top level of in the kernel resource tree (-> /proc/iomem). Nowadays, we can also have "System RAM" on lower levels of the tree -- driver-managed device memory that is always detected and added via drivers. Current examples are memory added via dax/kmem -- ("System RAM (kmem)") and virtio-mem ("System RAM (virtio_mem)"). Note that in some kernel versions "System RAM (kmem)" was exposed as "System RAM", but similarly, on lower levels of the resource tree. Let's add anything that contains "System RAM" to the elf core header, so it will be dumped for kexec_load(). Handling kexec_file_load() in the kernel is similarly getting fixed [1]. Loading a kdump kernel via "kexec -p -c" ... will result in the kdump kernel to also dump dax/kmem and virtio-mem added System RAM now. Note: We only want to dump this memory, we don't want to add this memory to the memmap of an ordinary kexec'ed kernel ("fast system reboot"). [1] https://lkml.kernel.org/r/20210322160200.19633-1-david@redhat.com Signed-off-by: David Hildenbrand <david@redhat.com> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02kexec-xen: Use correct image type for Live UpdateRaphael Ning
Unlike xen_kexec_load(), xen_kexec_unload() and xen_kexec_status() fail to distinguish between normal kexec and Xen Live Update image types. Fix that by introducing a new helper function that maps internal flags to KEXEC_TYPE_*, and using it throughout kexec-xen.c. Signed-off-by: Raphael Ning <raphning@amazon.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02kexec: Make --status work with normal kexec imagesRaphael Ning
According to kexec(8) manpage, --status (-S) works with both normal kexec (loaded by -l) and crash kernel (loaded by -p) image types, and defaults to the latter. However, the implementation does not match the description: `kexec -l -S` queries the -p image type as if -l were not specified. This is because there is no internal flag defined for the normal kexec type, and -S treats the zero flag as the trigger for the default behaviour (-p). Fix that by making sure the default behaviour for -S is not applied when the -l option is present. Signed-off-by: Raphael Ning <raphning@amazon.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02kexec: Fix description of --status exit codeRaphael Ning
On both Linux and Xen, an exit code of 0 from `kexec --status` indicates that the kexec image being queried is NOT loaded, which is contrary to what the man page and usage() say. Signed-off-by: Raphael Ning <raphning@amazon.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02printk: Use %zu to format size_tGeert Uytterhoeven
When compiling for 32-bit: util_lib/elf_info.c: In function ‘dump_dmesg_lockless’: util_lib/elf_info.c:1095:39: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=] 1095 | fprintf(stderr, "Failed to malloc %lu bytes for prb: %s\n", | ~~^ | | | long unsigned int | %u 1096 | printk_ringbuffer_sz, strerror(errno)); | ~~~~~~~~~~~~~~~~~~~~ | | | size_t {aka unsigned int} util_lib/elf_info.c:1101:49: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘size_t’ {aka ‘unsigned int’} [-Wformat=] 1101 | fprintf(stderr, "Failed to read prb of size %lu bytes: %s\n", | ~~^ | | | long unsigned int | %u 1102 | printk_ringbuffer_sz, strerror(errno)); | ~~~~~~~~~~~~~~~~~~~~ | | | size_t {aka unsigned int} Indeed, "size_t" is "unsigned int" on 32-bit platforms, and "unsigned long" on 64-bit platforms. Fix this by formatting using "%zu". Fixes: 4149df9005f2cdd2 ("printk: add support for lockless ringbuffer") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02printk: Use ULL suffix for 64-bit constantsGeert Uytterhoeven
When compiling for 32-bit: util_lib/elf_info.c: In function ‘get_desc_state’: util_lib/elf_info.c:923:31: warning: left shift count >= width of type [-Wshift-count-overflow] 923 | #define DESC_FLAGS_MASK (3UL << DESC_FLAGS_SHIFT) | ^~ util_lib/elf_info.c:925:25: note: in expansion of macro ‘DESC_FLAGS_MASK’ 925 | #define DESC_ID_MASK (~DESC_FLAGS_MASK) | ^~~~~~~~~~~~~~~ util_lib/elf_info.c:926:30: note: in expansion of macro ‘DESC_ID_MASK’ 926 | #define DESC_ID(sv) ((sv) & DESC_ID_MASK) | ^~~~~~~~~~~~ util_lib/elf_info.c:947:12: note: in expansion of macro ‘DESC_ID’ 947 | if (id != DESC_ID(state_val)) | ^~~~~~~ util_lib/elf_info.c: In function ‘id_inc’: util_lib/elf_info.c:923:31: warning: left shift count >= width of type [-Wshift-count-overflow] 923 | #define DESC_FLAGS_MASK (3UL << DESC_FLAGS_SHIFT) | ^~ util_lib/elf_info.c:925:25: note: in expansion of macro ‘DESC_FLAGS_MASK’ 925 | #define DESC_ID_MASK (~DESC_FLAGS_MASK) | ^~~~~~~~~~~~~~~ util_lib/elf_info.c:981:15: note: in expansion of macro ‘DESC_ID_MASK’ 981 | return (id & DESC_ID_MASK); | ^~~~~~~~~~~~ Indeed, "unsigned long" constants are 32-bit on 32-bit platforms, and 64-bit on 64-bit platforms. Fix this by using a "ULL" suffix instead. Fixes: 4149df9005f2cdd2 ("printk: add support for lockless ringbuffer") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02kexec: Use %llu/%llx and casts to format uint64_tGeert Uytterhoeven
When compiling for 32-bit: kexec/kexec.c: In function ‘cmdline_add_liveupdate’: kexec/kexec.c:1192:30: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=] 1192 | sprintf(buf, " liveupdate=%luM@0x%lx", lu_sizeM, lu_start); | ~~^ ~~~~~~~~ | | | | | uint64_t {aka long long unsigned int} | long unsigned int | %llu kexec/kexec.c:1192:37: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t’ {aka ‘long long unsigned int’} [-Wformat=] 1192 | sprintf(buf, " liveupdate=%luM@0x%lx", lu_sizeM, lu_start); | ~~^ ~~~~~~~~ | | | | | uint64_t {aka long long unsigned int} | long unsigned int | %llx Indeed, "uint64_t" is "unsigned long long" on 32-bit formats, and "unsigned long" on 64-bit formats. Fix this by casting to "unsigned long long", and formatting using "%llu" or "%llx". Fixes: b13984c6f9ec7fdd ("kexec: Introduce --load-live-update for xen") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02mips: Fix the increased mem parameter sizeYouling Tang
The added "mem=size@start" parameter actually corresponds to "crashkernel=YM@XM", but 1 byte is missing when calculating the size, so 1 byte should be added. For example, when using crashkernel=108M@64M (110592K@65536K): Without this patch: the mem parameter added is: mem=110591K@65536K With this patch: the mem parameter added is: mem=110592K@65536K Fixes: 0eac64052636 ("kexec: mips: Fix mem parameters") Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02i386: fix build on pre 4.4 kernelsFederico Pellegrin
kexec build will fail on older kernels (pre 4.4) as the define VIDEO_CAPABILITY_64BIT_BASE was not present at that time. This patch adds it, as per linux/include/uapi/linux/screen_info.h, if not present. Signed-off-by: Federico Pellegrin <fede@evolware.org> Reviewed-by: Kairui Song <kasong@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02mips: Fix typo in commentYouling Tang
Fix typo in comment. Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Simon Horman <horms@verge.net.au>
2021-04-02mips: Add '--reuse-cmdline' optional parameter supportYouling Tang
This patch adds an option "--reuse-cmdline" for people that are lazy in typing --append="$(cat /proc/cmdline)", which will directly use the command line of the currently running system. Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-12-17kexec-tools 2.0.21.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>
2020-12-17kexec-tools 2.0.21Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2020-12-09kexec-tools 2.0.21-rc1Simon Horman
Signed-off-by: Simon Horman <horms@verge.net.au>
2020-12-09kexec: mips: Fix mem parametersJinyang He
"mem=" is useful to indicate the memory region when capture kernel boot. Otherwise, capture kernel will breakdown the memory of panic kernel. Although it can be add by user, adding "mem" by software is a better way. What's more, "mem" should contain elfcorehdr range. Elfcorehdr memory should be managed by kernel. Fixes: 7bd251654aad ("kexec-tools: mips: Remove commandline parameter "mem"") Signed-off-by: Youling Tang <tangyouling@loongson.cn> Signed-off-by: Jinyang He <hejinyang@loongson.cn> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-12-09dt-ops: fix memory leak when new_node malloc failsqiuguorui1
In function dtb_set_property, when malloc new_node fails, we need to free new_dtb before return. Fixes: f56cbcf4c2766 ("kexec/dt-ops.c: Fix '/chosen' v/s 'chosen' node being passed to fdt helper functions") Signed-off-by: qiuguorui1 <qiuguorui1@huawei.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-11-30zlib: fix resource leak when gzdirect failedqiuguorui1
In function zlib_decompress_file, when gzdirect(fp) fails, we should gzclose fp before return. Fixes: d606837b56d46 ("Fix zlib/lzma decompression.") Signed-off-by: qiuguorui1 <qiuguorui1@huawei.com> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-11-30printk: add support for lockless ringbufferJohn Ogness
Linux 5.10 moved to a new lockless ringbuffer. The new ringbuffer is structured completely different to the previous iterations. Add support for retrieving the ringbuffer using vmcoreinfo. The new ringbuffer is detected based on the availability of the "prb" symbol. Signed-off-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-11-16x86_64: allow ELFCLASS32 for x32 supportAhelenia Ziemiańska
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-11-16i386: fix string formatting-related warningsAhelenia Ziemiańska
fixed the same way as in 70cca82 "kexec: Fix snprintf related compilation warnings" Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-11-16i386/kexec-mb2-x86.c: cast ints to uintptr_t before pointers to avoid warningsAhelenia Ziemiańska
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-11-16configure.ac, arch/x86_64: handle x32 as subarch of x86_64 and don't specify ↵Ahelenia Ziemiańska
-mcmodel=large there Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-11-16config: update to latest config.{sub,guess}, install-shAhelenia Ziemiańska
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Simon Horman <horms@verge.net.au>
2020-10-23arm64: Add purgatory printingMatthias Brugger
Add option to allow purgatory printing on arm64 hardware by passing the console name which should be used. Based on a patch by Geoff Levand. Signed-off-by: Matthias Brugger <mbrugger@suse.com> Acked-by: Bhupesh Sharma <bhsharma@redhat.com> Signed-off-by: Simon Horman <horms@verge.net.au>