From cd96421b19a4c9dd058cee724cc5b4fe5f0d74db Mon Sep 17 00:00:00 2001 From: John Crispin Date: Fri, 13 Feb 2015 07:42:13 +0000 Subject: [PATCH] kexec-tools: bump version from v2.0.4 to v2.0.9. - kexec-tools is now distributed with tarballs of .tar.gz and .tar.xz format; .tar.bz2 are not provided anymore. - Add CONFIG_KEXEC_LZMA for selecting lzma support. Patches are updated along to: - Remove the now unnecessary patch 0004-mips_regdefs.patch. - Drop 100-reduce_size.patch because the size reduction is marginal. - Allow zlib and lzma support coexist together. This patch has been merged into upstream project. - Fix kexec-tools' configure.ac. - Fix a few compilation warnings. Size comparison of stripped binaries of kexec malta target with both zlib and lzma support enabled. - Before: 41447 - After: 42583 Signed-off-by: Yousong Zhou SVN-Revision: 44437 --- package/boot/kexec-tools/Config.in | 5 + package/boot/kexec-tools/Makefile | 12 +- .../0001-Fix-zlib-lzma-decompression.patch | 171 ++++++++++++++++++ ...ly-necessary-quotes-to-result-of-mac.patch | 52 ++++++ ...r-warning-on-printing-64-bit-integer.patch | 35 ++++ .../0004-mips-remove-unused-variable.patch | 30 +++ .../patches/0004-mips_regdefs.patch | 103 ----------- ...rning-about-implicit-type-conversion.patch | 30 +++ .../kexec-tools/patches/100-reduce_size.patch | 36 ---- 9 files changed, 329 insertions(+), 145 deletions(-) create mode 100644 package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch create mode 100644 package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch create mode 100644 package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch create mode 100644 package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch delete mode 100644 package/boot/kexec-tools/patches/0004-mips_regdefs.patch create mode 100644 package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch delete mode 100644 package/boot/kexec-tools/patches/100-reduce_size.patch diff --git a/package/boot/kexec-tools/Config.in b/package/boot/kexec-tools/Config.in index 2642171bb0..6c7558f30a 100644 --- a/package/boot/kexec-tools/Config.in +++ b/package/boot/kexec-tools/Config.in @@ -23,4 +23,9 @@ config KEXEC_ZLIB prompt "zlib support" default y +config KEXEC_LZMA + bool + prompt "lzma support" + default n + endmenu diff --git a/package/boot/kexec-tools/Makefile b/package/boot/kexec-tools/Makefile index e884661c38..e5d4b4b2f4 100644 --- a/package/boot/kexec-tools/Makefile +++ b/package/boot/kexec-tools/Makefile @@ -8,23 +8,23 @@ include $(TOPDIR)/rules.mk PKG_NAME:=kexec-tools -PKG_VERSION:=2.0.4 +PKG_VERSION:=2.0.9 PKG_RELEASE:=1 -PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE_URL:=@KERNEL/linux/utils/kernel/kexec -PKG_MD5SUM:=05992bc8c0673fc55be7b6d27e48a8db +PKG_MD5SUM:=6681319934e22e74c532bd392ccb1bbb PKG_FIXUP:=autoreconf -PKG_CONFIG_DEPENDS := CONFIG_KEXEC_ZLIB +PKG_CONFIG_DEPENDS := CONFIG_KEXEC_ZLIB CONFIG_KEXEC_LZMA include $(INCLUDE_DIR)/package.mk define Package/kexec-tools SECTION:=utils CATEGORY:=Utilities - DEPENDS:=@KERNEL_KEXEC @armeb||@arm||@i386||@powerpc64||@mipsel||@mips +KEXEC_ZLIB:zlib + DEPENDS:=@KERNEL_KEXEC @armeb||@arm||@i386||@powerpc64||@mipsel||@mips +KEXEC_ZLIB:zlib +KEXEC_LZMA:liblzma TITLE:=Kernel boots kernel URL:=http://kernel.org/pub/linux/kernel/people/horms/kexec-tools/ MAINTAINER:=Florian Fainelli @@ -55,7 +55,7 @@ CONFIGURE_ARGS = \ --libexecdir=/usr/lib \ --sysconfdir=/etc \ $(if $(CONFIG_KEXEC_ZLIB),--with,--without)-zlib \ - --without-lzma + $(if $(CONFIG_KEXEC_LZMA),--with,--without)-lzma TARGET_CFLAGS += -ffunction-sections -fdata-sections TARGET_LDFLAGS += -Wl,--gc-sections diff --git a/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch b/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch new file mode 100644 index 0000000000..06c11ec350 --- /dev/null +++ b/package/boot/kexec-tools/patches/0001-Fix-zlib-lzma-decompression.patch @@ -0,0 +1,171 @@ +From d606837b56d46eb7f815b5d85f07fcc3f1555d00 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou +Date: Sun, 1 Feb 2015 00:10:07 +0800 +Subject: [PATCH 1/5] Fix zlib/lzma decompression. + +Let {zlib,lzma}_decompress_file() return NULL if anything wrong happened +to allow the other method to have a chance to run. + +Signed-off-by: Yousong Zhou +Signed-off-by: Simon Horman +--- + kexec/lzma.c | 33 ++++++++++++++++++++++----------- + kexec/zlib.c | 57 +++++++++++++++++++++++++++++++++++---------------------- + 2 files changed, 57 insertions(+), 33 deletions(-) + +diff --git a/kexec/lzma.c b/kexec/lzma.c +index 939aeb3..5bfccb7 100644 +--- a/kexec/lzma.c ++++ b/kexec/lzma.c +@@ -162,13 +162,16 @@ char *lzma_decompress_file(const char *filename, off_t *r_size) + off_t size, allocated; + ssize_t result; + +- if (!filename) { +- *r_size = 0; +- return 0; +- } ++ dbgprintf("Try LZMA decompression.\n"); ++ ++ *r_size = 0; ++ if (!filename) ++ return NULL; ++ + fp = lzopen(filename, "rb"); + if (fp == 0) { +- die("Cannot open `%s'\n", filename); ++ dbgprintf("Cannot open `%s'\n", filename); ++ return NULL; + } + size = 0; + allocated = 65536; +@@ -183,17 +186,25 @@ char *lzma_decompress_file(const char *filename, off_t *r_size) + if ((errno == EINTR) || (errno == EAGAIN)) + continue; + +- die ("read on %s of %ld bytes failed\n", +- filename, (allocated - size) + 0UL); ++ dbgprintf("%s: read on %s of %ld bytes failed\n", ++ __func__, filename, (allocated - size) + 0UL); ++ break; + } + size += result; +- } while(result > 0); +- result = lzclose(fp); +- if (result != LZMA_OK) { +- die ("Close of %s failed\n", filename); ++ } while (result > 0); ++ ++ if (lzclose(fp) != LZMA_OK) { ++ dbgprintf("%s: Close of %s failed\n", __func__, filename); ++ goto fail; + } ++ if (result < 0) ++ goto fail; ++ + *r_size = size; + return buf; ++fail: ++ free(buf); ++ return NULL; + } + #else + char *lzma_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size)) +diff --git a/kexec/zlib.c b/kexec/zlib.c +index d44df12..7170ac3 100644 +--- a/kexec/zlib.c ++++ b/kexec/zlib.c +@@ -15,29 +15,39 @@ + #include + #include + ++static void _gzerror(gzFile fp, int *errnum, const char **errmsg) ++{ ++ *errmsg = gzerror(fp, errnum); ++ if (*errnum == Z_ERRNO) { ++ *errmsg = strerror(*errnum); ++ } ++} ++ + char *zlib_decompress_file(const char *filename, off_t *r_size) + { + gzFile fp; + int errnum; + const char *msg; + char *buf; +- off_t size, allocated; ++ off_t size = 0, allocated; + ssize_t result; + ++ dbgprintf("Try gzip decompression.\n"); ++ ++ *r_size = 0; + if (!filename) { +- *r_size = 0; +- return 0; ++ return NULL; + } + fp = gzopen(filename, "rb"); + if (fp == 0) { +- msg = gzerror(fp, &errnum); +- if (errnum == Z_ERRNO) { +- msg = strerror(errno); +- } +- fprintf(stderr, "Cannot open `%s': %s\n", filename, msg); ++ _gzerror(fp, &errnum, &msg); ++ dbgprintf("Cannot open `%s': %s\n", filename, msg); ++ return NULL; ++ } ++ if (gzdirect(fp)) { ++ /* It's not in gzip format */ + return NULL; + } +- size = 0; + allocated = 65536; + buf = xmalloc(allocated); + do { +@@ -49,25 +59,28 @@ char *zlib_decompress_file(const char *filename, off_t *r_size) + if (result < 0) { + if ((errno == EINTR) || (errno == EAGAIN)) + continue; +- +- msg = gzerror(fp, &errnum); +- if (errnum == Z_ERRNO) { +- msg = strerror(errno); +- } +- die ("read on %s of %ld bytes failed: %s\n", +- filename, (allocated - size) + 0UL, msg); ++ _gzerror(fp, &errnum, &msg); ++ dbgprintf("Read on %s of %ld bytes failed: %s\n", ++ filename, (allocated - size) + 0UL, msg); ++ size = 0; ++ goto fail; + } + size += result; + } while(result > 0); ++ ++fail: + result = gzclose(fp); + if (result != Z_OK) { +- msg = gzerror(fp, &errnum); +- if (errnum == Z_ERRNO) { +- msg = strerror(errno); +- } +- die ("Close of %s failed: %s\n", filename, msg); ++ _gzerror(fp, &errnum, &msg); ++ dbgprintf(" Close of %s failed: %s\n", filename, msg); ++ } ++ ++ if (size > 0) { ++ *r_size = size; ++ } else { ++ free(buf); ++ buf = NULL; + } +- *r_size = size; + return buf; + } + #else +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch b/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch new file mode 100644 index 0000000000..aba8af7412 --- /dev/null +++ b/package/boot/kexec-tools/patches/0002-configure.ac-apply-necessary-quotes-to-result-of-mac.patch @@ -0,0 +1,52 @@ +From eb20884c9bbc42bdf1ccace4444f3ce72657d7d8 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou +Date: Tue, 9 Sep 2014 20:15:16 +0800 +Subject: [PATCH 2/5] configure.ac: apply necessary quotes to result of macro + expansion. + +This can fix the following error when searching for lzma support and +while at it also apply the practice to other uses of the same pattern. + + checking for lzma_code in -llzma... ./configure: line 4756: ac_fn_c_try_link: command not found + +Signed-off-by: Yousong Zhou +--- + configure.ac | 12 ++++++------ + 1 file changed, 6 insertions(+), 6 deletions(-) + +diff --git a/configure.ac b/configure.ac +index db93331..c410e90 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -152,22 +152,22 @@ AC_CHECK_PROG([DIRNAME], dirname, dirname, "no", [$PATH]) + dnl See if I have a usable copy of zlib available + if test "$with_zlib" = yes ; then + AC_CHECK_HEADER(zlib.h, +- AC_CHECK_LIB(z, inflateInit_, , +- AC_MSG_NOTICE([zlib support disabled]))) ++ [AC_CHECK_LIB(z, inflateInit_, , ++ AC_MSG_NOTICE([zlib support disabled]))]) + fi + + dnl See if I have a usable copy of lzma available + if test "$with_lzma" = yes ; then + AC_CHECK_HEADER(lzma.h, +- AC_CHECK_LIB(lzma, lzma_code, , +- AC_MSG_NOTICE([lzma support disabled]))) ++ [AC_CHECK_LIB(lzma, lzma_code, , ++ AC_MSG_NOTICE([lzma support disabled]))]) + fi + + dnl find Xen control stack libraries + if test "$with_xen" = yes ; then + AC_CHECK_HEADER(xenctrl.h, +- AC_CHECK_LIB(xenctrl, xc_kexec_load, , +- AC_MSG_NOTICE([Xen support disabled]))) ++ [AC_CHECK_LIB(xenctrl, xc_kexec_load, , ++ AC_MSG_NOTICE([Xen support disabled]))]) + fi + + dnl ---Sanity checks +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch b/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch new file mode 100644 index 0000000000..f4762e94c5 --- /dev/null +++ b/package/boot/kexec-tools/patches/0003-mips-fix-compiler-warning-on-printing-64-bit-integer.patch @@ -0,0 +1,35 @@ +From 89d455d785190203b1d3a8766c8babb8c1688fc3 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou +Date: Mon, 9 Feb 2015 19:51:25 +0800 +Subject: [PATCH 3/5] mips: fix compiler warning on printing 64-bit integer. + + +Signed-off-by: Yousong Zhou +--- + kexec/arch/mips/crashdump-mips.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c +index e7840e0..98c9f7c 100644 +--- a/kexec/arch/mips/crashdump-mips.c ++++ b/kexec/arch/mips/crashdump-mips.c +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + #include + #include + #include +@@ -52,7 +53,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info) + + if (parse_iomem_single("Kernel code\n", &start, NULL) == 0) { + elf_info->kern_paddr_start = start; +- dbgprintf("kernel load physical addr start = 0x%lx\n", start); ++ dbgprintf("kernel load physical addr start = 0x%" PRIu64 "\n", start); + return 0; + } + +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch b/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch new file mode 100644 index 0000000000..8626c41347 --- /dev/null +++ b/package/boot/kexec-tools/patches/0004-mips-remove-unused-variable.patch @@ -0,0 +1,30 @@ +From 904e9ae892b0592c916a013869e3be3d830e0155 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou +Date: Mon, 9 Feb 2015 20:11:04 +0800 +Subject: [PATCH 4/5] mips: remove unused variable. + +Fixes the following compilation warning. + + kexec/arch/mips/crashdump-mips.c:151:6: warning: unused variable 'i' [-Wunused-variable] + +Signed-off-by: Yousong Zhou +--- + kexec/arch/mips/crashdump-mips.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c +index 98c9f7c..dc68cb4 100644 +--- a/kexec/arch/mips/crashdump-mips.c ++++ b/kexec/arch/mips/crashdump-mips.c +@@ -148,7 +148,7 @@ static int exclude_crash_reserve_region(int *nr_ranges) + static int get_crash_memory_ranges(struct memory_range **range, int *ranges) + { + const char iomem[] = "/proc/iomem"; +- int i, memory_ranges = 0; ++ int memory_ranges = 0; + char line[MAX_LINE]; + FILE *fp; + unsigned long long start, end; +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/0004-mips_regdefs.patch b/package/boot/kexec-tools/patches/0004-mips_regdefs.patch deleted file mode 100644 index 7e21349aa1..0000000000 --- a/package/boot/kexec-tools/patches/0004-mips_regdefs.patch +++ /dev/null @@ -1,103 +0,0 @@ ---- /dev/null -+++ b/kexec/arch/mips/regdef.h -@@ -0,0 +1,100 @@ -+/* -+ * This file is subject to the terms and conditions of the GNU General Public -+ * License. See the file "COPYING" in the main directory of this archive -+ * for more details. -+ * -+ * Copyright (C) 1985 MIPS Computer Systems, Inc. -+ * Copyright (C) 1994, 95, 99, 2003 by Ralf Baechle -+ * Copyright (C) 1990 - 1992, 1999 Silicon Graphics, Inc. -+ */ -+#ifndef _ASM_REGDEF_H -+#define _ASM_REGDEF_H -+ -+#include -+ -+#if _MIPS_SIM == _MIPS_SIM_ABI32 -+ -+/* -+ * Symbolic register names for 32 bit ABI -+ */ -+#define zero $0 /* wired zero */ -+#define AT $1 /* assembler temp - uppercase because of ".set at" */ -+#define v0 $2 /* return value */ -+#define v1 $3 -+#define a0 $4 /* argument registers */ -+#define a1 $5 -+#define a2 $6 -+#define a3 $7 -+#define t0 $8 /* caller saved */ -+#define t1 $9 -+#define t2 $10 -+#define t3 $11 -+#define t4 $12 -+#define t5 $13 -+#define t6 $14 -+#define t7 $15 -+#define s0 $16 /* callee saved */ -+#define s1 $17 -+#define s2 $18 -+#define s3 $19 -+#define s4 $20 -+#define s5 $21 -+#define s6 $22 -+#define s7 $23 -+#define t8 $24 /* caller saved */ -+#define t9 $25 -+#define jp $25 /* PIC jump register */ -+#define k0 $26 /* kernel scratch */ -+#define k1 $27 -+#define gp $28 /* global pointer */ -+#define sp $29 /* stack pointer */ -+#define fp $30 /* frame pointer */ -+#define s8 $30 /* same like fp! */ -+#define ra $31 /* return address */ -+ -+#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ -+ -+#if _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 -+ -+#define zero $0 /* wired zero */ -+#define AT $at /* assembler temp - uppercase because of ".set at" */ -+#define v0 $2 /* return value - caller saved */ -+#define v1 $3 -+#define a0 $4 /* argument registers */ -+#define a1 $5 -+#define a2 $6 -+#define a3 $7 -+#define a4 $8 /* arg reg 64 bit; caller saved in 32 bit */ -+#define ta0 $8 -+#define a5 $9 -+#define ta1 $9 -+#define a6 $10 -+#define ta2 $10 -+#define a7 $11 -+#define ta3 $11 -+#define t0 $12 /* caller saved */ -+#define t1 $13 -+#define t2 $14 -+#define t3 $15 -+#define s0 $16 /* callee saved */ -+#define s1 $17 -+#define s2 $18 -+#define s3 $19 -+#define s4 $20 -+#define s5 $21 -+#define s6 $22 -+#define s7 $23 -+#define t8 $24 /* caller saved */ -+#define t9 $25 /* callee address for PIC/temp */ -+#define jp $25 /* PIC jump register */ -+#define k0 $26 /* kernel temporary */ -+#define k1 $27 -+#define gp $28 /* global pointer - caller saved for PIC */ -+#define sp $29 /* stack pointer */ -+#define fp $30 /* frame pointer */ -+#define s8 $30 /* callee saved */ -+#define ra $31 /* return address */ -+ -+#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 || _MIPS_SIM == _MIPS_SIM_NABI32 */ -+ -+#endif /* _ASM_REGDEF_H */ diff --git a/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch b/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch new file mode 100644 index 0000000000..008a62dcfd --- /dev/null +++ b/package/boot/kexec-tools/patches/0005-mips-fix-warning-about-implicit-type-conversion.patch @@ -0,0 +1,30 @@ +From 00e75179b3b4b80e6e58d29a2bd948f97682fd00 Mon Sep 17 00:00:00 2001 +From: Yousong Zhou +Date: Mon, 9 Feb 2015 20:28:14 +0800 +Subject: [PATCH 5/5] mips: fix warning about implicit type conversion. + +Fixes the following warning. + + kexec/arch/mips/kexec-elf-mips.c:161:16: warning: assignment makes integer from pointer without a cast [enabled by default] + +Signed-off-by: Yousong Zhou +--- + kexec/arch/mips/kexec-elf-mips.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kexec/arch/mips/kexec-elf-mips.c b/kexec/arch/mips/kexec-elf-mips.c +index a27d986..8a6419a 100644 +--- a/kexec/arch/mips/kexec-elf-mips.c ++++ b/kexec/arch/mips/kexec-elf-mips.c +@@ -158,7 +158,7 @@ int elf_mips_load(int argc, char **argv, const char *buf, off_t len, + if (info->kexec_flags & KEXEC_ON_CRASH) + /* In case of crashdump segment[0] is kernel. + * Put cmdline just after it. */ +- cmdline_addr = info->segment[0].mem + ++ cmdline_addr = (unsigned long)info->segment[0].mem + + info->segment[0].memsz; + else + cmdline_addr = 0; +-- +1.7.10.4 + diff --git a/package/boot/kexec-tools/patches/100-reduce_size.patch b/package/boot/kexec-tools/patches/100-reduce_size.patch deleted file mode 100644 index eafca7bf20..0000000000 --- a/package/boot/kexec-tools/patches/100-reduce_size.patch +++ /dev/null @@ -1,36 +0,0 @@ ---- a/kexec/crashdump-xen.c -+++ b/kexec/crashdump-xen.c -@@ -111,6 +111,7 @@ static int xen_detect_pv_guest(void) - * This includes dom0, which is the only PV guest where kexec/kdump works. - * HVM guests have to be handled as native hardware. - */ -+#if defined(__i386__) || defined(__x86_64__) - int xen_present(void) - { - if (!is_dom0) { -@@ -121,6 +122,7 @@ int xen_present(void) - } - return is_dom0 > 0; - } -+#endif - - unsigned long xen_architecture(struct crash_elf_info *elf_info) - { ---- a/kexec/crashdump.h -+++ b/kexec/crashdump.h -@@ -56,7 +56,15 @@ unsigned long crash_architecture(struct - unsigned long phys_to_virt(struct crash_elf_info *elf_info, - unsigned long paddr); - -+#if defined(__i386__) || defined(__x86_64__) - int xen_present(void); -+#else -+static inline int xen_present(void) -+{ -+ return 0; -+} -+#endif -+ - unsigned long xen_architecture(struct crash_elf_info *elf_info); - int xen_get_nr_phys_cpus(void); - int xen_get_note(int cpu, uint64_t *addr, uint64_t *len); -- 2.25.1