[PATCHv2] kexec-tools: update to 2.0.20

Rosen Penev rosenp at gmail.com
Wed Jul 22 21:10:36 EDT 2020


kdump was removed in 7acd257ae67b4ca94f8c23cb8bda0ee0709b9216

gdb can be used as an alternative.

Backported patch to fix compilation with GCC10.

Backported several openembedded patches, some of which are upstream
backports.

Signed-off-by: Rosen Penev <rosenp at gmail.com>
---
 v2: backported openembedded patches to fix compilation
 errors.
 package/boot/kexec-tools/Makefile             | 40 +-------
 .../kexec-tools/patches/010-powerpc.patch     | 35 +++++++
 .../kexec-tools/patches/020-arm-lpae.patch    | 49 +++++++++
 .../boot/kexec-tools/patches/100-gcc10.patch  | 99 +++++++++++++++++++
 ...rela-relocation-R_X86_64_PLT32-error.patch | 14 ---
 .../kexec-tools/patches/110-arm-syscall.patch | 34 +++++++
 .../boot/kexec-tools/patches/120-i386.patch   | 65 ++++++++++++
 7 files changed, 285 insertions(+), 51 deletions(-)
 create mode 100644 package/boot/kexec-tools/patches/010-powerpc.patch
 create mode 100644 package/boot/kexec-tools/patches/020-arm-lpae.patch
 create mode 100644 package/boot/kexec-tools/patches/100-gcc10.patch
 delete mode 100644 package/boot/kexec-tools/patches/100-kexec-tools-fix-for-Unhandled-rela-relocation-R_X86_64_PLT32-error.patch
 create mode 100644 package/boot/kexec-tools/patches/110-arm-syscall.patch
 create mode 100644 package/boot/kexec-tools/patches/120-i386.patch

diff --git a/package/boot/kexec-tools/Makefile b/package/boot/kexec-tools/Makefile
index 269345aa9d..db6dac333e 100644
--- a/package/boot/kexec-tools/Makefile
+++ b/package/boot/kexec-tools/Makefile
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=kexec-tools
-PKG_VERSION:=2.0.16
-PKG_RELEASE:=2
+PKG_VERSION:=2.0.20
+PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec
-PKG_HASH:=5b103351ad752c9badd1d65b00eb6de4bce579f944f4df4e3ef3a755ba567010
+PKG_HASH:=dad8077f0315445d1f6335579fc4ade222facf82a67124974c7be5303ba4f8c8
 
 PKG_FIXUP:=autoreconf
 
@@ -51,17 +51,6 @@ define Package/kexec/description
  The kexec utility allows to load and boot another kernel.
 endef
 
-define Package/kdump
-  $(call Package/kexec-tools/Default)
-  TITLE:=Kernel crash analysis
-  DEPENDS:=+kexec @(i386||x86_64||arm) @KERNEL_CRASH_DUMP
-endef
-
-define Package/kdump/description
- The kdump package allows to automatically boot into a
- special kernel for analyzing kernel crashes using kdump.
-endef
-
 define Package/kexec/config
 	source "$(SOURCE)/Config.in"
 endef
@@ -108,28 +97,5 @@ define Package/kexec/install
 	$(LN) ../usr/sbin/kexec $(1)/sbin/kexec
 endef
 
-define Package/kdump/install
-	$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config $(1)/etc/uci-defaults
-	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/kdump $(PKG_INSTALL_DIR)/usr/sbin/vmcore-dmesg $(1)/usr/sbin
-	$(INSTALL_BIN) ./files/kdump.init $(1)/etc/init.d/kdump
-	$(INSTALL_BIN) ./files/kdump.defaults $(1)/etc/uci-defaults/kdump
-	$(INSTALL_CONF) ./files/kdump.config $(1)/etc/config/kdump
-endef
-
-define Package/kdump/prerm
-#!/bin/sh
-
-case $$(uname -m) in
-	i?86|x86_64)
-		if grep -q " crashkernel=" /boot/grub/grub.cfg; then
-			mount /boot -o remount,rw
-			sed -i 's/ crashkernel=[^ ]*//' /boot/grub/grub.cfg
-			mount /boot -o remount,ro
-		fi
-		;;
-esac
-endef
-
 $(eval $(call BuildPackage,kexec-tools))
 $(eval $(call BuildPackage,kexec))
-$(eval $(call BuildPackage,kdump))
diff --git a/package/boot/kexec-tools/patches/010-powerpc.patch b/package/boot/kexec-tools/patches/010-powerpc.patch
new file mode 100644
index 0000000000..029650f35c
--- /dev/null
+++ b/package/boot/kexec-tools/patches/010-powerpc.patch
@@ -0,0 +1,35 @@
+From 211cae4b6a02a4d9d37bfcd76f3702696e095fc3 Mon Sep 17 00:00:00 2001
+From: Quanyang Wang <quanyang.wang at windriver.com>
+Date: Tue, 16 Jun 2015 12:59:57 +0800
+Subject: [PATCH] powerpc: change the memory size limit
+
+When run "kexec" in powerpc board, the kexec has a limit that
+the kernel text and bss size must be less than 24M. But now
+some kernel size exceed the limit. So we need to change the limit,
+else will get the error log as below:
+
+my_load:669: do
+Could not find a free area of memory of 0x12400 bytes...
+Could not find a free area of memory of 0x13000 bytes...
+locate_hole failed
+
+Upstream-Status: Pending
+
+Signed-off-by: Quanyang Wang <quanyang.wang at windriver.com>
+---
+ kexec/arch/ppc/kexec-ppc.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/kexec/arch/ppc/kexec-ppc.h b/kexec/arch/ppc/kexec-ppc.h
+index 04e728e..6bae9ec 100644
+--- a/kexec/arch/ppc/kexec-ppc.h
++++ b/kexec/arch/ppc/kexec-ppc.h
+@@ -44,7 +44,7 @@ void dol_ppc_usage(void);
+  * During inital setup the kernel does not map the whole memory but a part of
+  * it. On Book-E that is 64MiB, 601 24MiB or 256MiB (if possible).
+  */
+-#define KERNEL_ACCESS_TOP (24 * 1024 * 1024)
++#define KERNEL_ACCESS_TOP (36 * 1024 * 1024)
+ 
+ /* boot block version 17 as defined by the linux kernel */
+ struct bootblock {
diff --git a/package/boot/kexec-tools/patches/020-arm-lpae.patch b/package/boot/kexec-tools/patches/020-arm-lpae.patch
new file mode 100644
index 0000000000..832fe67716
--- /dev/null
+++ b/package/boot/kexec-tools/patches/020-arm-lpae.patch
@@ -0,0 +1,49 @@
+From 55e583d20651e829afbbc8dba0f8ec3017cda2d5 Mon Sep 17 00:00:00 2001
+From: Haiqing Bai <Haiqing.Bai at windriver.com>
+Date: Mon, 9 Jan 2017 15:26:29 +0800
+Subject: [PATCH] kexec: ARM: Fix add_buffer_phys_virt() align issue
+
+When "CONFIG_ARM_LPAE" is enabled,3 level page table
+is used by MMU, the "SECTION_SIZE" is defined with
+(1 << 21), but 'add_buffer_phys_virt()' hardcode this
+to (1 << 20).
+
+Upstream-Status: Pending
+
+Suggested-By:fredrik.markstrom at gmail.com
+Signed-off-by: Haiqing Bai <Haiqing.Bai at windriver.com>
+---
+ kexec/arch/arm/crashdump-arm.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
+index daa4788..3f72b38 100644
+--- a/kexec/arch/arm/crashdump-arm.c
++++ b/kexec/arch/arm/crashdump-arm.c
+@@ -240,6 +240,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
+ 	void *buf;
+ 	int err;
+ 	int last_ranges;
++	unsigned short align_bit_shift = 20;
+ 
+ 	/*
+ 	 * First fetch all the memory (RAM) ranges that we are going to pass to
+@@ -281,6 +282,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
+ 
+ 		/* for support LPAE enabled kernel*/
+ 		elf_info.class = ELFCLASS64;
++		align_bit_shift = 21;
+ 
+ 		err = crash_create_elf64_headers(info, &elf_info,
+ 					 usablemem_rgns.ranges,
+@@ -302,8 +304,9 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
+ 	 * 1MB) so that available memory passed in kernel command line will be
+ 	 * aligned to 1MB. This is because kernel create_mapping() wants memory
+ 	 * regions to be aligned to SECTION_SIZE.
++	 * The SECTION_SIZE of LPAE kernel is '1UL << 21' defined in pgtable-3level.h
+ 	 */
+-	elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << 20,
++	elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 1 << align_bit_shift,
+ 					  crash_kernel_mem.start,
+ 					  crash_kernel_mem.end, -1, 0);
+ 
diff --git a/package/boot/kexec-tools/patches/100-gcc10.patch b/package/boot/kexec-tools/patches/100-gcc10.patch
new file mode 100644
index 0000000000..2af315c0fc
--- /dev/null
+++ b/package/boot/kexec-tools/patches/100-gcc10.patch
@@ -0,0 +1,99 @@
+From cc087b11462af9f971a2c090d07e8d780a867b50 Mon Sep 17 00:00:00 2001
+From: Kairui Song <kasong at redhat.com>
+Date: Wed, 29 Jan 2020 13:38:19 +0800
+Subject: kexec-tools: Remove duplicated variable declarations
+
+When building kexec-tools for Fedora 32, following error is observed:
+
+/usr/bin/ld: kexec/arch/x86_64/kexec-bzImage64.o:(.bss+0x0): multiple definition of `bzImage_support_efi_boot';
+kexec/arch/i386/kexec-bzImage.o:(.bss+0x0): first defined here
+
+/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm/../../fs2dt.h:33: multiple definition of `my_debug';
+kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/kexec/fs2dt.h:33: first defined here
+
+/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:68: multiple definition of `arm64_mem';
+kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:68: first defined here
+
+/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:54: multiple definition of `initrd_size';
+kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:54: first defined here
+
+/builddir/build/BUILD/kexec-tools-2.0.20/kexec/arch/arm64/kexec-arm64.h:53: multiple definition of `initrd_base';
+kexec/fs2dt.o:/builddir/build/BUILD/kexec-tools-2.0.20/././kexec/arch/arm64/kexec-arm64.h:53: first defined here
+
+And apparently, these variables are wrongly declared multiple times. So
+remove duplicated declaration.
+
+Signed-off-by: Kairui Song <kasong at redhat.com>
+Signed-off-by: Simon Horman <horms at verge.net.au>
+---
+ kexec/arch/arm64/kexec-arm64.h      | 6 +++---
+ kexec/arch/ppc64/kexec-elf-ppc64.c  | 2 --
+ kexec/arch/x86_64/kexec-bzImage64.c | 1 -
+ kexec/fs2dt.h                       | 2 +-
+ 4 files changed, 4 insertions(+), 7 deletions(-)
+
+diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h
+index 628de79..ed447ac 100644
+--- a/kexec/arch/arm64/kexec-arm64.h
++++ b/kexec/arch/arm64/kexec-arm64.h
+@@ -50,8 +50,8 @@ int zImage_arm64_load(int argc, char **argv, const char *kernel_buf,
+ void zImage_arm64_usage(void);
+ 
+ 
+-off_t initrd_base;
+-off_t initrd_size;
++extern off_t initrd_base;
++extern off_t initrd_size;
+ 
+ /**
+  * struct arm64_mem - Memory layout info.
+@@ -65,7 +65,7 @@ struct arm64_mem {
+ };
+ 
+ #define arm64_mem_ngv UINT64_MAX
+-struct arm64_mem arm64_mem;
++extern struct arm64_mem arm64_mem;
+ 
+ uint64_t get_phys_offset(void);
+ uint64_t get_vp_offset(void);
+diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
+index 3510b70..695b8b0 100644
+--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
++++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
+@@ -44,8 +44,6 @@
+ uint64_t initrd_base, initrd_size;
+ unsigned char reuse_initrd = 0;
+ const char *ramdisk;
+-/* Used for enabling printing message from purgatory code */
+-int my_debug = 0;
+ 
+ int elf_ppc64_probe(const char *buf, off_t len)
+ {
+diff --git a/kexec/arch/x86_64/kexec-bzImage64.c b/kexec/arch/x86_64/kexec-bzImage64.c
+index 8edb3e4..ba8dc48 100644
+--- a/kexec/arch/x86_64/kexec-bzImage64.c
++++ b/kexec/arch/x86_64/kexec-bzImage64.c
+@@ -42,7 +42,6 @@
+ #include <arch/options.h>
+ 
+ static const int probe_debug = 0;
+-int bzImage_support_efi_boot;
+ 
+ int bzImage64_probe(const char *buf, off_t len)
+ {
+diff --git a/kexec/fs2dt.h b/kexec/fs2dt.h
+index 7633273..fe24931 100644
+--- a/kexec/fs2dt.h
++++ b/kexec/fs2dt.h
+@@ -30,7 +30,7 @@ extern struct bootblock bb[1];
+ 
+ /* Used for enabling printing message from purgatory code
+  * Only has implemented for PPC64 */
+-int my_debug;
++extern int my_debug;
+ extern int dt_no_old_root;
+ 
+ void reserve(unsigned long long where, unsigned long long length);
+-- 
+cgit 1.2.3-1.el7
+
diff --git a/package/boot/kexec-tools/patches/100-kexec-tools-fix-for-Unhandled-rela-relocation-R_X86_64_PLT32-error.patch b/package/boot/kexec-tools/patches/100-kexec-tools-fix-for-Unhandled-rela-relocation-R_X86_64_PLT32-error.patch
deleted file mode 100644
index dfad21992b..0000000000
--- a/package/boot/kexec-tools/patches/100-kexec-tools-fix-for-Unhandled-rela-relocation-R_X86_64_PLT32-error.patch
+++ /dev/null
@@ -1,14 +0,0 @@
-diff --git a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
-index 7fdde73..af33689 100644
---- a/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
-+++ b/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
-@@ -78,7 +78,8 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr),
- 		if ((int64_t)value != *(int32_t *)location)
- 			goto overflow;
- 		break;
--	case R_X86_64_PC32: 
-+	case R_X86_64_PC32:
-+	case R_X86_64_PLT32:
- 		*(uint32_t *)location = value - address;
- 		break;
- 	default:
diff --git a/package/boot/kexec-tools/patches/110-arm-syscall.patch b/package/boot/kexec-tools/patches/110-arm-syscall.patch
new file mode 100644
index 0000000000..9e91fd99f4
--- /dev/null
+++ b/package/boot/kexec-tools/patches/110-arm-syscall.patch
@@ -0,0 +1,34 @@
+From b54816eff272324320c490d62dc36b27d2838732 Mon Sep 17 00:00:00 2001
+From: Quanyang Wang <quanyang.wang at windriver.com>
+Date: Mon, 16 Sep 2019 10:49:05 +0800
+Subject: kexec/arm: undefine __NR_kexec_file_load for arm
+
+In the kernel upstream commit 4ab65ba7a5cb
+("ARM: add kexec_file_load system call number"),
+__NR_kexec_file_load for arm has been defined to be 401.
+This results that even if kexec_file_load isn't implemented
+for arm but the function is_kexec_file_load_implemented()
+will still return true. So undef __NR_kexec_file_load for
+arm architecture.
+
+Signed-off-by: Quanyang Wang <quanyang.wang at windriver.com>
+Signed-off-by: Simon Horman <horms at verge.net.au>
+---
+ kexec/kexec-syscall.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h
+index dac1c1f..92d51d3 100644
+--- a/kexec/kexec-syscall.h
++++ b/kexec/kexec-syscall.h
+@@ -56,6 +56,10 @@
+ #endif
+ #endif /*ifndef __NR_kexec_load*/
+ 
++#ifdef __arm__
++#undef __NR_kexec_file_load
++#endif
++
+ #ifndef __NR_kexec_file_load
+ 
+ #ifdef __x86_64__
diff --git a/package/boot/kexec-tools/patches/120-i386.patch b/package/boot/kexec-tools/patches/120-i386.patch
new file mode 100644
index 0000000000..8251e9a58b
--- /dev/null
+++ b/package/boot/kexec-tools/patches/120-i386.patch
@@ -0,0 +1,65 @@
+From 2c9f26ed20a791a7df0182ba82e93abb52f5a615 Mon Sep 17 00:00:00 2001
+From: Chris Packham <chris.packham at alliedtelesis.co.nz>
+Date: Mon, 18 Nov 2019 12:52:15 +1300
+Subject: kexec: build multiboot2 for i386
+
+This addresses the following compilation issues when building for i386.
+
+ kexec/arch/i386/kexec-x86.c:39:22: error: 'multiboot2_x86_probe' undeclared here (not in a function); did you mean 'multiboot_x86_probe'?
+   { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load,
+                       ^~~~~~~~~~~~~~~~~~~~
+                       multiboot_x86_probe
+ kexec/arch/i386/kexec-x86.c:39:44: error: 'multiboot2_x86_load' undeclared here (not in a function); did you mean 'multiboot_x86_load'?
+   { "multiboot2-x86", multiboot2_x86_probe, multiboot2_x86_load,
+                                             ^~~~~~~~~~~~~~~~~~~
+                                             multiboot_x86_load
+ kexec/arch/i386/kexec-x86.c:40:4: error: 'multiboot2_x86_usage' undeclared here (not in a function); did you mean 'multiboot_x86_usage'?
+     multiboot2_x86_usage },
+     ^~~~~~~~~~~~~~~~~~~~
+     multiboot_x86_usage
+ make: *** [Makefile:114: kexec/arch/i386/kexec-x86.o] Error 1
+ make: *** Waiting for unfinished jobs....
+
+Signed-off-by: Chris Packham <chris.packham at alliedtelesis.co.nz>
+Signed-off-by: Simon Horman <horms at verge.net.au>
+---
+ kexec/arch/i386/Makefile    | 2 +-
+ kexec/arch/i386/kexec-x86.h | 5 +++++
+ 2 files changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/kexec/arch/i386/Makefile b/kexec/arch/i386/Makefile
+index 105cefd..f486103 100644
+--- a/kexec/arch/i386/Makefile
++++ b/kexec/arch/i386/Makefile
+@@ -7,6 +7,7 @@ i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-x86.c
+ i386_KEXEC_SRCS += kexec/arch/i386/kexec-elf-rel-x86.c
+ i386_KEXEC_SRCS += kexec/arch/i386/kexec-bzImage.c
+ i386_KEXEC_SRCS += kexec/arch/i386/kexec-multiboot-x86.c
++i386_KEXEC_SRCS += kexec/arch/i386/kexec-mb2-x86.c
+ i386_KEXEC_SRCS += kexec/arch/i386/kexec-beoboot-x86.c
+ i386_KEXEC_SRCS += kexec/arch/i386/kexec-nbi.c
+ i386_KEXEC_SRCS += kexec/arch/i386/x86-linux-setup.c
+@@ -14,7 +15,6 @@ i386_KEXEC_SRCS += kexec/arch/i386/crashdump-x86.c
+ 
+ dist += kexec/arch/i386/Makefile $(i386_KEXEC_SRCS)			\
+ 	kexec/arch/i386/crashdump-x86.h					\
+-	kexec/arch/i386/kexec-mb2-x86.c					\
+ 	kexec/arch/i386/kexec-x86.h					\
+ 	kexec/arch/i386/x86-linux-setup.h				\
+ 	kexec/arch/i386/include/arch/options.h
+diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h
+index 1b58c3b..0f941df 100644
+--- a/kexec/arch/i386/kexec-x86.h
++++ b/kexec/arch/i386/kexec-x86.h
+@@ -60,6 +60,11 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,
+ 	struct kexec_info *info);
+ void multiboot_x86_usage(void);
+ 
++int multiboot2_x86_load(int argc, char **argv, const char *buf, off_t len,
++			struct kexec_info *info);
++void multiboot2_x86_usage(void);
++int multiboot2_x86_probe(const char *buf, off_t buf_len);
++
+ int elf_x86_probe(const char *buf, off_t len);
+ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
+ 	struct kexec_info *info);
-- 
2.26.2




More information about the openwrt-devel mailing list