diff --git a/0001-kexec-tools-2.0.14.git.patch b/0001-kexec-tools-2.0.14.git.patch deleted file mode 100644 index 83301d6..0000000 --- a/0001-kexec-tools-2.0.14.git.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 9da19c0a6f49b5577b147053f2c3226a8ce97d4e Mon Sep 17 00:00:00 2001 -From: Simon Horman -Date: Tue, 20 Dec 2016 09:18:50 +0100 -Subject: [PATCH 01/45] kexec-tools 2.0.14.git - -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 ---- - configure.ac | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/configure.ac b/configure.ac -index 53962562db08..304418539be8 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -4,7 +4,7 @@ dnl - dnl - - dnl ---Required --AC_INIT(kexec-tools, 2.0.14) -+AC_INIT(kexec-tools, 2.0.14.git) - AC_CONFIG_AUX_DIR(./config) - AC_CONFIG_HEADERS([include/config.h]) - AC_LANG(C) --- -2.13.0 - diff --git a/0002-ppc64-Reduce-number-of-ELF-LOAD-segments.patch b/0002-ppc64-Reduce-number-of-ELF-LOAD-segments.patch deleted file mode 100644 index 51f812c..0000000 --- a/0002-ppc64-Reduce-number-of-ELF-LOAD-segments.patch +++ /dev/null @@ -1,66 +0,0 @@ -From f63d8530b9b6a2d7e79b946e326e5a2197eb8f87 Mon Sep 17 00:00:00 2001 -From: Petr Tesarik -Date: Thu, 19 Jan 2017 18:37:09 +0100 -Subject: [PATCH 02/45] ppc64: Reduce number of ELF LOAD segments - -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 -Signed-off-by: Simon Horman ---- - kexec/arch/ppc64/crashdump-ppc64.c | 12 +++++++++++- - 1 file changed, 11 insertions(+), 1 deletion(-) - -diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c -index b3c89285a733..f62b1599c162 100644 ---- a/kexec/arch/ppc64/crashdump-ppc64.c -+++ b/kexec/arch/ppc64/crashdump-ppc64.c -@@ -123,6 +123,7 @@ static void exclude_crash_region(uint64_t start, uint64_t end) - static int get_dyn_reconf_crash_memory_ranges(void) - { - uint64_t start, end; -+ uint64_t startrange, endrange; - char fname[128], buf[32]; - FILE *file; - unsigned int i; -@@ -137,6 +138,7 @@ static int get_dyn_reconf_crash_memory_ranges(void) - } - - fseek(file, 4, SEEK_SET); -+ startrange = endrange = 0; - for (i = 0; i < num_of_lmbs; i++) { - if ((n = fread(buf, 1, 24, file)) < 0) { - perror(fname); -@@ -162,8 +164,16 @@ static int get_dyn_reconf_crash_memory_ranges(void) - if ((flags & 0x80) || !(flags & 0x8)) - continue; - -- exclude_crash_region(start, end); -+ if (start != endrange) { -+ if (startrange != endrange) -+ exclude_crash_region(startrange, endrange); -+ startrange = start; -+ } -+ endrange = end; - } -+ if (startrange != endrange) -+ exclude_crash_region(startrange, endrange); -+ - fclose(file); - return 0; - } --- -2.13.0 - diff --git a/0003-kexec-Increase-the-upper-limit-for-RAM-segments.patch b/0003-kexec-Increase-the-upper-limit-for-RAM-segments.patch deleted file mode 100644 index 4425ec1..0000000 --- a/0003-kexec-Increase-the-upper-limit-for-RAM-segments.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 24aa2d93cac316657a2c20f28b8687bbf7e22991 Mon Sep 17 00:00:00 2001 -From: Sameer Goel -Date: Wed, 18 Jan 2017 16:15:12 -0700 -Subject: [PATCH 03/45] kexec: Increase the upper limit for RAM segments - -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 -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/kexec-arm64.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h -index bac62f8b19e0..bd4c20e76d15 100644 ---- a/kexec/arch/arm64/kexec-arm64.h -+++ b/kexec/arch/arm64/kexec-arm64.h -@@ -11,7 +11,7 @@ - #include "image-header.h" - #include "kexec.h" - --#define KEXEC_SEGMENT_MAX 16 -+#define KEXEC_SEGMENT_MAX 64 - - #define BOOT_BLOCK_VERSION 17 - #define BOOT_BLOCK_LAST_COMP_VERSION 16 --- -2.13.0 - diff --git a/0004-alpha-add-missing-__NR_kexec_load-definition.patch b/0004-alpha-add-missing-__NR_kexec_load-definition.patch deleted file mode 100644 index 7d7c5cb..0000000 --- a/0004-alpha-add-missing-__NR_kexec_load-definition.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 4eaa36cd01a972a602065ebade5ac46d1c81fba9 Mon Sep 17 00:00:00 2001 -From: Simon Horman -Date: Tue, 20 Dec 2016 09:29:18 +0100 -Subject: [PATCH 04/45] alpha: add missing __NR_kexec_load definition - -Signed-off-by: Simon Horman ---- - kexec/kexec-syscall.h | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h -index c0d0beadf932..3b5c528d8aac 100644 ---- a/kexec/kexec-syscall.h -+++ b/kexec/kexec-syscall.h -@@ -48,6 +48,9 @@ - #ifdef __m68k__ - #define __NR_kexec_load 313 - #endif -+#ifdef __alpha__ -+#define __NR_kexec_load 448 -+#endif - #ifndef __NR_kexec_load - #error Unknown processor architecture. Needs a kexec_load syscall number. - #endif --- -2.13.0 - diff --git a/0005-kexec-implemented-XEN-KEXEC-STATUS-to-determine-if-a.patch b/0005-kexec-implemented-XEN-KEXEC-STATUS-to-determine-if-a.patch deleted file mode 100644 index 3c6c0cf..0000000 --- a/0005-kexec-implemented-XEN-KEXEC-STATUS-to-determine-if-a.patch +++ /dev/null @@ -1,345 +0,0 @@ -From 2cf7cb9a60802cfdbd4ec51439b05b5ac6293ee6 Mon Sep 17 00:00:00 2001 -From: Eric DeVolder -Date: Wed, 25 Jan 2017 09:31:15 -0600 -Subject: [PATCH 05/45] kexec: implemented XEN KEXEC STATUS to determine if an - image is loaded - -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 -Signed-off-by: Eric DeVolder -Signed-off-by: Simon Horman ---- - configure.ac | 8 +++- - kexec/kexec-xen.c | 26 +++++++++++++ - kexec/kexec.8 | 6 +++ - kexec/kexec.c | 112 ++++++++++++++++++++++++++++++++++++++---------------- - kexec/kexec.h | 5 ++- - 5 files changed, 122 insertions(+), 35 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 304418539be8..53fffc3a92ed 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -165,8 +165,14 @@ 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_CHECK_LIB(xenctrl, xc_kexec_load, [ have_xenctrl_h=yes ], - AC_MSG_NOTICE([Xen support disabled]))]) -+ if test "$have_xenctrl_h" = yes ; then -+ AC_CHECK_LIB(xenctrl, xc_kexec_status, -+ AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1, -+ [The kexec_status call is available]), -+ AC_MSG_NOTICE([The kexec_status call is not available])) -+ fi - fi - - dnl ---Sanity checks -diff --git a/kexec/kexec-xen.c b/kexec/kexec-xen.c -index 24a41919ce6a..2b448d39ba2a 100644 ---- a/kexec/kexec-xen.c -+++ b/kexec/kexec-xen.c -@@ -105,6 +105,27 @@ int xen_kexec_unload(uint64_t kexec_flags) - return ret; - } - -+int xen_kexec_status(uint64_t kexec_flags) -+{ -+ xc_interface *xch; -+ uint8_t type; -+ int ret = -1; -+ -+#ifdef HAVE_KEXEC_CMD_STATUS -+ xch = xc_interface_open(NULL, NULL, 0); -+ if (!xch) -+ return -1; -+ -+ type = (kexec_flags & KEXEC_ON_CRASH) ? KEXEC_TYPE_CRASH : KEXEC_TYPE_DEFAULT; -+ -+ ret = xc_kexec_status(xch, type); -+ -+ xc_interface_close(xch); -+#endif -+ -+ return ret; -+} -+ - void xen_kexec_exec(void) - { - xc_interface *xch; -@@ -130,6 +151,11 @@ int xen_kexec_unload(uint64_t kexec_flags) - return -1; - } - -+int xen_kexec_status(uint64_t kexec_flags) -+{ -+ return -1; -+} -+ - void xen_kexec_exec(void) - { - } -diff --git a/kexec/kexec.8 b/kexec/kexec.8 -index 4d0c1d1612e8..f4b39a656831 100644 ---- a/kexec/kexec.8 -+++ b/kexec/kexec.8 -@@ -107,6 +107,12 @@ command: - .B \-d\ (\-\-debug) - Enable debugging messages. - .TP -+.B \-S\ (\-\-status) -+Return 0 if the type (by default crash) is loaded. Can be used in conjuction -+with -l or -p to toggle the type. Note this option supersedes other options -+and it will -+.BR not\ load\ or\ unload\ the\ kernel. -+.TP - .B \-e\ (\-\-exec) - Run the currently loaded kernel. Note that it will reboot into the loaded kernel without calling shutdown(8). - .TP -diff --git a/kexec/kexec.c b/kexec/kexec.c -index 500e5a9e422b..ec16247a427f 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -51,6 +51,9 @@ - #include "kexec-lzma.h" - #include - -+#define KEXEC_LOADED_PATH "/sys/kernel/kexec_loaded" -+#define KEXEC_CRASH_LOADED_PATH "/sys/kernel/kexec_crash_loaded" -+ - unsigned long long mem_min = 0; - unsigned long long mem_max = ULONG_MAX; - static unsigned long kexec_flags = 0; -@@ -890,8 +893,6 @@ static int my_exec(void) - return -1; - } - --static int kexec_loaded(void); -- - static int load_jump_back_helper_image(unsigned long kexec_flags, void *entry) - { - int result; -@@ -902,6 +903,40 @@ static int load_jump_back_helper_image(unsigned long kexec_flags, void *entry) - return result; - } - -+static int kexec_loaded(const char *file) -+{ -+ long ret = -1; -+ FILE *fp; -+ char *p; -+ char line[3]; -+ -+ /* No way to tell if an image is loaded under Xen, assume it is. */ -+ if (xen_present()) -+ return 1; -+ -+ fp = fopen(file, "r"); -+ if (fp == NULL) -+ return -1; -+ -+ p = fgets(line, sizeof(line), fp); -+ fclose(fp); -+ -+ if (p == NULL) -+ return -1; -+ -+ ret = strtol(line, &p, 10); -+ -+ /* Too long */ -+ if (ret > INT_MAX) -+ return -1; -+ -+ /* No digits were found */ -+ if (p == line) -+ return -1; -+ -+ return (int)ret; -+} -+ - /* - * Jump back to the original kernel - */ -@@ -909,7 +944,7 @@ static int my_load_jump_back_helper(unsigned long kexec_flags, void *entry) - { - int result; - -- if (kexec_loaded()) { -+ if (kexec_loaded(KEXEC_LOADED_PATH)) { - fprintf(stderr, "There is kexec kernel loaded, make sure " - "you are in kexeced kernel.\n"); - return -1; -@@ -970,6 +1005,7 @@ void usage(void) - " to original kernel.\n" - " -s, --kexec-file-syscall Use file based syscall for kexec operation\n" - " -d, --debug Enable debugging to help spot a failure.\n" -+ " -S, --status Return 0 if the type (by default crash) is loaded.\n" - "\n" - "Supported kernel file types and options: \n"); - for (i = 0; i < file_types; i++) { -@@ -981,40 +1017,30 @@ void usage(void) - printf("\n"); - } - --static int kexec_loaded(void) -+static int k_status(unsigned long kexec_flags) - { -- long ret = -1; -- FILE *fp; -- char *p; -- char line[3]; -- -- /* No way to tell if an image is loaded under Xen, assume it is. */ -- if (xen_present()) -- return 1; -- -- fp = fopen("/sys/kernel/kexec_loaded", "r"); -- if (fp == NULL) -- return -1; -- -- p = fgets(line, sizeof(line), fp); -- fclose(fp); -- -- if (p == NULL) -- return -1; -- -- ret = strtol(line, &p, 10); -- -- /* Too long */ -- if (ret > INT_MAX) -- return -1; -+ int result; -+ long native_arch; - -- /* No digits were found */ -- if (p == line) -+ /* set the arch */ -+ native_arch = physical_arch(); -+ if (native_arch < 0) { - return -1; -+ } -+ kexec_flags |= native_arch; - -- return (int)ret; -+ if (xen_present()) -+ result = xen_kexec_status(kexec_flags); -+ else { -+ if (kexec_flags & KEXEC_ON_CRASH) -+ result = kexec_loaded(KEXEC_CRASH_LOADED_PATH); -+ else -+ result = kexec_loaded(KEXEC_LOADED_PATH); -+ } -+ return result; - } - -+ - /* - * Remove parameter from a kernel command line. Helper function by get_command_line(). - */ -@@ -1204,6 +1230,7 @@ int main(int argc, char *argv[]) - int do_unload = 0; - int do_reuse_initrd = 0; - int do_kexec_file_syscall = 0; -+ int do_status = 0; - void *entry = 0; - char *type = 0; - char *endptr; -@@ -1345,6 +1372,9 @@ int main(int argc, char *argv[]) - case OPT_KEXEC_FILE_SYSCALL: - /* We already parsed it. Nothing to do. */ - break; -+ case OPT_STATUS: -+ do_status = 1; -+ break; - default: - break; - } -@@ -1355,6 +1385,20 @@ int main(int argc, char *argv[]) - if (skip_sync) - do_sync = 0; - -+ if (do_status) { -+ if (kexec_flags == 0) -+ kexec_flags = KEXEC_ON_CRASH; -+ do_load = 0; -+ do_reuse_initrd = 0; -+ do_unload = 0; -+ do_load = 0; -+ do_shutdown = 0; -+ do_sync = 0; -+ do_ifdown = 0; -+ do_exec = 0; -+ do_load_jump_back_helper = 0; -+ } -+ - if (do_load && (kexec_flags & KEXEC_ON_CRASH) && - !is_crashkernel_mem_reserved()) { - die("Memory for crashkernel is not reserved\n" -@@ -1392,7 +1436,9 @@ int main(int argc, char *argv[]) - check_reuse_initrd(); - arch_reuse_initrd(); - } -- -+ if (do_status) { -+ result = k_status(kexec_flags); -+ } - if (do_unload) { - if (do_kexec_file_syscall) - result = kexec_file_unload(kexec_file_flags); -@@ -1408,7 +1454,7 @@ int main(int argc, char *argv[]) - kexec_flags, entry); - } - /* Don't shutdown unless there is something to reboot to! */ -- if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) { -+ if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded(KEXEC_LOADED_PATH)) { - die("Nothing has been loaded!\n"); - } - if ((result == 0) && do_shutdown) { -diff --git a/kexec/kexec.h b/kexec/kexec.h -index 9194f1c87c91..2b06f590b5ab 100644 ---- a/kexec/kexec.h -+++ b/kexec/kexec.h -@@ -219,6 +219,7 @@ extern int file_types; - #define OPT_TYPE 't' - #define OPT_PANIC 'p' - #define OPT_KEXEC_FILE_SYSCALL 's' -+#define OPT_STATUS 'S' - #define OPT_MEM_MIN 256 - #define OPT_MEM_MAX 257 - #define OPT_REUSE_INITRD 258 -@@ -245,8 +246,9 @@ extern int file_types; - { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ - { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ - { "debug", 0, 0, OPT_DEBUG }, \ -+ { "status", 0, 0, OPT_STATUS }, \ - --#define KEXEC_OPT_STR "h?vdfxyluet:ps" -+#define KEXEC_OPT_STR "h?vdfxyluet:psS" - - extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr); - extern void die(const char *fmt, ...) -@@ -311,5 +313,6 @@ int xen_present(void); - int xen_kexec_load(struct kexec_info *info); - int xen_kexec_unload(uint64_t kexec_flags); - void xen_kexec_exec(void); -+int xen_kexec_status(uint64_t kexec_flags); - - #endif /* KEXEC_H */ --- -2.13.0 - diff --git a/0006-kexec-Remove-redundant-space-from-help-message.patch b/0006-kexec-Remove-redundant-space-from-help-message.patch deleted file mode 100644 index 952429c..0000000 --- a/0006-kexec-Remove-redundant-space-from-help-message.patch +++ /dev/null @@ -1,28 +0,0 @@ -From ceedb33e6cd34d26008ded67d5f0726719f73a39 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Mon, 30 Jan 2017 12:14:25 -0600 -Subject: [PATCH 06/45] kexec: Remove redundant space from help message - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Signed-off-by: Simon Horman ---- - kexec/kexec.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/kexec/kexec.c b/kexec/kexec.c -index ec16247a427f..a2ba79d59006 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1004,7 +1004,7 @@ void usage(void) - " preserve context)\n" - " to original kernel.\n" - " -s, --kexec-file-syscall Use file based syscall for kexec operation\n" -- " -d, --debug Enable debugging to help spot a failure.\n" -+ " -d, --debug Enable debugging to help spot a failure.\n" - " -S, --status Return 0 if the type (by default crash) is loaded.\n" - "\n" - "Supported kernel file types and options: \n"); --- -2.13.0 - diff --git a/0007-purgatory-Add-purgatory.map-and-purgatory.ro.sym-to-.patch b/0007-purgatory-Add-purgatory.map-and-purgatory.ro.sym-to-.patch deleted file mode 100644 index 980cc76..0000000 --- a/0007-purgatory-Add-purgatory.map-and-purgatory.ro.sym-to-.patch +++ /dev/null @@ -1,29 +0,0 @@ -From e49623b0787d23f8f4f15d3ee3a1c81eb1f0da77 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Mon, 30 Jan 2017 12:14:24 -0600 -Subject: [PATCH 07/45] purgatory: Add purgatory.map and purgatory.ro.sym to - clean recipe - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Signed-off-by: Simon Horman ---- - purgatory/Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/purgatory/Makefile b/purgatory/Makefile -index 328904e24415..49ce80a638b2 100644 ---- a/purgatory/Makefile -+++ b/purgatory/Makefile -@@ -34,7 +34,7 @@ PURGATORY_SRCS+=$($(ARCH)_PURGATORY_SRCS) - PURGATORY_OBJS = $(call objify, $(PURGATORY_SRCS)) purgatory/sha256.o - PURGATORY_DEPS = $(call depify, $(PURGATORY_OBJS)) - --clean += $(PURGATORY_OBJS) $(PURGATORY_DEPS) $(PURGATORY) -+clean += $(PURGATORY_OBJS) $(PURGATORY_DEPS) $(PURGATORY) $(PURGATORY_MAP) $(PURGATORY).sym - - -include $(PURGATORY_DEPS) - --- -2.13.0 - diff --git a/0008-kexec-Add-option-to-get-crash-kernel-region-size.patch b/0008-kexec-Add-option-to-get-crash-kernel-region-size.patch deleted file mode 100644 index af67b34..0000000 --- a/0008-kexec-Add-option-to-get-crash-kernel-region-size.patch +++ /dev/null @@ -1,110 +0,0 @@ -From 76b31203222a9833f424e98a134603c2f840c82b Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:25 -0600 -Subject: [PATCH 08/45] kexec: Add option to get crash kernel region size - -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 -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/kexec.8 | 3 +++ - kexec/kexec.c | 16 ++++++++++++++++ - kexec/kexec.h | 4 +++- - 3 files changed, 22 insertions(+), 1 deletion(-) - -diff --git a/kexec/kexec.8 b/kexec/kexec.8 -index f4b39a656831..e0131b4ea827 100644 ---- a/kexec/kexec.8 -+++ b/kexec/kexec.8 -@@ -179,6 +179,9 @@ Load a helper image to jump back to original kernel. - .TP - .BI \-\-reuseinitrd - Reuse initrd from first boot. -+.TP -+.BI \-\-print-ckr-size -+Print crash kernel region size, if available. - - - .SH SUPPORTED KERNEL FILE TYPES AND OPTIONS -diff --git a/kexec/kexec.c b/kexec/kexec.c -index a2ba79d59006..cfd837c1b6bb 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -995,6 +995,7 @@ void usage(void) - " --mem-max= Specify the highest memory address to\n" - " load code into.\n" - " --reuseinitrd Reuse initrd from first boot.\n" -+ " --print-ckr-size Print crash kernel region size.\n" - " --load-preserve-context Load the new kernel and preserve\n" - " context of current kernel during kexec.\n" - " --load-jump-back-helper Load a helper image to jump back\n" -@@ -1218,6 +1219,18 @@ static int do_kexec_file_load(int fileind, int argc, char **argv, - return ret; - } - -+static void print_crashkernel_region_size(void) -+{ -+ uint64_t start = 0, end = 0; -+ -+ if (is_crashkernel_mem_reserved() && -+ get_crash_kernel_load_range(&start, &end)) { -+ fprintf(stderr, "get_crash_kernel_load_range() failed.\n"); -+ return; -+ } -+ -+ printf("%lu\n", (start != end) ? (end - start + 1) : 0UL); -+} - - int main(int argc, char *argv[]) - { -@@ -1375,6 +1388,9 @@ int main(int argc, char *argv[]) - case OPT_STATUS: - do_status = 1; - break; -+ case OPT_PRINT_CKR_SIZE: -+ print_crashkernel_region_size(); -+ return 0; - default: - break; - } -diff --git a/kexec/kexec.h b/kexec/kexec.h -index 2b06f590b5ab..52bef9b3c0f5 100644 ---- a/kexec/kexec.h -+++ b/kexec/kexec.h -@@ -226,7 +226,8 @@ extern int file_types; - #define OPT_LOAD_PRESERVE_CONTEXT 259 - #define OPT_LOAD_JUMP_BACK_HELPER 260 - #define OPT_ENTRY 261 --#define OPT_MAX 262 -+#define OPT_PRINT_CKR_SIZE 262 -+#define OPT_MAX 263 - #define KEXEC_OPTIONS \ - { "help", 0, 0, OPT_HELP }, \ - { "version", 0, 0, OPT_VERSION }, \ -@@ -247,6 +248,7 @@ extern int file_types; - { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ - { "debug", 0, 0, OPT_DEBUG }, \ - { "status", 0, 0, OPT_STATUS }, \ -+ { "print-ckr-size", 0, 0, OPT_PRINT_CKR_SIZE }, \ - - #define KEXEC_OPT_STR "h?vdfxyluet:psS" - --- -2.13.0 - diff --git a/0009-crashdump-arm-Add-get_crash_kernel_load_range-functi.patch b/0009-crashdump-arm-Add-get_crash_kernel_load_range-functi.patch deleted file mode 100644 index 88b2c21..0000000 --- a/0009-crashdump-arm-Add-get_crash_kernel_load_range-functi.patch +++ /dev/null @@ -1,33 +0,0 @@ -From cfcf60c38182fb97df3817ee6192190e66eb62ec Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:15 -0600 -Subject: [PATCH 09/45] crashdump/arm: Add get_crash_kernel_load_range() - function - -Implement get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/arm/crashdump-arm.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c -index 4a89b5ea9645..ac76e0a812d5 100644 ---- a/kexec/arch/arm/crashdump-arm.c -+++ b/kexec/arch/arm/crashdump-arm.c -@@ -413,3 +413,8 @@ int is_crashkernel_mem_reserved(void) - - return crash_kernel_mem.start != crash_kernel_mem.end; - } -+ -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ return parse_iomem_single("Crash kernel\n", start, end); -+} --- -2.13.0 - diff --git a/0010-crashdump-arm64-Add-get_crash_kernel_load_range-func.patch b/0010-crashdump-arm64-Add-get_crash_kernel_load_range-func.patch deleted file mode 100644 index afc0ab0..0000000 --- a/0010-crashdump-arm64-Add-get_crash_kernel_load_range-func.patch +++ /dev/null @@ -1,33 +0,0 @@ -From d43610084164aec742f9ec9bd87d87575397d666 Mon Sep 17 00:00:00 2001 -From: Eric DeVolder -Date: Fri, 17 Feb 2017 16:47:16 -0600 -Subject: [PATCH 10/45] crashdump/arm64: Add get_crash_kernel_load_range() - function - -Provide stub get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/crashdump-arm64.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c -index d2272c8124d0..b0e4713f12c6 100644 ---- a/kexec/arch/arm64/crashdump-arm64.c -+++ b/kexec/arch/arm64/crashdump-arm64.c -@@ -19,3 +19,9 @@ int is_crashkernel_mem_reserved(void) - { - return 0; - } -+ -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ /* Crash kernel region size is not exposed by the system */ -+ return -1; -+} --- -2.13.0 - diff --git a/0011-crashdump-cris-Add-get_crash_kernel_load_range-funct.patch b/0011-crashdump-cris-Add-get_crash_kernel_load_range-funct.patch deleted file mode 100644 index e3f4b17..0000000 --- a/0011-crashdump-cris-Add-get_crash_kernel_load_range-funct.patch +++ /dev/null @@ -1,37 +0,0 @@ -From b6af22826f6055757446cae394a475d179fb0b8b Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:17 -0600 -Subject: [PATCH 11/45] crashdump/cris: Add get_crash_kernel_load_range() - function - -Provide stub get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/cris/kexec-cris.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/kexec/arch/cris/kexec-cris.c b/kexec/arch/cris/kexec-cris.c -index 4ac2f8942996..3b69709d68cc 100644 ---- a/kexec/arch/cris/kexec-cris.c -+++ b/kexec/arch/cris/kexec-cris.c -@@ -77,6 +77,12 @@ int is_crashkernel_mem_reserved(void) - return 0; - } - -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ /* Crash kernel region size is not exposed by the system */ -+ return -1; -+} -+ - unsigned long virt_to_phys(unsigned long addr) - { - return (addr) & 0x7fffffff; --- -2.13.0 - diff --git a/0012-crashdump-ia64-Add-get_crash_kernel_load_range-funct.patch b/0012-crashdump-ia64-Add-get_crash_kernel_load_range-funct.patch deleted file mode 100644 index d32fd9b..0000000 --- a/0012-crashdump-ia64-Add-get_crash_kernel_load_range-funct.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 5c80bd9be2959adba8520222ce3456b1bc25cb79 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:18 -0600 -Subject: [PATCH 12/45] crashdump/ia64: Add get_crash_kernel_load_range() - function - -Implement get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/ia64/crashdump-ia64.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/kexec/arch/ia64/crashdump-ia64.c b/kexec/arch/ia64/crashdump-ia64.c -index 726c9f4281ba..755ee5e98566 100644 ---- a/kexec/arch/ia64/crashdump-ia64.c -+++ b/kexec/arch/ia64/crashdump-ia64.c -@@ -286,3 +286,8 @@ int is_crashkernel_mem_reserved(void) - return parse_iomem_single("Crash kernel\n", &start, - &end) == 0 ? (start != end) : 0; - } -+ -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ return parse_iomem_single("Crash kernel\n", start, end); -+} --- -2.13.0 - diff --git a/0013-crashdump-m68k-Add-get_crash_kernel_load_range-funct.patch b/0013-crashdump-m68k-Add-get_crash_kernel_load_range-funct.patch deleted file mode 100644 index bd5ba08..0000000 --- a/0013-crashdump-m68k-Add-get_crash_kernel_load_range-funct.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 14d71e51e5c95f18b1a3ea2cb143d85f7fe23e43 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:19 -0600 -Subject: [PATCH 13/45] crashdump/m68k: Add get_crash_kernel_load_range() - function - -Provide stub get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/m68k/kexec-m68k.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/kexec/arch/m68k/kexec-m68k.c b/kexec/arch/m68k/kexec-m68k.c -index 372aa378f9a1..cb5492785886 100644 ---- a/kexec/arch/m68k/kexec-m68k.c -+++ b/kexec/arch/m68k/kexec-m68k.c -@@ -89,6 +89,12 @@ int is_crashkernel_mem_reserved(void) - return 0; - } - -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ /* Crash kernel region size is not exposed by the system */ -+ return -1; -+} -+ - unsigned long virt_to_phys(unsigned long addr) - { - return addr + m68k_memoffset; --- -2.13.0 - diff --git a/0014-crashdump-mips-Add-get_crash_kernel_load_range-funct.patch b/0014-crashdump-mips-Add-get_crash_kernel_load_range-funct.patch deleted file mode 100644 index 059e347..0000000 --- a/0014-crashdump-mips-Add-get_crash_kernel_load_range-funct.patch +++ /dev/null @@ -1,32 +0,0 @@ -From d2caf4c4c43b300c3746d85791a650cdcf0ae733 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:20 -0600 -Subject: [PATCH 14/45] crashdump/mips: Add get_crash_kernel_load_range() - function - -Implement get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/mips/crashdump-mips.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c -index d6cff5ad8993..9c33599a34ed 100644 ---- a/kexec/arch/mips/crashdump-mips.c -+++ b/kexec/arch/mips/crashdump-mips.c -@@ -385,3 +385,7 @@ int is_crashkernel_mem_reserved(void) - (start != end) : 0; - } - -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ return parse_iomem_single("Crash kernel\n", start, end); -+} --- -2.13.0 - diff --git a/0015-crashdump-ppc-Add-get_crash_kernel_load_range-functi.patch b/0015-crashdump-ppc-Add-get_crash_kernel_load_range-functi.patch deleted file mode 100644 index 11fbe6e..0000000 --- a/0015-crashdump-ppc-Add-get_crash_kernel_load_range-functi.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 7fc80cfcd913897ea92889349d51c1dd33d2c4ed Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:21 -0600 -Subject: [PATCH 15/45] crashdump/ppc: Add get_crash_kernel_load_range() - function - -Implement get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/ppc/crashdump-powerpc.c | 22 +++++++++++++++++++++- - kexec/arch/ppc/kexec-ppc.c | 24 ++++++++++++++++++++++++ - kexec/arch/ppc/kexec-ppc.h | 1 + - 3 files changed, 46 insertions(+), 1 deletion(-) - -diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c -index 3dc35ebe8866..dde6de7ec7a1 100644 ---- a/kexec/arch/ppc/crashdump-powerpc.c -+++ b/kexec/arch/ppc/crashdump-powerpc.c -@@ -16,6 +16,9 @@ - #include "kexec-ppc.h" - #include "crashdump-powerpc.h" - -+#define DEVTREE_CRASHKERNEL_BASE "/proc/device-tree/chosen/linux,crashkernel-base" -+#define DEVTREE_CRASHKERNEL_SIZE "/proc/device-tree/chosen/linux,crashkernel-size" -+ - #ifdef CONFIG_PPC64 - static struct crash_elf_info elf_info64 = { - class: ELFCLASS64, -@@ -397,11 +400,28 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size) - usablemem_rgns.size, base, size); - } - -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ unsigned long long value; -+ -+ if (!get_devtree_value(DEVTREE_CRASHKERNEL_BASE, &value)) -+ *start = value; -+ else -+ return -1; -+ -+ if (!get_devtree_value(DEVTREE_CRASHKERNEL_SIZE, &value)) -+ *end = *start + value - 1; -+ else -+ return -1; -+ -+ return 0; -+} -+ - int is_crashkernel_mem_reserved(void) - { - int fd; - -- fd = open("/proc/device-tree/chosen/linux,crashkernel-base", O_RDONLY); -+ fd = open(DEVTREE_CRASHKERNEL_BASE, O_RDONLY); - if (fd < 0) - return 0; - close(fd); -diff --git a/kexec/arch/ppc/kexec-ppc.c b/kexec/arch/ppc/kexec-ppc.c -index d04611092a1b..03bec36302f7 100644 ---- a/kexec/arch/ppc/kexec-ppc.c -+++ b/kexec/arch/ppc/kexec-ppc.c -@@ -423,6 +423,30 @@ err_out: - return -1; - } - -+/* Return 0 if fname/value valid, -1 otherwise */ -+int get_devtree_value(const char *fname, unsigned long long *value) -+{ -+ FILE *file; -+ char buf[MAXBYTES]; -+ int n = -1; -+ -+ if ((file = fopen(fname, "r"))) { -+ n = fread(buf, 1, MAXBYTES, file); -+ fclose(file); -+ } -+ -+ if (n == sizeof(uint32_t)) -+ *value = ((uint32_t *)buf)[0]; -+ else if (n == sizeof(uint64_t)) -+ *value = ((uint64_t *)buf)[0]; -+ else { -+ fprintf(stderr, "%s node has invalid size: %d\n", fname, n); -+ return -1; -+ } -+ -+ return 0; -+} -+ - /* Get devtree details and create exclude_range array - * Also create usablemem_ranges for KEXEC_ON_CRASH - */ -diff --git a/kexec/arch/ppc/kexec-ppc.h b/kexec/arch/ppc/kexec-ppc.h -index 904cf48ffe98..f8fd67827e43 100644 ---- a/kexec/arch/ppc/kexec-ppc.h -+++ b/kexec/arch/ppc/kexec-ppc.h -@@ -75,6 +75,7 @@ extern unsigned long dt_address_cells, dt_size_cells; - extern int init_memory_region_info(void); - extern int read_memory_region_limits(int fd, unsigned long long *start, - unsigned long long *end); -+extern int get_devtree_value(const char *fname, unsigned long long *pvalue); - #define COMMAND_LINE_SIZE 512 /* from kernel */ - /*fs2dt*/ - void reserve(unsigned long long where, unsigned long long length); --- -2.13.0 - diff --git a/0016-crashdump-ppc64-Add-get_crash_kernel_load_range-func.patch b/0016-crashdump-ppc64-Add-get_crash_kernel_load_range-func.patch deleted file mode 100644 index 4eed538..0000000 --- a/0016-crashdump-ppc64-Add-get_crash_kernel_load_range-func.patch +++ /dev/null @@ -1,114 +0,0 @@ -From e4280e22c8c45cab1f86860f1fc0beddda77a3a9 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:22 -0600 -Subject: [PATCH 16/45] crashdump/ppc64: Add get_crash_kernel_load_range() - function - -Implement get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/ppc64/crashdump-ppc64.c | 22 +++++++++++++++++++++- - kexec/arch/ppc64/kexec-ppc64.c | 24 ++++++++++++++++++++++++ - kexec/arch/ppc64/kexec-ppc64.h | 2 ++ - 3 files changed, 47 insertions(+), 1 deletion(-) - -diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c -index f62b1599c162..5a71d5161c87 100644 ---- a/kexec/arch/ppc64/crashdump-ppc64.c -+++ b/kexec/arch/ppc64/crashdump-ppc64.c -@@ -36,6 +36,9 @@ - #include "../../fs2dt.h" - #include "crashdump-ppc64.h" - -+#define DEVTREE_CRASHKERNEL_BASE "/proc/device-tree/chosen/linux,crashkernel-base" -+#define DEVTREE_CRASHKERNEL_SIZE "/proc/device-tree/chosen/linux,crashkernel-size" -+ - static struct crash_elf_info elf_info64 = - { - class: ELFCLASS64, -@@ -526,11 +529,28 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size) - usablemem_rgns.size, base, size); - } - -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ unsigned long long value; -+ -+ if (!get_devtree_value(DEVTREE_CRASHKERNEL_BASE, &value)) -+ *start = value; -+ else -+ return -1; -+ -+ if (!get_devtree_value(DEVTREE_CRASHKERNEL_SIZE, &value)) -+ *end = *start + value - 1; -+ else -+ return -1; -+ -+ return 0; -+} -+ - int is_crashkernel_mem_reserved(void) - { - int fd; - -- fd = open("/proc/device-tree/chosen/linux,crashkernel-base", O_RDONLY); -+ fd = open(DEVTREE_CRASHKERNEL_BASE, O_RDONLY); - if (fd < 0) - return 0; - close(fd); -diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c -index 09ee0256ed05..6e8c175878a4 100644 ---- a/kexec/arch/ppc64/kexec-ppc64.c -+++ b/kexec/arch/ppc64/kexec-ppc64.c -@@ -356,6 +356,30 @@ void scan_reserved_ranges(unsigned long kexec_flags, int *range_index) - *range_index = i; - } - -+/* Return 0 if fname/value valid, -1 otherwise */ -+int get_devtree_value(const char *fname, unsigned long long *value) -+{ -+ FILE *file; -+ char buf[MAXBYTES]; -+ int n = -1; -+ -+ if ((file = fopen(fname, "r"))) { -+ n = fread(buf, 1, MAXBYTES, file); -+ fclose(file); -+ } -+ -+ if (n == sizeof(uint32_t)) -+ *value = ((uint32_t *)buf)[0]; -+ else if (n == sizeof(uint64_t)) -+ *value = ((uint64_t *)buf)[0]; -+ else { -+ fprintf(stderr, "%s node has invalid size: %d\n", fname, n); -+ return -1; -+ } -+ -+ return 0; -+} -+ - /* Get devtree details and create exclude_range array - * Also create usablemem_ranges for KEXEC_ON_CRASH - */ -diff --git a/kexec/arch/ppc64/kexec-ppc64.h b/kexec/arch/ppc64/kexec-ppc64.h -index 89ee94279301..633ae776dcdd 100644 ---- a/kexec/arch/ppc64/kexec-ppc64.h -+++ b/kexec/arch/ppc64/kexec-ppc64.h -@@ -14,6 +14,8 @@ - #define HAVE_DYNAMIC_MEMORY - #define NEED_RESERVE_DTB - -+extern int get_devtree_value(const char *fname, unsigned long long *pvalue); -+ - int setup_memory_ranges(unsigned long kexec_flags); - - int elf_ppc64_probe(const char *buf, off_t len); --- -2.13.0 - diff --git a/0017-crashdump-s390-Add-get_crash_kernel_load_range-funct.patch b/0017-crashdump-s390-Add-get_crash_kernel_load_range-funct.patch deleted file mode 100644 index 8e76122..0000000 --- a/0017-crashdump-s390-Add-get_crash_kernel_load_range-funct.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 796f0ffa134d94f48aa58c4f2f0f85a443b7a225 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:23 -0600 -Subject: [PATCH 17/45] crashdump/s390: Add get_crash_kernel_load_range() - function - -Implement get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/s390/kexec-s390.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/kexec/arch/s390/kexec-s390.c b/kexec/arch/s390/kexec-s390.c -index 074575e5d783..f863483ce808 100644 ---- a/kexec/arch/s390/kexec-s390.c -+++ b/kexec/arch/s390/kexec-s390.c -@@ -262,3 +262,8 @@ int is_crashkernel_mem_reserved(void) - return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ? - (start != end) : 0; - } -+ -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ return parse_iomem_single("Crash kernel\n", start, end); -+} --- -2.13.0 - diff --git a/0018-crashdump-sh-Add-get_crash_kernel_load_range-functio.patch b/0018-crashdump-sh-Add-get_crash_kernel_load_range-functio.patch deleted file mode 100644 index e85c423..0000000 --- a/0018-crashdump-sh-Add-get_crash_kernel_load_range-functio.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 05ae4fb2e354e0f640d77957ee4c7dcb0eddc5f3 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Fri, 17 Feb 2017 16:47:24 -0600 -Subject: [PATCH 18/45] crashdump/sh: Add get_crash_kernel_load_range() - function - -Implement get_crash_kernel_load_range() in support of -print crash kernel region size option. - -Signed-off-by: Daniel Kiper -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/arch/sh/crashdump-sh.c | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/kexec/arch/sh/crashdump-sh.c b/kexec/arch/sh/crashdump-sh.c -index 9e6af6bf54bf..aa25dea353c3 100644 ---- a/kexec/arch/sh/crashdump-sh.c -+++ b/kexec/arch/sh/crashdump-sh.c -@@ -178,3 +178,8 @@ int is_crashkernel_mem_reserved(void) - return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ? - (start != end) : 0; - } -+ -+int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -+{ -+ return parse_iomem_single("Crash kernel\n", start, end); -+} --- -2.13.0 - diff --git a/0019-gitignore-add-two-generated-files-in-purgatory.patch b/0019-gitignore-add-two-generated-files-in-purgatory.patch deleted file mode 100644 index 0f44dec..0000000 --- a/0019-gitignore-add-two-generated-files-in-purgatory.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 7dac152d5b47f5e505994026cbfec30dee1a0941 Mon Sep 17 00:00:00 2001 -From: Eric DeVolder -Date: Fri, 10 Feb 2017 16:20:05 -0600 -Subject: [PATCH 19/45] gitignore: add two generated files in purgatory - -This patch adds the two generated files below to .gitignore. - -purgatory/purgatory.map -purgatory/purgatory.ro.sym - -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - .gitignore | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/.gitignore b/.gitignore -index 81e03abcb0b8..1ab52d952d49 100644 ---- a/.gitignore -+++ b/.gitignore -@@ -17,3 +17,5 @@ - /configure - /include/config.h.in - /include/config.h -+/purgatory/purgatory.map -+/purgatory/purgatory.ro.sym --- -2.13.0 - diff --git a/0020-Only-print-debug-message-when-failed-to-serach-for-k.patch b/0020-Only-print-debug-message-when-failed-to-serach-for-k.patch deleted file mode 100644 index 51c95c8..0000000 --- a/0020-Only-print-debug-message-when-failed-to-serach-for-k.patch +++ /dev/null @@ -1,39 +0,0 @@ -From 263e45ccf27b21e9862cc538ed28978533d04e4b Mon Sep 17 00:00:00 2001 -From: Baoquan He -Date: Fri, 3 Mar 2017 11:52:15 +0800 -Subject: [PATCH 20/45] Only print debug message when failed to serach for - kernel symbol from /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 -Reviewed-by: Pratyush Anand -Acked-by: Dave Young -Signed-off-by: Simon Horman ---- - kexec/arch/i386/crashdump-x86.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c -index 88aeee33572b..c4cf2013a001 100644 ---- a/kexec/arch/i386/crashdump-x86.c -+++ b/kexec/arch/i386/crashdump-x86.c -@@ -127,7 +127,7 @@ static unsigned long long get_kernel_sym(const char *symbol) - } - } - -- fprintf(stderr, "Cannot get kernel %s symbol address\n", symbol); -+ dbgprintf("Cannot get kernel %s symbol address\n", symbol); - return 0; - } - --- -2.13.0 - diff --git a/0021-build_mem_phdrs-check-if-p_paddr-is-invalid.patch b/0021-build_mem_phdrs-check-if-p_paddr-is-invalid.patch deleted file mode 100644 index 5bb1945..0000000 --- a/0021-build_mem_phdrs-check-if-p_paddr-is-invalid.patch +++ /dev/null @@ -1,42 +0,0 @@ -From ed15ba1b9977e506637ff1697821d97127b2c919 Mon Sep 17 00:00:00 2001 -From: Pratyush Anand -Date: Wed, 1 Mar 2017 11:19:42 +0530 -Subject: [PATCH 21/45] build_mem_phdrs(): check if p_paddr is invalid - -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 -Acked-by: Dave Young -Signed-off-by: Simon Horman ---- - kexec/kexec-elf.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/kexec/kexec-elf.c b/kexec/kexec-elf.c -index 1d6320a2f0e6..be60bbd48486 100644 ---- a/kexec/kexec-elf.c -+++ b/kexec/kexec-elf.c -@@ -432,7 +432,8 @@ static int build_mem_phdrs(const char *buf, off_t len, struct mem_ehdr *ehdr, - } - return -1; - } -- if ((phdr->p_paddr + phdr->p_memsz) < phdr->p_paddr) { -+ if (phdr->p_paddr != (unsigned long long)-1 && -+ (phdr->p_paddr + phdr->p_memsz) < phdr->p_paddr) { - /* The memory address wraps */ - if (probe_debug) { - fprintf(stderr, "ELF address wrap around\n"); --- -2.13.0 - diff --git a/0022-uImage-fix-realloc-pointer-confusion.patch b/0022-uImage-fix-realloc-pointer-confusion.patch deleted file mode 100644 index c8d7236..0000000 --- a/0022-uImage-fix-realloc-pointer-confusion.patch +++ /dev/null @@ -1,41 +0,0 @@ -From 0cc1891c4dc84a2cbbd1f126134ce51538f260dc Mon Sep 17 00:00:00 2001 -From: David Woodhouse -Date: Wed, 8 Mar 2017 22:41:08 +0000 -Subject: [PATCH 22/45] uImage: fix realloc() pointer confusion - -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 -Signed-off-by: Simon Horman ---- - kexec/kexec-uImage.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c -index 5e24629880bc..667cd932fd27 100644 ---- a/kexec/kexec-uImage.c -+++ b/kexec/kexec-uImage.c -@@ -210,9 +210,9 @@ static int uImage_gz_load(const unsigned char *buf, off_t len, - return -1; - } - -+ uncomp_buf = new_buf; - strm.next_out = uncomp_buf + mem_alloc - inc_buf; - strm.avail_out = inc_buf; -- uncomp_buf = new_buf; - } else { - printf("Error during decompression %d\n", ret); - return -1; --- -2.13.0 - diff --git a/0023-uImage-Fix-uImage_load-for-little-endian-machines.patch b/0023-uImage-Fix-uImage_load-for-little-endian-machines.patch deleted file mode 100644 index ec2095d..0000000 --- a/0023-uImage-Fix-uImage_load-for-little-endian-machines.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 67234243bb91052b816cdc8b922cd4bab21f22dd Mon Sep 17 00:00:00 2001 -From: David Woodhouse -Date: Wed, 8 Mar 2017 22:41:09 +0000 -Subject: [PATCH 23/45] uImage: Fix uImage_load() for little-endian machines - -Signed-off-by: David Woodhouse -Signed-off-by: Simon Horman ---- - kexec/kexec-uImage.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c -index 667cd932fd27..49f266aa4ecb 100644 ---- a/kexec/kexec-uImage.c -+++ b/kexec/kexec-uImage.c -@@ -236,7 +236,7 @@ int uImage_load(const unsigned char *buf, off_t len, struct Image_info *image) - { - const struct image_header *header = (const struct image_header *)buf; - const unsigned char *img_buf = buf + sizeof(struct image_header); -- off_t img_len = header->ih_size; -+ off_t img_len = be32_to_cpu(header->ih_size); - - /* - * Prevent loading a modified image. --- -2.13.0 - diff --git a/0024-uImage-Add-new-IH_ARCH_xxx-definitions.patch b/0024-uImage-Add-new-IH_ARCH_xxx-definitions.patch deleted file mode 100644 index 85676b9..0000000 --- a/0024-uImage-Add-new-IH_ARCH_xxx-definitions.patch +++ /dev/null @@ -1,32 +0,0 @@ -From b3d533c1f499dba5eb1fba57e08ff0c1059aed3f Mon Sep 17 00:00:00 2001 -From: David Woodhouse -Date: Wed, 8 Mar 2017 22:41:10 +0000 -Subject: [PATCH 24/45] uImage: Add new IH_ARCH_xxx definitions - -Signed-off-by: David Woodhouse -Signed-off-by: Simon Horman ---- - include/image.h | 7 +++++++ - 1 file changed, 7 insertions(+) - -diff --git a/include/image.h b/include/image.h -index e742aae739fd..8e9d81e24a41 100644 ---- a/include/image.h -+++ b/include/image.h -@@ -79,6 +79,13 @@ - #define IH_ARCH_BLACKFIN 16 /* Blackfin */ - #define IH_ARCH_AVR32 17 /* AVR32 */ - #define IH_ARCH_ST200 18 /* STMicroelectronics ST200 */ -+#define IH_ARCH_SANDBOX 19 /* Sandbox architecture (test only) */ -+#define IH_ARCH_NDS32 20 /* ANDES Technology - NDS32 */ -+#define IH_ARCH_OPENRISC 21 /* OpenRISC 1000 */ -+#define IH_ARCH_ARM64 22 /* ARM64 */ -+#define IH_ARCH_ARC 23 /* Synopsys DesignWare ARC */ -+#define IH_ARCH_X86_64 24 /* AMD x86_64, Intel and Via */ -+#define IH_ARCH_XTENSA 25 /* Xtensa */ - - /* - * Image Types --- -2.13.0 - diff --git a/0025-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch b/0025-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch deleted file mode 100644 index a1fe168..0000000 --- a/0025-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch +++ /dev/null @@ -1,83 +0,0 @@ -From f25146afc5a90bdaa5b518d05eda40410f6744a2 Mon Sep 17 00:00:00 2001 -From: David Woodhouse -Date: Wed, 8 Mar 2017 22:41:11 +0000 -Subject: [PATCH 25/45] uImage: use 'char *' instead of 'unsigned char *' for - uImage_load() - -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 -Signed-off-by: Simon Horman ---- - include/kexec-uImage.h | 4 ++-- - kexec/arch/ppc/kexec-uImage-ppc.c | 2 +- - kexec/kexec-uImage.c | 6 +++--- - 3 files changed, 6 insertions(+), 6 deletions(-) - -diff --git a/include/kexec-uImage.h b/include/kexec-uImage.h -index 4725157bd576..483b578adee1 100644 ---- a/include/kexec-uImage.h -+++ b/include/kexec-uImage.h -@@ -2,7 +2,7 @@ - #define __KEXEC_UIMAGE_H__ - - struct Image_info { -- const unsigned char *buf; -+ const char *buf; - off_t len; - unsigned int base; - unsigned int ep; -@@ -11,5 +11,5 @@ struct Image_info { - int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch); - int uImage_probe_kernel(const unsigned char *buf, off_t len, unsigned int arch); - int uImage_probe_ramdisk(const unsigned char *buf, off_t len, unsigned int arch); --int uImage_load(const unsigned char *buf, off_t len, struct Image_info *info); -+int uImage_load(const char *buf, off_t len, struct Image_info *info); - #endif -diff --git a/kexec/arch/ppc/kexec-uImage-ppc.c b/kexec/arch/ppc/kexec-uImage-ppc.c -index c89a1a77926d..5eec6e418a58 100644 ---- a/kexec/arch/ppc/kexec-uImage-ppc.c -+++ b/kexec/arch/ppc/kexec-uImage-ppc.c -@@ -55,7 +55,7 @@ char *slurp_ramdisk_ppc(const char *filename, off_t *r_size) - { - struct Image_info img; - off_t size; -- const unsigned char *buf = slurp_file(filename, &size); -+ const char *buf = slurp_file(filename, &size); - int rc; - - /* Check if this is a uImage RAMDisk */ -diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c -index 49f266aa4ecb..2740a26b6d6c 100644 ---- a/kexec/kexec-uImage.c -+++ b/kexec/kexec-uImage.c -@@ -136,7 +136,7 @@ int uImage_probe_ramdisk(const unsigned char *buf, off_t len, unsigned int arch) - #define COMMENT 0x10 /* bit 4 set: file comment present */ - #define RESERVED 0xE0 /* bits 5..7: reserved */ - --static int uImage_gz_load(const unsigned char *buf, off_t len, -+static int uImage_gz_load(const char *buf, off_t len, - struct Image_info *image) - { - int ret; -@@ -225,14 +225,14 @@ static int uImage_gz_load(const unsigned char *buf, off_t len, - return 0; - } - #else --static int uImage_gz_load(const unsigned char *UNUSED(buf), off_t UNUSED(len), -+static int uImage_gz_load(const char *UNUSED(buf), off_t UNUSED(len), - struct Image_info *UNUSED(image)) - { - return -1; - } - #endif - --int uImage_load(const unsigned char *buf, off_t len, struct Image_info *image) -+int uImage_load(const char *buf, off_t len, struct Image_info *image) - { - const struct image_header *header = (const struct image_header *)buf; - const unsigned char *img_buf = buf + sizeof(struct image_header); --- -2.13.0 - diff --git a/0026-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch b/0026-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch deleted file mode 100644 index 710bb3d..0000000 --- a/0026-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch +++ /dev/null @@ -1,100 +0,0 @@ -From a0c575793b86ebdcf7260ffc7ebbebb912e7ecf4 Mon Sep 17 00:00:00 2001 -From: David Woodhouse -Date: Wed, 8 Mar 2017 22:41:12 +0000 -Subject: [PATCH 26/45] uImage: use 'char *' instead of 'unsigned char *' for - uImage_probe() - -... 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 -Signed-off-by: Simon Horman ---- - include/kexec-uImage.h | 6 +++--- - kexec/arch/arm/kexec-uImage-arm.c | 3 +-- - kexec/kexec-uImage.c | 10 +++++----- - 3 files changed, 9 insertions(+), 10 deletions(-) - -diff --git a/include/kexec-uImage.h b/include/kexec-uImage.h -index 483b578adee1..983d63f7f420 100644 ---- a/include/kexec-uImage.h -+++ b/include/kexec-uImage.h -@@ -8,8 +8,8 @@ struct Image_info { - unsigned int ep; - }; - --int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch); --int uImage_probe_kernel(const unsigned char *buf, off_t len, unsigned int arch); --int uImage_probe_ramdisk(const unsigned char *buf, off_t len, unsigned int arch); -+int uImage_probe(const char *buf, off_t len, unsigned int arch); -+int uImage_probe_kernel(const char *buf, off_t len, unsigned int arch); -+int uImage_probe_ramdisk(const char *buf, off_t len, unsigned int arch); - int uImage_load(const char *buf, off_t len, struct Image_info *info); - #endif -diff --git a/kexec/arch/arm/kexec-uImage-arm.c b/kexec/arch/arm/kexec-uImage-arm.c -index 8e0a9ac6d242..03c2f4ddca7b 100644 ---- a/kexec/arch/arm/kexec-uImage-arm.c -+++ b/kexec/arch/arm/kexec-uImage-arm.c -@@ -11,8 +11,7 @@ - - int uImage_arm_probe(const char *buf, off_t len) - { -- return uImage_probe_kernel((const unsigned char *)buf, len, -- IH_ARCH_ARM); -+ return uImage_probe_kernel(buf, len, IH_ARCH_ARM); - } - - int uImage_arm_load(int argc, char **argv, const char *buf, off_t len, -diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c -index 2740a26b6d6c..eeee4be10f41 100644 ---- a/kexec/kexec-uImage.c -+++ b/kexec/kexec-uImage.c -@@ -24,7 +24,7 @@ - * - * Returns 0 if this is not a uImage - */ --int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch) -+int uImage_probe(const char *buf, off_t len, unsigned int arch) - { - struct image_header header; - #ifdef HAVE_LIBZ -@@ -109,7 +109,7 @@ int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch) - * 1 - If the image is not a uImage. - */ - --int uImage_probe_kernel(const unsigned char *buf, off_t len, unsigned int arch) -+int uImage_probe_kernel(const char *buf, off_t len, unsigned int arch) - { - int type = uImage_probe(buf, len, arch); - if (type < 0) -@@ -118,7 +118,7 @@ int uImage_probe_kernel(const unsigned char *buf, off_t len, unsigned int arch) - return !(type == IH_TYPE_KERNEL || type == IH_TYPE_KERNEL_NOLOAD); - } - --int uImage_probe_ramdisk(const unsigned char *buf, off_t len, unsigned int arch) -+int uImage_probe_ramdisk(const char *buf, off_t len, unsigned int arch) - { - int type = uImage_probe(buf, len, arch); - -@@ -220,7 +220,7 @@ static int uImage_gz_load(const char *buf, off_t len, - } while (1); - - inflateEnd(&strm); -- image->buf = uncomp_buf; -+ image->buf = (char *)uncomp_buf; - image->len = mem_alloc - strm.avail_out; - return 0; - } -@@ -235,7 +235,7 @@ static int uImage_gz_load(const char *UNUSED(buf), off_t UNUSED(len), - int uImage_load(const char *buf, off_t len, struct Image_info *image) - { - const struct image_header *header = (const struct image_header *)buf; -- const unsigned char *img_buf = buf + sizeof(struct image_header); -+ const char *img_buf = buf + sizeof(struct image_header); - off_t img_len = be32_to_cpu(header->ih_size); - - /* --- -2.13.0 - diff --git a/0027-arm64-add-uImage-support.patch b/0027-arm64-add-uImage-support.patch deleted file mode 100644 index 25b9a7a..0000000 --- a/0027-arm64-add-uImage-support.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 896fb2aa30c6acf0c651ba80e4ef661517b4aac4 Mon Sep 17 00:00:00 2001 -From: David Woodhouse -Date: Wed, 8 Mar 2017 22:41:13 +0000 -Subject: [PATCH 27/45] arm64: add uImage support - -Signed-off-by: David Woodhouse -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/Makefile | 3 +++ - kexec/arch/arm64/kexec-arm64.c | 1 + - kexec/arch/arm64/kexec-arm64.h | 4 ++++ - kexec/arch/arm64/kexec-uImage-arm64.c | 34 ++++++++++++++++++++++++++++++++++ - 4 files changed, 42 insertions(+) - create mode 100644 kexec/arch/arm64/kexec-uImage-arm64.c - -diff --git a/kexec/arch/arm64/Makefile b/kexec/arch/arm64/Makefile -index 74b677f7784e..a931f0e94012 100644 ---- a/kexec/arch/arm64/Makefile -+++ b/kexec/arch/arm64/Makefile -@@ -12,8 +12,11 @@ arm64_KEXEC_SRCS += \ - kexec/arch/arm64/crashdump-arm64.c \ - kexec/arch/arm64/kexec-arm64.c \ - kexec/arch/arm64/kexec-elf-arm64.c \ -+ kexec/arch/arm64/kexec-uImage-arm64.c \ - kexec/arch/arm64/kexec-image-arm64.c - -+arm64_UIMAGE = kexec/kexec-uImage.c -+ - arm64_ARCH_REUSE_INITRD = - arm64_ADD_SEGMENT = - arm64_VIRT_TO_PHYS = -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 04fd3968bb52..c82293973936 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -40,6 +40,7 @@ const struct arch_map_entry arches[] = { - struct file_type file_type[] = { - {"vmlinux", elf_arm64_probe, elf_arm64_load, elf_arm64_usage}, - {"Image", image_arm64_probe, image_arm64_load, image_arm64_usage}, -+ {"uImage", uImage_arm64_probe, uImage_arm64_load, uImage_arm64_usage}, - }; - - int file_types = sizeof(file_type) / sizeof(file_type[0]); -diff --git a/kexec/arch/arm64/kexec-arm64.h b/kexec/arch/arm64/kexec-arm64.h -index bd4c20e76d15..bf724ef16573 100644 ---- a/kexec/arch/arm64/kexec-arm64.h -+++ b/kexec/arch/arm64/kexec-arm64.h -@@ -30,6 +30,10 @@ int image_arm64_probe(const char *kernel_buf, off_t kernel_size); - int image_arm64_load(int argc, char **argv, const char *kernel_buf, - off_t kernel_size, struct kexec_info *info); - void image_arm64_usage(void); -+int uImage_arm64_probe(const char *buf, off_t len); -+int uImage_arm64_load(int argc, char **argv, const char *buf, off_t len, -+ struct kexec_info *info); -+void uImage_arm64_usage(void); - - off_t initrd_base; - off_t initrd_size; -diff --git a/kexec/arch/arm64/kexec-uImage-arm64.c b/kexec/arch/arm64/kexec-uImage-arm64.c -new file mode 100644 -index 000000000000..022d7ee4693a ---- /dev/null -+++ b/kexec/arch/arm64/kexec-uImage-arm64.c -@@ -0,0 +1,34 @@ -+/* -+ * uImage support added by David Woodhouse -+ */ -+#include -+#include -+#include -+#include -+#include -+#include "../../kexec.h" -+#include "kexec-arm64.h" -+ -+int uImage_arm64_probe(const char *buf, off_t len) -+{ -+ return uImage_probe_kernel(buf, len, IH_ARCH_ARM64); -+} -+ -+int uImage_arm64_load(int argc, char **argv, const char *buf, off_t len, -+ struct kexec_info *info) -+{ -+ struct Image_info img; -+ int ret; -+ -+ ret = uImage_load(buf, len, &img); -+ if (ret) -+ return ret; -+ -+ return image_arm64_load(argc, argv, img.buf, img.len, info); -+} -+ -+void uImage_arm64_usage(void) -+{ -+ printf( -+" An ARM64 U-boot uImage file, compressed or not, big or little endian.\n\n"); -+} --- -2.13.0 - diff --git a/0028-vmcore-dmesg-Define-_GNU_SOURCE.patch b/0028-vmcore-dmesg-Define-_GNU_SOURCE.patch deleted file mode 100644 index 199f60d..0000000 --- a/0028-vmcore-dmesg-Define-_GNU_SOURCE.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 2f6f6d6fef7872647cacc6741ac35ac2b4df7ed5 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Wed, 8 Mar 2017 22:41:14 +0000 -Subject: [PATCH 28/45] vmcore-dmesg: Define _GNU_SOURCE - -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 -Signed-off-by: David Woodhouse -Signed-off-by: Simon Horman ---- - vmcore-dmesg/vmcore-dmesg.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c -index 0364636af35d..a8f56dfbe51f 100644 ---- a/vmcore-dmesg/vmcore-dmesg.c -+++ b/vmcore-dmesg/vmcore-dmesg.c -@@ -1,4 +1,5 @@ - #define _XOPEN_SOURCE 600 -+#define _GNU_SOURCE - #define _LARGEFILE_SOURCE 1 - #define _FILE_OFFSET_BITS 64 - #include --- -2.13.0 - diff --git a/0029-Don-t-use-L-width-specifier-with-integer-values.patch b/0029-Don-t-use-L-width-specifier-with-integer-values.patch deleted file mode 100644 index 9da824b..0000000 --- a/0029-Don-t-use-L-width-specifier-with-integer-values.patch +++ /dev/null @@ -1,192 +0,0 @@ -From 47cc70157c6610d4c01a7ab4f8f0d24ab054b43b Mon Sep 17 00:00:00 2001 -From: Philip Prindeville -Date: Fri, 10 Mar 2017 20:12:15 -0700 -Subject: [PATCH 29/45] Don't use %L width specifier with integer values - -MUSL doesn't support %L except for floating-point arguments; therefore, -%ll must be used instead with integer arguments. - -Signed-off-by: Philip Prindeville -Signed-off-by: Simon Horman ---- - kexec/arch/arm/kexec-arm.c | 2 +- - kexec/arch/i386/crashdump-x86.c | 8 ++++---- - kexec/arch/i386/kexec-x86-common.c | 2 +- - kexec/arch/ia64/kexec-elf-rel-ia64.c | 2 +- - kexec/arch/mips/crashdump-mips.c | 2 +- - kexec/arch/mips/kexec-mips.c | 2 +- - kexec/arch/s390/kexec-s390.c | 2 +- - kexec/crashdump.c | 8 ++++---- - kexec/kexec-iomem.c | 2 +- - 9 files changed, 15 insertions(+), 15 deletions(-) - -diff --git a/kexec/arch/arm/kexec-arm.c b/kexec/arch/arm/kexec-arm.c -index 2194b7cbfcb7..49f35b11b21c 100644 ---- a/kexec/arch/arm/kexec-arm.c -+++ b/kexec/arch/arm/kexec-arm.c -@@ -47,7 +47,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, - int count; - if (memory_ranges >= MAX_MEMORY_RANGES) - break; -- count = sscanf(line, "%Lx-%Lx : %n", -+ count = sscanf(line, "%llx-%llx : %n", - &start, &end, &consumed); - if (count != 2) - continue; -diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c -index c4cf2013a001..285dea9abd4b 100644 ---- a/kexec/arch/i386/crashdump-x86.c -+++ b/kexec/arch/i386/crashdump-x86.c -@@ -119,7 +119,7 @@ static unsigned long long get_kernel_sym(const char *symbol) - } - - while(fgets(line, sizeof(line), fp) != NULL) { -- if (sscanf(line, "%Lx %c %s", &vaddr, &type, sym) != 3) -+ if (sscanf(line, "%llx %c %s", &vaddr, &type, sym) != 3) - continue; - if (strcmp(sym, symbol) == 0) { - dbgprintf("kernel symbol %s vaddr = %16llx\n", symbol, vaddr); -@@ -296,12 +296,12 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, - - if (memory_ranges >= CRASH_MAX_MEMORY_RANGES) - break; -- count = sscanf(line, "%Lx-%Lx : %n", -+ count = sscanf(line, "%llx-%llx : %n", - &start, &end, &consumed); - if (count != 2) - continue; - str = line + consumed; -- dbgprintf("%016Lx-%016Lx : %s", -+ dbgprintf("%016llx-%016llx : %s", - start, end, str); - /* Only Dumping memory of type System RAM. */ - if (memcmp(str, "System RAM\n", 11) == 0) { -@@ -778,7 +778,7 @@ static int get_crash_notes(int cpu, uint64_t *addr, uint64_t *len) - *addr = x86__pa(vaddr + (cpu * MAX_NOTE_BYTES)); - *len = MAX_NOTE_BYTES; - -- dbgprintf("crash_notes addr = %Lx\n", -+ dbgprintf("crash_notes addr = %llx\n", - (unsigned long long)*addr); - - fclose(fp); -diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c -index 3e97239c0c78..be03618770f7 100644 ---- a/kexec/arch/i386/kexec-x86-common.c -+++ b/kexec/arch/i386/kexec-x86-common.c -@@ -81,7 +81,7 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges - int count; - if (memory_ranges >= MAX_MEMORY_RANGES) - break; -- count = sscanf(line, "%Lx-%Lx : %n", -+ count = sscanf(line, "%llx-%llx : %n", - &start, &end, &consumed); - if (count != 2) - continue; -diff --git a/kexec/arch/ia64/kexec-elf-rel-ia64.c b/kexec/arch/ia64/kexec-elf-rel-ia64.c -index 7f7c08cba4b1..500f2473ee38 100644 ---- a/kexec/arch/ia64/kexec-elf-rel-ia64.c -+++ b/kexec/arch/ia64/kexec-elf-rel-ia64.c -@@ -155,6 +155,6 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, - } - return; - overflow: -- die("overflow in relocation type %lu val %Lx\n", -+ die("overflow in relocation type %lu val %llx\n", - r_type, value); - } -diff --git a/kexec/arch/mips/crashdump-mips.c b/kexec/arch/mips/crashdump-mips.c -index 9c33599a34ed..6308ec81276f 100644 ---- a/kexec/arch/mips/crashdump-mips.c -+++ b/kexec/arch/mips/crashdump-mips.c -@@ -173,7 +173,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) - int type, consumed, count; - if (memory_ranges >= CRASH_MAX_MEMORY_RANGES) - break; -- count = sscanf(line, "%Lx-%Lx : %n", -+ count = sscanf(line, "%llx-%llx : %n", - &start, &end, &consumed); - if (count != 2) - continue; -diff --git a/kexec/arch/mips/kexec-mips.c b/kexec/arch/mips/kexec-mips.c -index ee3cd3a8b6eb..2e5b700da1ed 100644 ---- a/kexec/arch/mips/kexec-mips.c -+++ b/kexec/arch/mips/kexec-mips.c -@@ -48,7 +48,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, - while (fgets(line, sizeof(line), fp) != 0) { - if (memory_ranges >= MAX_MEMORY_RANGES) - break; -- count = sscanf(line, "%Lx-%Lx : %n", &start, &end, &consumed); -+ count = sscanf(line, "%llx-%llx : %n", &start, &end, &consumed); - if (count != 2) - continue; - str = line + consumed; -diff --git a/kexec/arch/s390/kexec-s390.c b/kexec/arch/s390/kexec-s390.c -index f863483ce808..33ba6b970664 100644 ---- a/kexec/arch/s390/kexec-s390.c -+++ b/kexec/arch/s390/kexec-s390.c -@@ -170,7 +170,7 @@ int get_memory_ranges_s390(struct memory_range memory_range[], int *ranges, - if (current_range == MAX_MEMORY_RANGES) - break; - -- sscanf(line,"%Lx-%Lx : %n", &start, &end, &cons); -+ sscanf(line,"%llx-%llx : %n", &start, &end, &cons); - str = line+cons; - if ((memcmp(str, sys_ram, strlen(sys_ram)) == 0) || - ((memcmp(str, crash_kernel, strlen(crash_kernel)) == 0) && -diff --git a/kexec/crashdump.c b/kexec/crashdump.c -index 15c11051fb98..0b363c503833 100644 ---- a/kexec/crashdump.c -+++ b/kexec/crashdump.c -@@ -98,7 +98,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) - } - if (!fgets(line, sizeof(line), fp)) - die("Cannot parse %s: %s\n", crash_notes, strerror(errno)); -- count = sscanf(line, "%Lx", &temp); -+ count = sscanf(line, "%llx", &temp); - if (count != 1) - die("Cannot parse %s: %s\n", crash_notes, strerror(errno)); - *addr = (uint64_t) temp; -@@ -112,7 +112,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) - if (!fgets(line, sizeof(line), fp)) - die("Cannot parse %s: %s\n", - crash_notes_size, strerror(errno)); -- count = sscanf(line, "%Lu", &temp); -+ count = sscanf(line, "%llu", &temp); - if (count != 1) - die("Cannot parse %s: %s\n", - crash_notes_size, strerror(errno)); -@@ -120,7 +120,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) - fclose(fp); - } - -- dbgprintf("%s: crash_notes addr = %Lx, size = %Lu\n", __FUNCTION__, -+ dbgprintf("%s: crash_notes addr = %llx, size = %llu\n", __FUNCTION__, - (unsigned long long)*addr, (unsigned long long)*len); - - return 0; -@@ -141,7 +141,7 @@ static int get_vmcoreinfo(const char *kdump_info, uint64_t *addr, uint64_t *len) - - if (!fgets(line, sizeof(line), fp)) - die("Cannot parse %s: %s\n", kdump_info, strerror(errno)); -- count = sscanf(line, "%Lx %Lx", &temp, &temp2); -+ count = sscanf(line, "%llx %llx", &temp, &temp2); - if (count != 2) - die("Cannot parse %s: %s\n", kdump_info, strerror(errno)); - -diff --git a/kexec/kexec-iomem.c b/kexec/kexec-iomem.c -index 485a2e810080..7ec385371a2c 100644 ---- a/kexec/kexec-iomem.c -+++ b/kexec/kexec-iomem.c -@@ -44,7 +44,7 @@ int kexec_iomem_for_each_line(char *match, - die("Cannot open %s\n", iomem); - - while(fgets(line, sizeof(line), fp) != 0) { -- count = sscanf(line, "%Lx-%Lx : %n", &start, &end, &consumed); -+ count = sscanf(line, "%llx-%llx : %n", &start, &end, &consumed); - if (count != 2) - continue; - str = line + consumed; --- -2.13.0 - diff --git a/0030-x86-x86_64-Fix-format-warning-with-die.patch b/0030-x86-x86_64-Fix-format-warning-with-die.patch deleted file mode 100644 index d110469..0000000 --- a/0030-x86-x86_64-Fix-format-warning-with-die.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 1550f81bf1886aa0520da0b6181cd61c1a75d4ad Mon Sep 17 00:00:00 2001 -From: Pratyush Anand -Date: Tue, 14 Mar 2017 17:59:22 +0530 -Subject: [PATCH 30/45] x86/x86_64: Fix format warning with die() - -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 -Signed-off-by: Simon Horman ---- - kexec/arch/i386/kexec-elf-x86.c | 4 ++-- - kexec/arch/x86_64/kexec-elf-x86_64.c | 4 ++-- - 2 files changed, 4 insertions(+), 4 deletions(-) - -diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c -index de00dcb869d7..fedf031cdf4a 100644 ---- a/kexec/arch/i386/kexec-elf-x86.c -+++ b/kexec/arch/i386/kexec-elf-x86.c -@@ -91,7 +91,7 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len, - char *command_line = NULL, *modified_cmdline = NULL; - const char *append = NULL; - char *tmp_cmdline = NULL; -- char *error_msg = NULL; -+ const char *error_msg = NULL; - int result; - int command_line_len; - const char *ramdisk; -@@ -296,6 +296,6 @@ out: - free(command_line); - free(modified_cmdline); - if (error_msg) -- die(error_msg); -+ die("%s", error_msg); - return result; - } -diff --git a/kexec/arch/x86_64/kexec-elf-x86_64.c b/kexec/arch/x86_64/kexec-elf-x86_64.c -index ae6569220bc8..ad2231193eb1 100644 ---- a/kexec/arch/x86_64/kexec-elf-x86_64.c -+++ b/kexec/arch/x86_64/kexec-elf-x86_64.c -@@ -99,7 +99,7 @@ int elf_x86_64_load(int argc, char **argv, const char *buf, off_t len, - #define ARG_STYLE_NONE 2 - int opt; - int result = 0; -- char *error_msg = NULL; -+ const char *error_msg = NULL; - - /* See options.h and add any new options there too! */ - static const struct option options[] = { -@@ -276,6 +276,6 @@ out: - free(command_line); - free(modified_cmdline); - if (error_msg) -- die(error_msg); -+ die("%s", error_msg); - return result; - } --- -2.13.0 - diff --git a/0031-ppc-Fix-format-warning-with-die.patch b/0031-ppc-Fix-format-warning-with-die.patch deleted file mode 100644 index ae94f3f..0000000 --- a/0031-ppc-Fix-format-warning-with-die.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 82a49747e5ad73cca14171e81df913f95fece161 Mon Sep 17 00:00:00 2001 -From: Jussi Kukkonen -Date: Thu, 16 Mar 2017 16:11:18 +0200 -Subject: [PATCH 31/45] ppc: Fix format warning with die() - -Enable compiling kexec-tools for ppc with -Werror=format-security. - -Signed-off-by: Jussi Kukkonen -Signed-off-by: Simon Horman ---- - kexec/arch/ppc/kexec-elf-ppc.c | 2 +- - kexec/arch/ppc/kexec-uImage-ppc.c | 2 +- - 2 files changed, 2 insertions(+), 2 deletions(-) - -diff --git a/kexec/arch/ppc/kexec-elf-ppc.c b/kexec/arch/ppc/kexec-elf-ppc.c -index 291f06d4d48f..ad43ad11f0cc 100644 ---- a/kexec/arch/ppc/kexec-elf-ppc.c -+++ b/kexec/arch/ppc/kexec-elf-ppc.c -@@ -453,7 +453,7 @@ out: - if (!tmp_cmdline) - free(command_line); - if (error_msg) -- die(error_msg); -+ die("%s", error_msg); - - return result; - } -diff --git a/kexec/arch/ppc/kexec-uImage-ppc.c b/kexec/arch/ppc/kexec-uImage-ppc.c -index 5eec6e418a58..e8f7adccdc3f 100644 ---- a/kexec/arch/ppc/kexec-uImage-ppc.c -+++ b/kexec/arch/ppc/kexec-uImage-ppc.c -@@ -306,7 +306,7 @@ out: - if (!tmp_cmdline) - free(command_line); - if (error_msg) -- die(error_msg); -+ die("%s", error_msg); - return ret; - } - --- -2.13.0 - diff --git a/0032-crashdump-Remove-stray-get_crashkernel_region-declar.patch b/0032-crashdump-Remove-stray-get_crashkernel_region-declar.patch deleted file mode 100644 index 3213ab2..0000000 --- a/0032-crashdump-Remove-stray-get_crashkernel_region-declar.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0516f46adbf3da74da9971d39b4f8b50cd83d3f5 Mon Sep 17 00:00:00 2001 -From: Daniel Kiper -Date: Thu, 16 Mar 2017 11:12:24 +0100 -Subject: [PATCH 32/45] crashdump: Remove stray get_crashkernel_region() - declaration - -Signed-off-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - kexec/crashdump.h | 1 - - 1 file changed, 1 deletion(-) - -diff --git a/kexec/crashdump.h b/kexec/crashdump.h -index 96219a81829e..86e1ef2523ca 100644 ---- a/kexec/crashdump.h -+++ b/kexec/crashdump.h -@@ -1,7 +1,6 @@ - #ifndef CRASHDUMP_H - #define CRASHDUMP_H - --int get_crashkernel_region(uint64_t *start, uint64_t *end); - extern int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len); - extern int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len); - extern int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len); --- -2.13.0 - diff --git a/0033-x86-Support-large-number-of-memory-ranges.patch b/0033-x86-Support-large-number-of-memory-ranges.patch deleted file mode 100644 index d9c8385..0000000 --- a/0033-x86-Support-large-number-of-memory-ranges.patch +++ /dev/null @@ -1,52 +0,0 @@ -From 4a6d67d9e938a7accf128aff23f8ad4bda67f729 Mon Sep 17 00:00:00 2001 -From: Xunlei Pang -Date: Thu, 23 Mar 2017 19:16:59 +0800 -Subject: [PATCH 33/45] x86: Support large number of memory ranges - -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 -Tested-by: Frank Ramsay -Signed-off-by: Simon Horman ---- - kexec/arch/i386/kexec-x86.h | 2 +- - kexec/crashdump.h | 4 ++-- - 2 files changed, 3 insertions(+), 3 deletions(-) - -diff --git a/kexec/arch/i386/kexec-x86.h b/kexec/arch/i386/kexec-x86.h -index 33df3524f4e2..51855f8db762 100644 ---- a/kexec/arch/i386/kexec-x86.h -+++ b/kexec/arch/i386/kexec-x86.h -@@ -1,7 +1,7 @@ - #ifndef KEXEC_X86_H - #define KEXEC_X86_H - --#define MAX_MEMORY_RANGES 1024 -+#define MAX_MEMORY_RANGES 2048 - - enum coretype { - CORE_TYPE_UNDEF = 0, -diff --git a/kexec/crashdump.h b/kexec/crashdump.h -index 86e1ef2523ca..18bd691c33e2 100644 ---- a/kexec/crashdump.h -+++ b/kexec/crashdump.h -@@ -7,8 +7,8 @@ extern int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len); - - /* Need to find a better way to determine per cpu notes section size. */ - #define MAX_NOTE_BYTES 1024 --/* Expecting ELF headers to fit in 32K. Increase it if you need more. */ --#define KCORE_ELF_HEADERS_SIZE 32768 -+/* Expecting ELF headers to fit in 64K. Increase it if you need more. */ -+#define KCORE_ELF_HEADERS_SIZE 65536 - /* The address of the ELF header is passed to the secondary kernel - * using the kernel command line option memmap=nnn. - * The smallest unit the kernel accepts is in kilobytes, --- -2.13.0 - diff --git a/0034-Fix-broken-Xen-support-in-configure.ac.patch b/0034-Fix-broken-Xen-support-in-configure.ac.patch deleted file mode 100644 index 62877e8..0000000 --- a/0034-Fix-broken-Xen-support-in-configure.ac.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 59d3e5b5ad6f0f33a9801bb69559d28efc62b4ce Mon Sep 17 00:00:00 2001 -From: Eric DeVolder -Date: Fri, 7 Apr 2017 09:13:06 -0500 -Subject: [PATCH 34/45] Fix broken Xen support in configure.ac - -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 -Signed-off-by: Eric DeVolder -Reviewed-by: Daniel Kiper -Signed-off-by: Simon Horman ---- - configure.ac | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 53fffc3a92ed..87a9ac8ccf88 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -165,9 +165,9 @@ 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, [ have_xenctrl_h=yes ], -+ [AC_CHECK_LIB(xenctrl, xc_kexec_load, , - AC_MSG_NOTICE([Xen support disabled]))]) -- if test "$have_xenctrl_h" = yes ; then -+ if test "$ac_cv_lib_xenctrl_xc_kexec_load" = yes ; then - AC_CHECK_LIB(xenctrl, xc_kexec_status, - AC_DEFINE(HAVE_KEXEC_CMD_STATUS, 1, - [The kexec_status call is available]), --- -2.13.0 - diff --git a/0035-kexec-extend-the-semantics-of-kexec_iomem_for_each_l.patch b/0035-kexec-extend-the-semantics-of-kexec_iomem_for_each_l.patch deleted file mode 100644 index 1a07e13..0000000 --- a/0035-kexec-extend-the-semantics-of-kexec_iomem_for_each_l.patch +++ /dev/null @@ -1,79 +0,0 @@ -From c95df0e099b14757de483245d7b1b45e2d6e2c91 Mon Sep 17 00:00:00 2001 -From: AKASHI Takahiro -Date: Wed, 17 May 2017 14:51:41 +0900 -Subject: [PATCH 35/45] kexec: extend the semantics of - kexec_iomem_for_each_line - -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 -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/kexec-iomem.c | 15 ++++++++++----- - 1 file changed, 10 insertions(+), 5 deletions(-) - -diff --git a/kexec/kexec-iomem.c b/kexec/kexec-iomem.c -index 7ec385371a2c..b5b52b1c0803 100644 ---- a/kexec/kexec-iomem.c -+++ b/kexec/kexec-iomem.c -@@ -18,6 +18,9 @@ - * Iterate over each line in the file returned by proc_iomem(). If match is - * NULL or if the line matches with our match-pattern then call the - * callback if non-NULL. -+ * If match is NULL, callback should return a negative if error. -+ * Otherwise the interation goes on, incrementing nr but only if callback -+ * returns 0 (matched). - * - * Return the number of lines matched. - */ -@@ -37,7 +40,7 @@ int kexec_iomem_for_each_line(char *match, - char *str; - int consumed; - int count; -- int nr = 0; -+ int nr = 0, ret; - - fp = fopen(iomem, "r"); - if (!fp) -@@ -50,11 +53,13 @@ int kexec_iomem_for_each_line(char *match, - str = line + consumed; - size = end - start + 1; - if (!match || memcmp(str, match, strlen(match)) == 0) { -- if (callback -- && callback(data, nr, str, start, size) < 0) { -- break; -+ if (callback) { -+ ret = callback(data, nr, str, start, size); -+ if (ret < 0) -+ break; -+ else if (ret == 0) -+ nr++; - } -- nr++; - } - } - --- -2.13.0 - diff --git a/0036-kexec-generalize-and-rename-get_kernel_stext_sym.patch b/0036-kexec-generalize-and-rename-get_kernel_stext_sym.patch deleted file mode 100644 index 11d5942..0000000 --- a/0036-kexec-generalize-and-rename-get_kernel_stext_sym.patch +++ /dev/null @@ -1,187 +0,0 @@ -From 325804055e99dbf40af5e6fa546320b821d9d821 Mon Sep 17 00:00:00 2001 -From: Pratyush Anand -Date: Wed, 17 May 2017 14:51:42 +0900 -Subject: [PATCH 36/45] kexec: generalize and rename get_kernel_stext_sym() - -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 -[created symbols.c] -Signed-off-by: AKASHI Takahiro -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/Makefile | 1 + - kexec/arch/arm/crashdump-arm.c | 40 +--------------------------------------- - kexec/arch/i386/crashdump-x86.c | 29 ----------------------------- - kexec/kexec.h | 2 ++ - kexec/symbols.c | 34 ++++++++++++++++++++++++++++++++++ - 5 files changed, 38 insertions(+), 68 deletions(-) - create mode 100644 kexec/symbols.c - -diff --git a/kexec/Makefile b/kexec/Makefile -index 39f365f543d7..2b4fb3d162ec 100644 ---- a/kexec/Makefile -+++ b/kexec/Makefile -@@ -26,6 +26,7 @@ KEXEC_SRCS_base += kexec/kernel_version.c - KEXEC_SRCS_base += kexec/lzma.c - KEXEC_SRCS_base += kexec/zlib.c - KEXEC_SRCS_base += kexec/kexec-xen.c -+KEXEC_SRCS_base += kexec/symbols.c - - KEXEC_GENERATED_SRCS += $(PURGATORY_HEX_C) - -diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c -index ac76e0a812d5..daa478868b49 100644 ---- a/kexec/arch/arm/crashdump-arm.c -+++ b/kexec/arch/arm/crashdump-arm.c -@@ -73,48 +73,10 @@ static struct crash_elf_info elf_info = { - - extern unsigned long long user_page_offset; - --/* Retrieve kernel _stext symbol virtual address from /proc/kallsyms */ --static unsigned long long get_kernel_stext_sym(void) --{ -- const char *kallsyms = "/proc/kallsyms"; -- const char *stext = "_stext"; -- char sym[128]; -- char line[128]; -- FILE *fp; -- unsigned long long vaddr = 0; -- char type; -- -- fp = fopen(kallsyms, "r"); -- if (!fp) { -- fprintf(stderr, "Cannot open %s\n", kallsyms); -- return 0; -- } -- -- while(fgets(line, sizeof(line), fp) != NULL) { -- unsigned long long addr; -- -- if (sscanf(line, "%Lx %c %s", &addr, &type, sym) != 3) -- continue; -- -- if (strcmp(sym, stext) == 0) { -- dbgprintf("kernel symbol %s vaddr = %#llx\n", stext, addr); -- vaddr = addr; -- break; -- } -- } -- -- fclose(fp); -- -- if (vaddr == 0) -- fprintf(stderr, "Cannot get kernel %s symbol address\n", stext); -- -- return vaddr; --} -- - static int get_kernel_page_offset(struct kexec_info *info, - struct crash_elf_info *elf_info) - { -- unsigned long long stext_sym_addr = get_kernel_stext_sym(); -+ unsigned long long stext_sym_addr = get_kernel_sym("_stext"); - if (stext_sym_addr == 0) { - if (user_page_offset != (-1ULL)) { - elf_info->page_offset = user_page_offset; -diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c -index 285dea9abd4b..69a063a5670b 100644 ---- a/kexec/arch/i386/crashdump-x86.c -+++ b/kexec/arch/i386/crashdump-x86.c -@@ -102,35 +102,6 @@ static int get_kernel_paddr(struct kexec_info *UNUSED(info), - return -1; - } - --/* Retrieve kernel symbol virtual address from /proc/kallsyms */ --static unsigned long long get_kernel_sym(const char *symbol) --{ -- const char *kallsyms = "/proc/kallsyms"; -- char sym[128]; -- char line[128]; -- FILE *fp; -- unsigned long long vaddr; -- char type; -- -- fp = fopen(kallsyms, "r"); -- if (!fp) { -- fprintf(stderr, "Cannot open %s\n", kallsyms); -- return 0; -- } -- -- while(fgets(line, sizeof(line), fp) != NULL) { -- if (sscanf(line, "%llx %c %s", &vaddr, &type, sym) != 3) -- continue; -- if (strcmp(sym, symbol) == 0) { -- dbgprintf("kernel symbol %s vaddr = %16llx\n", symbol, vaddr); -- return vaddr; -- } -- } -- -- dbgprintf("Cannot get kernel %s symbol address\n", symbol); -- return 0; --} -- - /* Retrieve info regarding virtual address kernel has been compiled for and - * size of the kernel from /proc/kcore. Current /proc/kcore parsing from - * from kexec-tools fails because of malformed elf notes. A kernel patch has -diff --git a/kexec/kexec.h b/kexec/kexec.h -index 52bef9b3c0f5..26225d2c002a 100644 ---- a/kexec/kexec.h -+++ b/kexec/kexec.h -@@ -317,4 +317,6 @@ int xen_kexec_unload(uint64_t kexec_flags); - void xen_kexec_exec(void); - int xen_kexec_status(uint64_t kexec_flags); - -+extern unsigned long long get_kernel_sym(const char *text); -+ - #endif /* KEXEC_H */ -diff --git a/kexec/symbols.c b/kexec/symbols.c -new file mode 100644 -index 000000000000..e88f7f342d3b ---- /dev/null -+++ b/kexec/symbols.c -@@ -0,0 +1,34 @@ -+#include -+#include -+#include "kexec.h" -+ -+/* Retrieve kernel symbol virtual address from /proc/kallsyms */ -+unsigned long long get_kernel_sym(const char *symbol) -+{ -+ const char *kallsyms = "/proc/kallsyms"; -+ char sym[128]; -+ char line[128]; -+ FILE *fp; -+ unsigned long long vaddr; -+ char type; -+ -+ fp = fopen(kallsyms, "r"); -+ if (!fp) { -+ fprintf(stderr, "Cannot open %s\n", kallsyms); -+ return 0; -+ } -+ -+ while (fgets(line, sizeof(line), fp) != NULL) { -+ if (sscanf(line, "%llx %c %s", &vaddr, &type, sym) != 3) -+ continue; -+ if (strcmp(sym, symbol) == 0) { -+ dbgprintf("kernel symbol %s vaddr = %16llx\n", -+ symbol, vaddr); -+ return vaddr; -+ } -+ } -+ -+ dbgprintf("Cannot get kernel %s symbol address\n", symbol); -+ -+ return 0; -+} --- -2.13.0 - diff --git a/0037-arm64-identify-PHYS_OFFSET-correctly.patch b/0037-arm64-identify-PHYS_OFFSET-correctly.patch deleted file mode 100644 index daec942..0000000 --- a/0037-arm64-identify-PHYS_OFFSET-correctly.patch +++ /dev/null @@ -1,89 +0,0 @@ -From ef26cc33b8d66460c555600b0e388f55c5cd6f21 Mon Sep 17 00:00:00 2001 -From: AKASHI Takahiro -Date: Wed, 17 May 2017 14:51:43 +0900 -Subject: [PATCH 37/45] arm64: identify PHYS_OFFSET correctly - -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 -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/Makefile | 1 + - kexec/arch/arm64/iomem.h | 7 +++++++ - kexec/arch/arm64/kexec-arm64.c | 12 ++++++++++-- - 3 files changed, 18 insertions(+), 2 deletions(-) - create mode 100644 kexec/arch/arm64/iomem.h - -diff --git a/kexec/arch/arm64/Makefile b/kexec/arch/arm64/Makefile -index a931f0e94012..91f6388e46a3 100644 ---- a/kexec/arch/arm64/Makefile -+++ b/kexec/arch/arm64/Makefile -@@ -26,6 +26,7 @@ dist += $(arm64_KEXEC_SRCS) \ - kexec/arch/arm64/include/arch/options.h \ - kexec/arch/arm64/crashdump-arm64.h \ - kexec/arch/arm64/image-header.h \ -+ kexec/arch/arm64/iomem.h \ - kexec/arch/arm64/kexec-arm64.h \ - kexec/arch/arm64/Makefile - -diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h -new file mode 100644 -index 000000000000..7fd66eb063e1 ---- /dev/null -+++ b/kexec/arch/arm64/iomem.h -@@ -0,0 +1,7 @@ -+#ifndef IOMEM_H -+#define IOMEM_H -+ -+#define SYSTEM_RAM "System RAM\n" -+#define IOMEM_RESERVED "reserved\n" -+ -+#endif -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index c82293973936..7024f749f3f6 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -21,6 +21,7 @@ - #include "crashdump-arm64.h" - #include "dt-ops.h" - #include "fs2dt.h" -+#include "iomem.h" - #include "kexec-syscall.h" - #include "arch/options.h" - -@@ -477,7 +478,14 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str, - return -1; - - r = (struct memory_range *)data + nr; -- r->type = RANGE_RAM; -+ -+ if (!strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM))) -+ r->type = RANGE_RAM; -+ else if (!strncmp(str, IOMEM_RESERVED, strlen(IOMEM_RESERVED))) -+ r->type = RANGE_RESERVED; -+ else -+ return 1; -+ - r->start = base; - r->end = base + length - 1; - -@@ -496,7 +504,7 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str, - static int get_memory_ranges_iomem(struct memory_range *array, - unsigned int *count) - { -- *count = kexec_iomem_for_each_line("System RAM\n", -+ *count = kexec_iomem_for_each_line(NULL, - get_memory_ranges_iomem_cb, array); - - if (!*count) { --- -2.13.0 - diff --git a/0038-arm64-change-return-values-on-error-to-negative.patch b/0038-arm64-change-return-values-on-error-to-negative.patch deleted file mode 100644 index 53c0854..0000000 --- a/0038-arm64-change-return-values-on-error-to-negative.patch +++ /dev/null @@ -1,182 +0,0 @@ -From a17234fe94bce780ac36a0ba9bfc9b6e8ffd84f0 Mon Sep 17 00:00:00 2001 -From: AKASHI Takahiro -Date: Wed, 17 May 2017 14:51:44 +0900 -Subject: [PATCH 38/45] arm64: change return values on error to negative - -EFAILED is defined "-1" and so we don't need to negate it as a return value. - -Signed-off-by: AKASHI Takahiro -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/kexec-arm64.c | 24 ++++++++++++------------ - kexec/arch/arm64/kexec-elf-arm64.c | 6 +++--- - kexec/arch/arm64/kexec-image-arm64.c | 4 ++-- - 3 files changed, 17 insertions(+), 17 deletions(-) - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 7024f749f3f6..153c96f73b3d 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -79,7 +79,7 @@ int arm64_process_image_header(const struct arm64_image_header *h) - #endif - - if (!arm64_header_check_magic(h)) -- return -EFAILED; -+ return EFAILED; - - if (h->image_size) { - arm64_mem.text_offset = arm64_header_text_offset(h); -@@ -202,7 +202,7 @@ static int set_bootargs(struct dtb *dtb, const char *command_line) - if (result) { - fprintf(stderr, - "kexec: Set device tree bootargs failed.\n"); -- return -EFAILED; -+ return EFAILED; - } - - return 0; -@@ -222,7 +222,7 @@ static int read_proc_dtb(struct dtb *dtb) - - if (result) { - dbgprintf("%s: %s\n", __func__, strerror(errno)); -- return -EFAILED; -+ return EFAILED; - } - - dtb->path = path; -@@ -245,7 +245,7 @@ static int read_sys_dtb(struct dtb *dtb) - - if (result) { - dbgprintf("%s: %s\n", __func__, strerror(errno)); -- return -EFAILED; -+ return EFAILED; - } - - dtb->path = path; -@@ -275,7 +275,7 @@ static int read_1st_dtb(struct dtb *dtb) - goto on_success; - - dbgprintf("%s: not found\n", __func__); -- return -EFAILED; -+ return EFAILED; - - on_success: - dbgprintf("%s: found %s\n", __func__, dtb->path); -@@ -294,7 +294,7 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line) - - if (result) { - fprintf(stderr, "kexec: Invalid 2nd device tree.\n"); -- return -EFAILED; -+ return EFAILED; - } - - result = set_bootargs(dtb, command_line); -@@ -349,14 +349,14 @@ int arm64_load_other_segments(struct kexec_info *info, - if (result) { - fprintf(stderr, - "kexec: Error: No device tree available.\n"); -- return -EFAILED; -+ return EFAILED; - } - } - - result = setup_2nd_dtb(&dtb, command_line); - - if (result) -- return -EFAILED; -+ return EFAILED; - - /* Put the other segments after the image. */ - -@@ -384,7 +384,7 @@ int arm64_load_other_segments(struct kexec_info *info, - - if (_ALIGN_UP(initrd_end, GiB(1)) - _ALIGN_DOWN(image_base, GiB(1)) > GiB(32)) { - fprintf(stderr, "kexec: Error: image + initrd too big.\n"); -- return -EFAILED; -+ return EFAILED; - } - - dbgprintf("initrd: base %lx, size %lxh (%ld)\n", -@@ -395,7 +395,7 @@ int arm64_load_other_segments(struct kexec_info *info, - initrd_base + initrd_size); - - if (result) -- return -EFAILED; -+ return EFAILED; - } - } - -@@ -403,7 +403,7 @@ int arm64_load_other_segments(struct kexec_info *info, - - if (dtb.size > MiB(2)) { - fprintf(stderr, "kexec: Error: dtb too big.\n"); -- return -EFAILED; -+ return EFAILED; - } - - dtb_base = add_buffer_phys_virt(info, dtb.buf, dtb.size, dtb.size, -@@ -509,7 +509,7 @@ static int get_memory_ranges_iomem(struct memory_range *array, - - if (!*count) { - dbgprintf("%s: failed: No RAM found.\n", __func__); -- return -EFAILED; -+ return EFAILED; - } - - return 0; -diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c -index daf8bf0df9c4..2b6c127ebc92 100644 ---- a/kexec/arch/arm64/kexec-elf-arm64.c -+++ b/kexec/arch/arm64/kexec-elf-arm64.c -@@ -48,7 +48,7 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf, - - if (info->kexec_flags & KEXEC_ON_CRASH) { - fprintf(stderr, "kexec: kdump not yet supported on arm64\n"); -- return -EFAILED; -+ return EFAILED; - } - - result = build_elf_exec_info(kernel_buf, kernel_size, &ehdr, 0); -@@ -92,7 +92,7 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf, - - if (i == ehdr.e_phnum) { - dbgprintf("%s: Valid arm64 header not found\n", __func__); -- result = -EFAILED; -+ result = EFAILED; - goto exit; - } - -@@ -100,7 +100,7 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf, - - if (kernel_segment == ULONG_MAX) { - dbgprintf("%s: Kernel segment is not allocated\n", __func__); -- result = -EFAILED; -+ result = EFAILED; - goto exit; - } - -diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c -index 960ed9667a4d..e5f2a9befdb1 100644 ---- a/kexec/arch/arm64/kexec-image-arm64.c -+++ b/kexec/arch/arm64/kexec-image-arm64.c -@@ -36,13 +36,13 @@ int image_arm64_load(int argc, char **argv, const char *kernel_buf, - header = (const struct arm64_image_header *)(kernel_buf); - - if (arm64_process_image_header(header)) -- return -1; -+ return EFAILED; - - kernel_segment = arm64_locate_kernel_segment(info); - - if (kernel_segment == ULONG_MAX) { - dbgprintf("%s: Kernel segment is not allocated\n", __func__); -- result = -EFAILED; -+ result = EFAILED; - goto exit; - } - --- -2.13.0 - diff --git a/0039-arm64-kdump-identify-memory-regions.patch b/0039-arm64-kdump-identify-memory-regions.patch deleted file mode 100644 index 12d2411..0000000 --- a/0039-arm64-kdump-identify-memory-regions.patch +++ /dev/null @@ -1,214 +0,0 @@ -From c0672c93edcb5bb32800f8d48afa05861ef32a79 Mon Sep 17 00:00:00 2001 -From: AKASHI Takahiro -Date: Wed, 17 May 2017 14:51:45 +0900 -Subject: [PATCH 39/45] arm64: kdump: identify memory regions - -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 -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/Makefile | 2 + - kexec/arch/arm64/crashdump-arm64.c | 109 +++++++++++++++++++++++++++++++++++-- - kexec/arch/arm64/crashdump-arm64.h | 14 ++++- - kexec/arch/arm64/iomem.h | 1 + - 4 files changed, 120 insertions(+), 6 deletions(-) - -diff --git a/kexec/arch/arm64/Makefile b/kexec/arch/arm64/Makefile -index 91f6388e46a3..9d9111caa8ed 100644 ---- a/kexec/arch/arm64/Makefile -+++ b/kexec/arch/arm64/Makefile -@@ -6,6 +6,8 @@ arm64_FS2DT_INCLUDE += \ - - arm64_DT_OPS += kexec/dt-ops.c - -+arm64_MEM_REGIONS = kexec/mem_regions.c -+ - arm64_CPPFLAGS += -I $(srcdir)/kexec/ - - arm64_KEXEC_SRCS += \ -diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c -index b0e4713f12c6..9267c9add291 100644 ---- a/kexec/arch/arm64/crashdump-arm64.c -+++ b/kexec/arch/arm64/crashdump-arm64.c -@@ -1,5 +1,13 @@ - /* - * ARM64 crashdump. -+ * partly derived from arm implementation -+ * -+ * Copyright (c) 2014-2017 Linaro Limited -+ * Author: AKASHI Takahiro -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. - */ - - #define _GNU_SOURCE -@@ -10,18 +18,111 @@ - #include "kexec.h" - #include "crashdump.h" - #include "crashdump-arm64.h" -+#include "iomem.h" - #include "kexec-arm64.h" - #include "kexec-elf.h" -+#include "mem_regions.h" - --struct memory_ranges usablemem_rgns = {}; -+/* memory ranges on crashed kernel */ -+static struct memory_range system_memory_ranges[CRASH_MAX_MEMORY_RANGES]; -+static struct memory_ranges system_memory_rgns = { -+ .size = 0, -+ .max_size = CRASH_MAX_MEMORY_RANGES, -+ .ranges = system_memory_ranges, -+}; - --int is_crashkernel_mem_reserved(void) -+/* memory range reserved for crashkernel */ -+struct memory_range crash_reserved_mem; -+struct memory_ranges usablemem_rgns = { -+ .size = 0, -+ .max_size = 1, -+ .ranges = &crash_reserved_mem, -+}; -+ -+/* -+ * iomem_range_callback() - callback called for each iomem region -+ * @data: not used -+ * @nr: not used -+ * @str: name of the memory region -+ * @base: start address of the memory region -+ * @length: size of the memory region -+ * -+ * This function is called once for each memory region found in /proc/iomem. -+ * It locates system RAM and crashkernel reserved memory and places these to -+ * variables, respectively, system_memory_ranges and crash_reserved_mem. -+ */ -+ -+static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr), -+ char *str, unsigned long long base, -+ unsigned long long length) - { -+ if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0) -+ return mem_regions_add(&usablemem_rgns, -+ base, length, RANGE_RAM); -+ else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) -+ return mem_regions_add(&system_memory_rgns, -+ base, length, RANGE_RAM); -+ - return 0; - } - -+int is_crashkernel_mem_reserved(void) -+{ -+ if (!usablemem_rgns.size) -+ kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL); -+ -+ return crash_reserved_mem.start != crash_reserved_mem.end; -+} -+ -+/* -+ * crash_get_memory_ranges() - read system physical memory -+ * -+ * Function reads through system physical memory and stores found memory -+ * regions in system_memory_ranges. -+ * Regions are sorted in ascending order. -+ * -+ * Returns 0 in case of success and a negative value otherwise. -+ */ -+static int crash_get_memory_ranges(void) -+{ -+ /* -+ * First read all memory regions that can be considered as -+ * system memory including the crash area. -+ */ -+ if (!usablemem_rgns.size) -+ kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL); -+ -+ /* allow only a single region for crash dump kernel */ -+ if (usablemem_rgns.size != 1) -+ return -EINVAL; -+ -+ dbgprint_mem_range("Reserved memory range", &crash_reserved_mem, 1); -+ -+ if (mem_regions_exclude(&system_memory_rgns, &crash_reserved_mem)) { -+ fprintf(stderr, -+ "Error: Number of crash memory ranges excedeed the max limit\n"); -+ return -ENOMEM; -+ } -+ -+ /* -+ * Make sure that the memory regions are sorted. -+ */ -+ mem_regions_sort(&system_memory_rgns); -+ -+ dbgprint_mem_range("Coredump memory ranges", -+ system_memory_rgns.ranges, system_memory_rgns.size); -+} -+ - int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) - { -- /* Crash kernel region size is not exposed by the system */ -- return -1; -+ if (!usablemem_rgns.size) -+ kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL); -+ -+ if (!crash_reserved_mem.end) -+ return -1; -+ -+ *start = crash_reserved_mem.start; -+ *end = crash_reserved_mem.end; -+ -+ return 0; - } -diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h -index f33c7a25b454..ce9881eba67e 100644 ---- a/kexec/arch/arm64/crashdump-arm64.h -+++ b/kexec/arch/arm64/crashdump-arm64.h -@@ -1,12 +1,22 @@ - /* - * ARM64 crashdump. -+ * -+ * Copyright (c) 2014-2017 Linaro Limited -+ * Author: AKASHI Takahiro -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. - */ - --#if !defined(CRASHDUMP_ARM64_H) -+#ifndef CRASHDUMP_ARM64_H - #define CRASHDUMP_ARM64_H - - #include "kexec.h" - -+#define CRASH_MAX_MEMORY_RANGES 32 -+ - extern struct memory_ranges usablemem_rgns; -+extern struct memory_range crash_reserved_mem; - --#endif -+#endif /* CRASHDUMP_ARM64_H */ -diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h -index 7fd66eb063e1..20cda87dbd02 100644 ---- a/kexec/arch/arm64/iomem.h -+++ b/kexec/arch/arm64/iomem.h -@@ -2,6 +2,7 @@ - #define IOMEM_H - - #define SYSTEM_RAM "System RAM\n" -+#define CRASH_KERNEL "Crash kernel\n" - #define IOMEM_RESERVED "reserved\n" - - #endif --- -2.13.0 - diff --git a/0040-arm64-kdump-add-elf-core-header-segment.patch b/0040-arm64-kdump-add-elf-core-header-segment.patch deleted file mode 100644 index e70713c..0000000 --- a/0040-arm64-kdump-add-elf-core-header-segment.patch +++ /dev/null @@ -1,202 +0,0 @@ -From 0bd5219da953639276cd17e067c030ac97feca97 Mon Sep 17 00:00:00 2001 -From: AKASHI Takahiro -Date: Wed, 17 May 2017 14:51:46 +0900 -Subject: [PATCH 40/45] arm64: kdump: add elf core header segment - -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 -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/crashdump-arm64.c | 98 ++++++++++++++++++++++++++++++++++++++ - kexec/arch/arm64/crashdump-arm64.h | 3 ++ - kexec/arch/arm64/iomem.h | 2 + - kexec/arch/arm64/kexec-elf-arm64.c | 11 +++++ - 4 files changed, 114 insertions(+) - -diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c -index 9267c9add291..d142435fa933 100644 ---- a/kexec/arch/arm64/crashdump-arm64.c -+++ b/kexec/arch/arm64/crashdump-arm64.c -@@ -39,6 +39,39 @@ struct memory_ranges usablemem_rgns = { - .ranges = &crash_reserved_mem, - }; - -+struct memory_range elfcorehdr_mem; -+ -+static struct crash_elf_info elf_info = { -+ .class = ELFCLASS64, -+#if (__BYTE_ORDER == __LITTLE_ENDIAN) -+ .data = ELFDATA2LSB, -+#else -+ .data = ELFDATA2MSB, -+#endif -+ .machine = EM_AARCH64, -+}; -+ -+/* -+ * Note: The returned value is correct only if !CONFIG_RANDOMIZE_BASE. -+ */ -+static uint64_t get_kernel_page_offset(void) -+{ -+ int i; -+ -+ if (elf_info.kern_vaddr_start == UINT64_MAX) -+ return UINT64_MAX; -+ -+ /* Current max virtual memory range is 48-bits. */ -+ for (i = 48; i > 0; i--) -+ if (!(elf_info.kern_vaddr_start & (1UL << i))) -+ break; -+ -+ if (i <= 0) -+ return UINT64_MAX; -+ else -+ return UINT64_MAX << i; -+} -+ - /* - * iomem_range_callback() - callback called for each iomem region - * @data: not used -@@ -62,6 +95,10 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr), - else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0) - return mem_regions_add(&system_memory_rgns, - base, length, RANGE_RAM); -+ else if (strncmp(str, KERNEL_CODE, strlen(KERNEL_CODE)) == 0) -+ elf_info.kern_paddr_start = base; -+ else if (strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) == 0) -+ elf_info.kern_size = base + length - elf_info.kern_paddr_start; - - return 0; - } -@@ -111,6 +148,67 @@ static int crash_get_memory_ranges(void) - - dbgprint_mem_range("Coredump memory ranges", - system_memory_rgns.ranges, system_memory_rgns.size); -+ -+ /* -+ * For additional kernel code/data segment. -+ * kern_paddr_start/kern_size are determined in iomem_range_callback -+ */ -+ elf_info.kern_vaddr_start = get_kernel_sym("_text"); -+ if (!elf_info.kern_vaddr_start) -+ elf_info.kern_vaddr_start = UINT64_MAX; -+ -+ return 0; -+} -+ -+/* -+ * load_crashdump_segments() - load the elf core header -+ * @info: kexec info structure -+ * -+ * This function creates and loads an additional segment of elf core header -+ : which is used to construct /proc/vmcore on crash dump kernel. -+ * -+ * Return 0 in case of success and -1 in case of error. -+ */ -+ -+int load_crashdump_segments(struct kexec_info *info) -+{ -+ unsigned long elfcorehdr; -+ unsigned long bufsz; -+ void *buf; -+ int err; -+ -+ /* -+ * First fetch all the memory (RAM) ranges that we are going to -+ * pass to the crash dump kernel during panic. -+ */ -+ -+ err = crash_get_memory_ranges(); -+ -+ if (err) -+ return EFAILED; -+ -+ elf_info.page_offset = get_kernel_page_offset(); -+ dbgprintf("%s: page_offset: %016llx\n", __func__, -+ elf_info.page_offset); -+ -+ err = crash_create_elf64_headers(info, &elf_info, -+ system_memory_rgns.ranges, system_memory_rgns.size, -+ &buf, &bufsz, ELF_CORE_HEADER_ALIGN); -+ -+ if (err) -+ return EFAILED; -+ -+ elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 0, -+ crash_reserved_mem.start, crash_reserved_mem.end, -+ -1, 0); -+ -+ elfcorehdr_mem.start = elfcorehdr; -+ elfcorehdr_mem.end = elfcorehdr + bufsz - 1; -+ -+ dbgprintf("%s: elfcorehdr 0x%llx-0x%llx\n", __func__, -+ elfcorehdr_mem.start, elfcorehdr_mem.end); -+ -+ return 0; - } - - int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) -diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h -index ce9881eba67e..64c677d2fce1 100644 ---- a/kexec/arch/arm64/crashdump-arm64.h -+++ b/kexec/arch/arm64/crashdump-arm64.h -@@ -18,5 +18,8 @@ - - extern struct memory_ranges usablemem_rgns; - extern struct memory_range crash_reserved_mem; -+extern struct memory_range elfcorehdr_mem; -+ -+extern int load_crashdump_segments(struct kexec_info *info); - - #endif /* CRASHDUMP_ARM64_H */ -diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h -index 20cda87dbd02..d4864bb44922 100644 ---- a/kexec/arch/arm64/iomem.h -+++ b/kexec/arch/arm64/iomem.h -@@ -2,6 +2,8 @@ - #define IOMEM_H - - #define SYSTEM_RAM "System RAM\n" -+#define KERNEL_CODE "Kernel code\n" -+#define KERNEL_DATA "Kernel data\n" - #define CRASH_KERNEL "Crash kernel\n" - #define IOMEM_RESERVED "reserved\n" - -diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c -index 2b6c127ebc92..900c6939ab62 100644 ---- a/kexec/arch/arm64/kexec-elf-arm64.c -+++ b/kexec/arch/arm64/kexec-elf-arm64.c -@@ -119,6 +119,16 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf, - dbgprintf("%s: PE format: %s\n", __func__, - (arm64_header_check_pe_sig(header) ? "yes" : "no")); - -+ /* create and initialize elf core header segment */ -+ if (info->kexec_flags & KEXEC_ON_CRASH) { -+ result = load_crashdump_segments(info); -+ if (result) { -+ dbgprintf("%s: Creating eflcorehdr failed.\n", -+ __func__); -+ goto exit; -+ } -+ } -+ - /* load the kernel */ - result = elf_exec_load(&ehdr, info); - -@@ -127,6 +137,7 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf, - goto exit; - } - -+ /* load additional data */ - result = arm64_load_other_segments(info, kernel_segment - + arm64_mem.text_offset); - --- -2.13.0 - diff --git a/0041-arm64-kdump-set-up-kernel-image-segment.patch b/0041-arm64-kdump-set-up-kernel-image-segment.patch deleted file mode 100644 index fa029f8..0000000 --- a/0041-arm64-kdump-set-up-kernel-image-segment.patch +++ /dev/null @@ -1,142 +0,0 @@ -From 1591926df5a602ffcbf55e99aa8a96fbebd0bafe Mon Sep 17 00:00:00 2001 -From: AKASHI Takahiro -Date: Wed, 17 May 2017 14:51:47 +0900 -Subject: [PATCH 41/45] arm64: kdump: set up kernel image segment - -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 -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/crashdump-arm64.c | 24 ++++++++++++++++++++++++ - kexec/arch/arm64/crashdump-arm64.h | 1 + - kexec/arch/arm64/kexec-arm64.c | 25 ++++++++++++++++++++----- - kexec/arch/arm64/kexec-elf-arm64.c | 11 ++++++++++- - 4 files changed, 55 insertions(+), 6 deletions(-) - -diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c -index d142435fa933..4fd7aa8fd43c 100644 ---- a/kexec/arch/arm64/crashdump-arm64.c -+++ b/kexec/arch/arm64/crashdump-arm64.c -@@ -211,6 +211,30 @@ int load_crashdump_segments(struct kexec_info *info) - return 0; - } - -+/* -+ * e_entry and p_paddr are actually in virtual address space. -+ * Those values will be translated to physcal addresses by using -+ * virt_to_phys() in add_segment(). -+ * So let's fix up those values for later use so the memory base -+ * (arm64_mm.phys_offset) will be correctly replaced with -+ * crash_reserved_mem.start. -+ */ -+void fixup_elf_addrs(struct mem_ehdr *ehdr) -+{ -+ struct mem_phdr *phdr; -+ int i; -+ -+ ehdr->e_entry += - arm64_mem.phys_offset + crash_reserved_mem.start; -+ -+ for (i = 0; i < ehdr->e_phnum; i++) { -+ phdr = &ehdr->e_phdr[i]; -+ if (phdr->p_type != PT_LOAD) -+ continue; -+ phdr->p_paddr += -+ (-arm64_mem.phys_offset + crash_reserved_mem.start); -+ } -+} -+ - int get_crash_kernel_load_range(uint64_t *start, uint64_t *end) - { - if (!usablemem_rgns.size) -diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h -index 64c677d2fce1..880b83aa3d0f 100644 ---- a/kexec/arch/arm64/crashdump-arm64.h -+++ b/kexec/arch/arm64/crashdump-arm64.h -@@ -21,5 +21,6 @@ extern struct memory_range crash_reserved_mem; - extern struct memory_range elfcorehdr_mem; - - extern int load_crashdump_segments(struct kexec_info *info); -+extern void fixup_elf_addrs(struct mem_ehdr *ehdr); - - #endif /* CRASHDUMP_ARM64_H */ -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 153c96f73b3d..6c2175672305 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -308,12 +308,27 @@ unsigned long arm64_locate_kernel_segment(struct kexec_info *info) - { - unsigned long hole; - -- hole = locate_hole(info, -- arm64_mem.text_offset + arm64_mem.image_size, -- MiB(2), 0, ULONG_MAX, 1); -+ if (info->kexec_flags & KEXEC_ON_CRASH) { -+ unsigned long hole_end; -+ -+ hole = (crash_reserved_mem.start < mem_min ? -+ mem_min : crash_reserved_mem.start); -+ hole = _ALIGN_UP(hole, MiB(2)); -+ hole_end = hole + arm64_mem.text_offset + arm64_mem.image_size; -+ -+ if ((hole_end > mem_max) || -+ (hole_end > crash_reserved_mem.end)) { -+ dbgprintf("%s: Crash kernel out of range\n", __func__); -+ hole = ULONG_MAX; -+ } -+ } else { -+ hole = locate_hole(info, -+ arm64_mem.text_offset + arm64_mem.image_size, -+ MiB(2), 0, ULONG_MAX, 1); - -- if (hole == ULONG_MAX) -- dbgprintf("%s: locate_hole failed\n", __func__); -+ if (hole == ULONG_MAX) -+ dbgprintf("%s: locate_hole failed\n", __func__); -+ } - - return hole; - } -diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c -index 900c6939ab62..a9611474ef51 100644 ---- a/kexec/arch/arm64/kexec-elf-arm64.c -+++ b/kexec/arch/arm64/kexec-elf-arm64.c -@@ -9,6 +9,7 @@ - #include - #include - -+#include "crashdump-arm64.h" - #include "kexec-arm64.h" - #include "kexec-elf.h" - #include "kexec-syscall.h" -@@ -105,7 +106,8 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf, - } - - arm64_mem.vp_offset = _ALIGN_DOWN(ehdr.e_entry, MiB(2)); -- arm64_mem.vp_offset -= kernel_segment - get_phys_offset(); -+ if (!(info->kexec_flags & KEXEC_ON_CRASH)) -+ arm64_mem.vp_offset -= kernel_segment - get_phys_offset(); - - dbgprintf("%s: kernel_segment: %016lx\n", __func__, kernel_segment); - dbgprintf("%s: text_offset: %016lx\n", __func__, -@@ -130,6 +132,13 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf, - } - - /* load the kernel */ -+ if (info->kexec_flags & KEXEC_ON_CRASH) -+ /* -+ * offset addresses in elf header in order to load -+ * vmlinux (elf_exec) into crash kernel's memory -+ */ -+ fixup_elf_addrs(&ehdr); -+ - result = elf_exec_load(&ehdr, info); - - if (result) { --- -2.13.0 - diff --git a/0042-arm64-kdump-set-up-other-segments.patch b/0042-arm64-kdump-set-up-other-segments.patch deleted file mode 100644 index aa900f7..0000000 --- a/0042-arm64-kdump-set-up-other-segments.patch +++ /dev/null @@ -1,35 +0,0 @@ -From defad947feff0d0135f79893e99ca94ec9a59e0f Mon Sep 17 00:00:00 2001 -From: AKASHI Takahiro -Date: Wed, 17 May 2017 14:51:48 +0900 -Subject: [PATCH 42/45] arm64: kdump: set up other segments - -We make sure that all the other segments, initrd and device-tree blob, -also be loaded into the reserved memory of crash dump kernel. - -Signed-off-by: AKASHI Takahiro -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/kexec-arm64.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index 6c2175672305..dfe16a626136 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -376,7 +376,10 @@ int arm64_load_other_segments(struct kexec_info *info, - /* Put the other segments after the image. */ - - hole_min = image_base + arm64_mem.image_size; -- hole_max = ULONG_MAX; -+ if (info->kexec_flags & KEXEC_ON_CRASH) -+ hole_max = crash_reserved_mem.end; -+ else -+ hole_max = ULONG_MAX; - - if (arm64_opts.initrd) { - initrd_buf = slurp_file(arm64_opts.initrd, &initrd_size); --- -2.13.0 - diff --git a/0043-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch b/0043-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch deleted file mode 100644 index 3cb3267..0000000 --- a/0043-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch +++ /dev/null @@ -1,282 +0,0 @@ -From 5f955585c7c9166da5b8f33e3d8a4c43845ee70b Mon Sep 17 00:00:00 2001 -From: AKASHI Takahiro -Date: Wed, 17 May 2017 14:51:49 +0900 -Subject: [PATCH 43/45] arm64: kdump: add DT properties to crash dump kernel's - dtb - -We pass the following properties to crash dump kernel: -linux,elfcorehdr: elf core header segment, - same as "elfcorehdr=" kernel parameter on other archs -linux,usable-memory-range: usable memory reserved for crash dump kernel - -Signed-off-by: AKASHI Takahiro -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/kexec-arm64.c | 197 ++++++++++++++++++++++++++++++++++++- - kexec/arch/arm64/kexec-elf-arm64.c | 5 - - 2 files changed, 192 insertions(+), 10 deletions(-) - -diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c -index dfe16a626136..62f37585b788 100644 ---- a/kexec/arch/arm64/kexec-arm64.c -+++ b/kexec/arch/arm64/kexec-arm64.c -@@ -25,6 +25,14 @@ - #include "kexec-syscall.h" - #include "arch/options.h" - -+#define ROOT_NODE_ADDR_CELLS_DEFAULT 1 -+#define ROOT_NODE_SIZE_CELLS_DEFAULT 1 -+ -+#define PROP_ADDR_CELLS "#address-cells" -+#define PROP_SIZE_CELLS "#size-cells" -+#define PROP_ELFCOREHDR "linux,elfcorehdr" -+#define PROP_USABLE_MEM_RANGE "linux,usable-memory-range" -+ - /* Global varables the core kexec routines expect. */ - - unsigned char reuse_initrd; -@@ -129,9 +137,6 @@ int arch_process_options(int argc, char **argv) - case OPT_INITRD: - arm64_opts.initrd = optarg; - break; -- case OPT_PANIC: -- die("load-panic (-p) not supported"); -- break; - default: - break; /* Ignore core and unknown options. */ - } -@@ -282,12 +287,115 @@ on_success: - return 0; - } - -+static int get_cells_size(void *fdt, uint32_t *address_cells, -+ uint32_t *size_cells) -+{ -+ int nodeoffset; -+ const uint32_t *prop = NULL; -+ int prop_len; -+ -+ /* default values */ -+ *address_cells = ROOT_NODE_ADDR_CELLS_DEFAULT; -+ *size_cells = ROOT_NODE_SIZE_CELLS_DEFAULT; -+ -+ /* under root node */ -+ nodeoffset = fdt_path_offset(fdt, "/"); -+ if (nodeoffset < 0) -+ goto on_error; -+ -+ prop = fdt_getprop(fdt, nodeoffset, PROP_ADDR_CELLS, &prop_len); -+ if (prop) { -+ if (prop_len == sizeof(*prop)) -+ *address_cells = fdt32_to_cpu(*prop); -+ else -+ goto on_error; -+ } -+ -+ prop = fdt_getprop(fdt, nodeoffset, PROP_SIZE_CELLS, &prop_len); -+ if (prop) { -+ if (prop_len == sizeof(*prop)) -+ *size_cells = fdt32_to_cpu(*prop); -+ else -+ goto on_error; -+ } -+ -+ dbgprintf("%s: #address-cells:%d #size-cells:%d\n", __func__, -+ *address_cells, *size_cells); -+ return 0; -+ -+on_error: -+ return EFAILED; -+} -+ -+static bool cells_size_fitted(uint32_t address_cells, uint32_t size_cells, -+ struct memory_range *range) -+{ -+ dbgprintf("%s: %llx-%llx\n", __func__, range->start, range->end); -+ -+ /* if *_cells >= 2, cells can hold 64-bit values anyway */ -+ if ((address_cells == 1) && (range->start >= (1ULL << 32))) -+ return false; -+ -+ if ((size_cells == 1) && -+ ((range->end - range->start + 1) >= (1ULL << 32))) -+ return false; -+ -+ return true; -+} -+ -+static void fill_property(void *buf, uint64_t val, uint32_t cells) -+{ -+ uint32_t val32; -+ int i; -+ -+ if (cells == 1) { -+ val32 = cpu_to_fdt32((uint32_t)val); -+ memcpy(buf, &val32, sizeof(uint32_t)); -+ } else { -+ for (i = 0; -+ i < (cells * sizeof(uint32_t) - sizeof(uint64_t)); i++) -+ *(char *)buf++ = 0; -+ -+ val = cpu_to_fdt64(val); -+ memcpy(buf, &val, sizeof(uint64_t)); -+ } -+} -+ -+static int fdt_setprop_range(void *fdt, int nodeoffset, -+ const char *name, struct memory_range *range, -+ uint32_t address_cells, uint32_t size_cells) -+{ -+ void *buf, *prop; -+ size_t buf_size; -+ int result; -+ -+ buf_size = (address_cells + size_cells) * sizeof(uint32_t); -+ prop = buf = xmalloc(buf_size); -+ -+ fill_property(prop, range->start, address_cells); -+ prop += address_cells * sizeof(uint32_t); -+ -+ fill_property(prop, range->end - range->start + 1, size_cells); -+ prop += size_cells * sizeof(uint32_t); -+ -+ result = fdt_setprop(fdt, nodeoffset, name, buf, buf_size); -+ -+ free(buf); -+ -+ return result; -+} -+ - /** - * setup_2nd_dtb - Setup the 2nd stage kernel's dtb. - */ - --static int setup_2nd_dtb(struct dtb *dtb, char *command_line) -+static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash) - { -+ uint32_t address_cells, size_cells; -+ int range_len; -+ int nodeoffset; -+ char *new_buf = NULL; -+ int new_size; - int result; - - result = fdt_check_header(dtb->buf); -@@ -299,8 +407,86 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line) - - result = set_bootargs(dtb, command_line); - -+ if (on_crash) { -+ /* determine #address-cells and #size-cells */ -+ result = get_cells_size(dtb->buf, &address_cells, &size_cells); -+ if (result) { -+ fprintf(stderr, -+ "kexec: cannot determine cells-size.\n"); -+ result = -EINVAL; -+ goto on_error; -+ } -+ -+ if (!cells_size_fitted(address_cells, size_cells, -+ &elfcorehdr_mem)) { -+ fprintf(stderr, -+ "kexec: elfcorehdr doesn't fit cells-size.\n"); -+ result = -EINVAL; -+ goto on_error; -+ } -+ -+ if (!cells_size_fitted(address_cells, size_cells, -+ &crash_reserved_mem)) { -+ fprintf(stderr, -+ "kexec: usable memory range doesn't fit cells-size.\n"); -+ result = -EINVAL; -+ goto on_error; -+ } -+ -+ /* duplicate dt blob */ -+ range_len = sizeof(uint32_t) * (address_cells + size_cells); -+ new_size = fdt_totalsize(dtb->buf) -+ + fdt_prop_len(PROP_ELFCOREHDR, range_len) -+ + fdt_prop_len(PROP_USABLE_MEM_RANGE, range_len); -+ -+ new_buf = xmalloc(new_size); -+ result = fdt_open_into(dtb->buf, new_buf, new_size); -+ if (result) { -+ dbgprintf("%s: fdt_open_into failed: %s\n", __func__, -+ fdt_strerror(result)); -+ result = -ENOSPC; -+ goto on_error; -+ } -+ -+ /* add linux,elfcorehdr */ -+ nodeoffset = fdt_path_offset(new_buf, "/chosen"); -+ result = fdt_setprop_range(new_buf, nodeoffset, -+ PROP_ELFCOREHDR, &elfcorehdr_mem, -+ address_cells, size_cells); -+ if (result) { -+ dbgprintf("%s: fdt_setprop failed: %s\n", __func__, -+ fdt_strerror(result)); -+ result = -EINVAL; -+ goto on_error; -+ } -+ -+ /* add linux,usable-memory-range */ -+ nodeoffset = fdt_path_offset(new_buf, "/chosen"); -+ result = fdt_setprop_range(new_buf, nodeoffset, -+ PROP_USABLE_MEM_RANGE, &crash_reserved_mem, -+ address_cells, size_cells); -+ if (result) { -+ dbgprintf("%s: fdt_setprop failed: %s\n", __func__, -+ fdt_strerror(result)); -+ result = -EINVAL; -+ goto on_error; -+ } -+ -+ fdt_pack(new_buf); -+ dtb->buf = new_buf; -+ dtb->size = fdt_totalsize(new_buf); -+ } -+ - dump_reservemap(dtb); - -+ -+ return result; -+ -+on_error: -+ fprintf(stderr, "kexec: %s failed.\n", __func__); -+ if (new_buf) -+ free(new_buf); -+ - return result; - } - -@@ -368,7 +554,8 @@ int arm64_load_other_segments(struct kexec_info *info, - } - } - -- result = setup_2nd_dtb(&dtb, command_line); -+ result = setup_2nd_dtb(&dtb, command_line, -+ info->kexec_flags & KEXEC_ON_CRASH); - - if (result) - return EFAILED; -diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c -index a9611474ef51..fc83b42c9d2b 100644 ---- a/kexec/arch/arm64/kexec-elf-arm64.c -+++ b/kexec/arch/arm64/kexec-elf-arm64.c -@@ -47,11 +47,6 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf, - int result; - int i; - -- if (info->kexec_flags & KEXEC_ON_CRASH) { -- fprintf(stderr, "kexec: kdump not yet supported on arm64\n"); -- return EFAILED; -- } -- - result = build_elf_exec_info(kernel_buf, kernel_size, &ehdr, 0); - - if (result < 0) { --- -2.13.0 - diff --git a/0044-arm64-kdump-Add-support-for-binary-image-files.patch b/0044-arm64-kdump-Add-support-for-binary-image-files.patch deleted file mode 100644 index 564accf..0000000 --- a/0044-arm64-kdump-Add-support-for-binary-image-files.patch +++ /dev/null @@ -1,58 +0,0 @@ -From c504ff5d85aa035aed9f14f5ce96c5d959952dd9 Mon Sep 17 00:00:00 2001 -From: Pratyush Anand -Date: Wed, 17 May 2017 14:51:50 +0900 -Subject: [PATCH 44/45] arm64: kdump: Add support for binary image files - -This patch adds support to use binary image ie arch/arm64/boot/Image with -kdump. - -Signed-off-by: Pratyush Anand -[takahiro.akashi@linaro.org: a bit reworked] -Signed-off-by: AKASHI Takahiro -Tested-by: David Woodhouse -Tested-by: Pratyush Anand -Signed-off-by: Simon Horman ---- - kexec/arch/arm64/kexec-image-arm64.c | 13 +++++++++++++ - 1 file changed, 13 insertions(+) - -diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c -index e5f2a9befdb1..e1b1e54b149f 100644 ---- a/kexec/arch/arm64/kexec-image-arm64.c -+++ b/kexec/arch/arm64/kexec-image-arm64.c -@@ -4,7 +4,9 @@ - - #define _GNU_SOURCE - -+#include "crashdump-arm64.h" - #include "kexec-arm64.h" -+#include "kexec-syscall.h" - #include - - int image_arm64_probe(const char *kernel_buf, off_t kernel_size) -@@ -58,11 +60,22 @@ int image_arm64_load(int argc, char **argv, const char *kernel_buf, - dbgprintf("%s: PE format: %s\n", __func__, - (arm64_header_check_pe_sig(header) ? "yes" : "no")); - -+ /* create and initialize elf core header segment */ -+ if (info->kexec_flags & KEXEC_ON_CRASH) { -+ result = load_crashdump_segments(info); -+ if (result) { -+ dbgprintf("%s: Creating eflcorehdr failed.\n", -+ __func__); -+ goto exit; -+ } -+ } -+ - /* load the kernel */ - add_segment_phys_virt(info, kernel_buf, kernel_size, - kernel_segment + arm64_mem.text_offset, - arm64_mem.image_size, 0); - -+ /* load additional data */ - result = arm64_load_other_segments(info, kernel_segment - + arm64_mem.text_offset); - --- -2.13.0 - diff --git a/0045-Handle-additional-e820-memmap-type-strings.patch b/0045-Handle-additional-e820-memmap-type-strings.patch deleted file mode 100644 index acdc6db..0000000 --- a/0045-Handle-additional-e820-memmap-type-strings.patch +++ /dev/null @@ -1,39 +0,0 @@ -From fab91841c717150aca4bc73e4c54769305e27ade Mon Sep 17 00:00:00 2001 -From: Eric DeVolder -Date: Wed, 10 May 2017 11:03:37 -0500 -Subject: [PATCH 45/45] Handle additional e820 memmap type strings - -Keep pace with changes to linux arch/x86/kernel/e820.c to -function e820_type_to_string(). With this change, the following -messages from kexec are eliminated (and allows kexec to load): - - Unknown type (Reserved) while parsing /sys/firmware/memmap/8/type. - Please report this as bug. Using RANGE_RESERVED now. - - Unknown type (Unknown E820 type) while parsing /sys/firmware/memmap/4/type. - Please report this as bug. Using RANGE_RESERVED now. - -Signed-off-by: Eric DeVolder -Signed-off-by: Simon Horman ---- - kexec/firmware_memmap.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/kexec/firmware_memmap.c b/kexec/firmware_memmap.c -index 4d84f0011c57..1ee214aa9316 100644 ---- a/kexec/firmware_memmap.c -+++ b/kexec/firmware_memmap.c -@@ -164,6 +164,10 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range) - range->type = RANGE_RESERVED; - else if (strcmp(type, "reserved") == 0) - range->type = RANGE_RESERVED; -+ else if (strcmp(type, "Reserved") == 0) -+ range->type = RANGE_RESERVED; -+ else if (strcmp(type, "Unknown E820 type") == 0) -+ range->type = RANGE_RESERVED; - else if (strcmp(type, "ACPI Non-volatile Storage") == 0) - range->type = RANGE_ACPI_NVS; - else if (strcmp(type, "Uncached RAM") == 0) --- -2.13.0 - diff --git a/0046-powerpc-fix-command-line-overflow-error.patch b/0046-powerpc-fix-command-line-overflow-error.patch deleted file mode 100644 index b933d72..0000000 --- a/0046-powerpc-fix-command-line-overflow-error.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 21eb397a5fc9227cd95d23e8c74a49cf6a293e57 Mon Sep 17 00:00:00 2001 -From: Hari Bathini -Date: Wed, 9 Aug 2017 23:47:42 +0530 -Subject: [PATCH] kexec-tools: powerpc: fix command line overflow error - -References: bsc#1074947 -Patch-mainline: v2.0.16-rc1 -Git-commit: 21eb397a5fc9227cd95d23e8c74a49cf6a293e57 - -Since kernel commit a5980d064fe2 ("powerpc: Bump COMMAND_LINE_SIZE -to 2048"), powerpc bumped command line size to 2048 but the size -used here is still the default value of 512. Bump it to 2048 to -fix command line overflow errors observed when command line length -is above 512 bytes. Also, get rid of the multiple definitions of -COMMAND_LINE_SIZE macro in ppc architecture. - -Signed-off-by: Hari Bathini -Signed-off-by: Simon Horman -Acked-by: Michal Suchanek ---- - kexec/arch/ppc/crashdump-powerpc.c | 6 +++++- - kexec/arch/ppc/crashdump-powerpc.h | 2 -- - kexec/arch/ppc/fs2dt.c | 1 - - kexec/arch/ppc/kexec-ppc.h | 3 ++- - kexec/arch/ppc/ops.h | 1 - - kexec/arch/ppc64/crashdump-ppc64.c | 6 ++++-- - kexec/arch/ppc64/crashdump-ppc64.h | 2 +- - 7 files changed, 12 insertions(+), 9 deletions(-) - -diff --git a/kexec/arch/ppc/crashdump-powerpc.c b/kexec/arch/ppc/crashdump-powerpc.c -index dde6de7ec7a1..4ad026f38dd0 100644 ---- a/kexec/arch/ppc/crashdump-powerpc.c -+++ b/kexec/arch/ppc/crashdump-powerpc.c -@@ -252,8 +252,12 @@ static void ulltoa(unsigned long long i, char *str) - /* Append str to cmdline */ - static void add_cmdline(char *cmdline, char *str) - { -+ int cmdline_size; - int cmdlen = strlen(cmdline) + strlen(str); -- if (cmdlen > (COMMAND_LINE_SIZE - 1)) -+ -+ cmdline_size = (kernel_version() < KERNEL_VERSION(3, 15, 0) ? -+ 512 : COMMAND_LINE_SIZE); -+ if (cmdlen > (cmdline_size - 1)) - die("Command line overflow\n"); - strcat(cmdline, str); - } -diff --git a/kexec/arch/ppc/crashdump-powerpc.h b/kexec/arch/ppc/crashdump-powerpc.h -index 9b9b01e3157b..97b5095ba748 100644 ---- a/kexec/arch/ppc/crashdump-powerpc.h -+++ b/kexec/arch/ppc/crashdump-powerpc.h -@@ -20,8 +20,6 @@ extern struct arch_options_t arch_options; - #define KERNELBASE PAGE_OFFSET - #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) - --#define COMMAND_LINE_SIZE 512 /* from kernel */ -- - #ifdef CONFIG_BOOKE - /* We don't need backup region in Book E */ - #define BACKUP_SRC_START 0x0000 -diff --git a/kexec/arch/ppc/fs2dt.c b/kexec/arch/ppc/fs2dt.c -index 6e7737919695..fed499b4da9d 100644 ---- a/kexec/arch/ppc/fs2dt.c -+++ b/kexec/arch/ppc/fs2dt.c -@@ -37,7 +37,6 @@ - #define TREEWORDS 65536 /* max 32 bit words for properties */ - #define MEMRESERVE 256 /* max number of reserved memory blks */ - #define MAX_MEMORY_RANGES 1024 --#define COMMAND_LINE_SIZE 512 /* from kernel */ - - static char pathname[MAXPATH]; - static char propnames[NAMESPACE] = { 0 }; -diff --git a/kexec/arch/ppc/kexec-ppc.h b/kexec/arch/ppc/kexec-ppc.h -index f8fd67827e43..04e728eddf7f 100644 ---- a/kexec/arch/ppc/kexec-ppc.h -+++ b/kexec/arch/ppc/kexec-ppc.h -@@ -6,6 +6,8 @@ - #define CORE_TYPE_ELF32 1 - #define CORE_TYPE_ELF64 2 - -+#define COMMAND_LINE_SIZE 2048 /* from kernel */ -+ - extern unsigned char setup_simple_start[]; - extern uint32_t setup_simple_size; - -@@ -76,7 +78,6 @@ extern int init_memory_region_info(void); - extern int read_memory_region_limits(int fd, unsigned long long *start, - unsigned long long *end); - extern int get_devtree_value(const char *fname, unsigned long long *pvalue); --#define COMMAND_LINE_SIZE 512 /* from kernel */ - /*fs2dt*/ - void reserve(unsigned long long where, unsigned long long length); - -diff --git a/kexec/arch/ppc/ops.h b/kexec/arch/ppc/ops.h -index 7334a059dd94..5e7a070808d3 100644 ---- a/kexec/arch/ppc/ops.h -+++ b/kexec/arch/ppc/ops.h -@@ -12,7 +12,6 @@ - #define _PPC_BOOT_OPS_H_ - #include "types.h" - --#define COMMAND_LINE_SIZE 512 - #define MAX_PATH_LEN 256 - #define MAX_PROP_LEN 256 /* What should this be? */ - -diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c -index 5a71d5161c87..13995bfb8fc1 100644 ---- a/kexec/arch/ppc64/crashdump-ppc64.c -+++ b/kexec/arch/ppc64/crashdump-ppc64.c -@@ -381,7 +381,7 @@ static void ultoa(uint64_t i, char *str) - static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr, - char *byte) - { -- int cmdlen, len, align = 1024; -+ int cmdline_size, cmdlen, len, align = 1024; - char str[COMMAND_LINE_SIZE], *ptr; - - /* Passing in =xxxK / =xxxM format. Saves space required in cmdline.*/ -@@ -402,7 +402,9 @@ static int add_cmdline_param(char *cmdline, uint64_t addr, char *cmdstr, - strcat(str, byte); - len = strlen(str); - cmdlen = strlen(cmdline) + len; -- if (cmdlen > (COMMAND_LINE_SIZE - 1)) -+ cmdline_size = (kernel_version() < KERNEL_VERSION(3, 15, 0) ? -+ 512 : COMMAND_LINE_SIZE); -+ if (cmdlen > (cmdline_size - 1)) - die("Command line overflow\n"); - strcat(cmdline, str); - dbgprintf("Command line after adding elfcorehdr: %s\n", cmdline); -diff --git a/kexec/arch/ppc64/crashdump-ppc64.h b/kexec/arch/ppc64/crashdump-ppc64.h -index d654c6b5e8a9..42ccc31e538c 100644 ---- a/kexec/arch/ppc64/crashdump-ppc64.h -+++ b/kexec/arch/ppc64/crashdump-ppc64.h -@@ -16,7 +16,7 @@ void add_usable_mem_rgns(unsigned long long base, unsigned long long size); - #define __pa(x) ((unsigned long)(x)-PAGE_OFFSET) - #define MAXMEM (-KERNELBASE-VMALLOCBASE) - --#define COMMAND_LINE_SIZE 512 /* from kernel */ -+#define COMMAND_LINE_SIZE 2048 /* from kernel */ - /* Backup Region, First 64K of System RAM. */ - #define BACKUP_SRC_START 0x0000 - #define BACKUP_SRC_END 0xffff --- -2.13.6 - diff --git a/0047-fix-how-RMA-top-is-deduced.patch b/0047-fix-how-RMA-top-is-deduced.patch deleted file mode 100644 index 255db8c..0000000 --- a/0047-fix-how-RMA-top-is-deduced.patch +++ /dev/null @@ -1,128 +0,0 @@ -From 47478ea66d4301b12a07862aebc8447a2932f0ed Mon Sep 17 00:00:00 2001 -From: Hari Bathini -Date: Wed, 26 Jul 2017 22:49:41 +0530 -Subject: [PATCH] kexec-tools: ppc64: fix how RMA top is deduced - -References: bsc#1074947 -Patch-mainline: v2.0.16-rc1 -Git-commit: 47478ea66d4301b12a07862aebc8447a2932f0ed - -Hang was observed, in purgatory, on a machine configured with -single LPAR. This was because one of the segments was loaded -outside the actual Real Memory Area (RMA) due to wrongly -deduced RMA top value. - -Currently, top of real memory area, which is crucial for loading -kexec/kdump kernel, is obtained by iterating through mem nodes -and setting its value based on the base and size values of the -last mem node in the iteration. That can't always be correct as -the order of iteration may not be same and RMA base & size are -always based on the first memory property. Fix this by setting -RMA top value based on the base and size values of the memory -node that has the smallest base value (first memory property) -among all the memory nodes. - -Also, correct the misnomers rmo_base and rmo_top to rma_base -and rma_top respectively. - -While how RMA top is deduced was broken for sometime, the issue -may not have been seen so far, for couple of possible reasons: - - 1. Only one mem node was available. - 2. First memory property has been the last node in - iteration when multiple mem nodes were present. - -Fixes: 02f4088ffded ("kexec fix ppc64 device-tree mem node") -Reported-by: Ankit Kumar -Cc: Michael Ellerman -Cc: Geoff Levand -Signed-off-by: Hari Bathini -Signed-off-by: Simon Horman -Acked-by: Michal Suchanek ---- - kexec/arch/ppc64/kexec-ppc64.c | 35 +++++++++++++++++++---------------- - 1 file changed, 19 insertions(+), 16 deletions(-) - -diff --git a/kexec/arch/ppc64/kexec-ppc64.c b/kexec/arch/ppc64/kexec-ppc64.c -index 6e8c175878a4..a7d708b8f8c6 100644 ---- a/kexec/arch/ppc64/kexec-ppc64.c -+++ b/kexec/arch/ppc64/kexec-ppc64.c -@@ -38,7 +38,7 @@ - static struct memory_range *exclude_range = NULL; - static struct memory_range *memory_range = NULL; - static struct memory_range *base_memory_range = NULL; --static uint64_t rmo_top; -+static uint64_t rma_top; - uint64_t memory_max = 0; - uint64_t memory_limit; - static int nr_memory_ranges, nr_exclude_ranges; -@@ -385,7 +385,7 @@ int get_devtree_value(const char *fname, unsigned long long *value) - */ - static int get_devtree_details(unsigned long kexec_flags) - { -- uint64_t rmo_base; -+ uint64_t rma_base = -1, base; - uint64_t tce_base; - unsigned int tce_size; - uint64_t htab_base, htab_size; -@@ -696,10 +696,13 @@ static int get_devtree_details(unsigned long kexec_flags) - perror(fname); - goto error_openfile; - } -- rmo_base = be64_to_cpu(((uint64_t *)buf)[0]); -- rmo_top = rmo_base + be64_to_cpu(((uint64_t *)buf)[1]); -- if (rmo_top > 0x30000000UL) -- rmo_top = 0x30000000UL; -+ base = be64_to_cpu(((uint64_t *)buf)[0]); -+ if (base < rma_base) { -+ rma_base = base; -+ rma_top = base + be64_to_cpu(((uint64_t *)buf)[1]); -+ if (rma_top > 0x30000000UL) -+ rma_top = 0x30000000UL; -+ } - - fclose(file); - closedir(cdir); -@@ -811,14 +814,14 @@ int setup_memory_ranges(unsigned long kexec_flags) - j++; - if (j >= max_memory_ranges) - realloc_memory_ranges(); -- /* Limit the end to rmo_top */ -- if (memory_range[j-1].start >= rmo_top) { -+ /* Limit the end to rma_top */ -+ if (memory_range[j-1].start >= rma_top) { - j--; - break; - } -- if ((memory_range[j-1].start < rmo_top) && -- (memory_range[j-1].end >= rmo_top)) { -- memory_range[j-1].end = rmo_top; -+ if ((memory_range[j-1].start < rma_top) && -+ (memory_range[j-1].end >= rma_top)) { -+ memory_range[j-1].end = rma_top; - break; - } - continue; -@@ -833,14 +836,14 @@ int setup_memory_ranges(unsigned long kexec_flags) - j++; - if (j >= max_memory_ranges) - realloc_memory_ranges(); -- /* Limit range to rmo_top */ -- if (memory_range[j-1].start >= rmo_top) { -+ /* Limit range to rma_top */ -+ if (memory_range[j-1].start >= rma_top) { - j--; - break; - } -- if ((memory_range[j-1].start < rmo_top) && -- (memory_range[j-1].end >= rmo_top)) { -- memory_range[j-1].end = rmo_top; -+ if ((memory_range[j-1].start < rma_top) && -+ (memory_range[j-1].end >= rma_top)) { -+ memory_range[j-1].end = rma_top; - break; - } - } --- -2.13.6 - diff --git a/kexec-bootloader.8 b/kexec-bootloader.8 new file mode 100644 index 0000000..e6ca79e --- /dev/null +++ b/kexec-bootloader.8 @@ -0,0 +1,68 @@ +'\" t +.\" Title: kexec-bootloader +.\" Author: Bernhard Walle +.\" Generator: DocBook XSL Stylesheets vsnapshot +.\" Date: 01/19/2018 +.\" Manual: User Manuals +.\" Source: SUSE +.\" Language: English +.\" +.TH "KEXEC\-BOOTLOADER" "8" "01/19/2018" "SUSE" "User Manuals" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +kexec-bootloader \- Load kexec kernel from bootloader configuration +.SH "SYNOPSIS" +.sp +kexec\-bootloader [\-D] +.SH "DESCRIPTION" +.sp +kexec\-bootloader takes the default section of bootloader configuration and loads that kernel, initrd with \fIkexec \-l\fR and the respective command line\&. +.sp +Under systemd kexec\-bootloader may be invoked by kexec\-load\&.service (/usr/bin/systemctl kexec) to perform a kexec\&. To emulate previous SLE configurable behaviour where kexec occurs automatically at system reboot the systemd reboot target should be altered via \*(Aqln \-s /usr/lib/systemd/system/kexec\&.target /etc/systemd/system/reboot\&.target +.SH "OPTIONS" +.PP +\fB\-h\fR | \fB\-\-help\fR +.RS 4 +Shows a short usage message\&. +.RE +.PP +\fB\-D\fR | \fB\-\-debug\fR +.RS 4 +Prints debugging output\&. +.RE +.SH "RETURN VALUE" +.sp +The program returns \fB0\fR on success and \fB1\fR on failure\&. +.SH "BUGS" +.sp +Please report bugs and enhancement requests at https://bugzilla\&.novell\&.com\&. +.SH "COPYING" +.sp +Copyright (c) 2008 Bernhard Walle \&. Free use of this software is granted under the terms of the GNU General Public License (GPL), version 2 or later\&. +.SH "SEE ALSO" +.sp +\fBkexec\fR(8) +.SH "AUTHOR" +.PP +\fBBernhard Walle\fR <\&bwalle@suse\&.de\&> +.RS 4 +Author. +.RE diff --git a/kexec-bootloader.8.txt b/kexec-bootloader.8.txt deleted file mode 100644 index 983331e..0000000 --- a/kexec-bootloader.8.txt +++ /dev/null @@ -1,84 +0,0 @@ -//{{{ Copyright (c) 2008, SUSE LINUX Products GmbH -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// Neither the name of the Novell nor the names of its contributors may be used -// to endorse or promote products derived from this software without specific -// prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -// INTERRUPTION) HOWEVER CAUSED AND ONANY THEORY OF LIABILITY, WHETHER IN -// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -// POSSIBILITY OF SUCH DAMAGE. -//}}} - -kexec-bootloader(8) -=================== -:man source: SUSE -:man manual: User Manuals -Bernhard Walle - -Name ----- -kexec-bootloader - Load kexec kernel from bootloader configuration - -Synopsis --------- -kexec-bootloader [-D] - -Description ------------ -kexec-bootloader takes the default section of bootloader configuration and -loads that kernel, initrd with _kexec -l_ and the respective command line. - -Under systemd kexec-bootloader may be invoked by kexec-load.service -(/usr/bin/systemctl kexec) to perform a kexec. To emulate previous SLE -configurable behaviour where kexec occurs automatically at system reboot -the systemd reboot target should be altered via -'ln -s /usr/lib/systemd/system/kexec.target /etc/systemd/system/reboot.target - -Options -------- -*-h* | *--help*:: - Shows a short usage message. - -*-D* | *--debug*:: - Prints debugging output. - -Return Value ------------- -The program returns *0* on success and *1* on failure. - -Bugs ----- -Please report bugs and enhancement requests at https://bugzilla.novell.com[]. - -Copying -------- -Copyright (c) 2008 Bernhard Walle . Free use of this software is -granted under the terms of the GNU General Public License (GPL), version 2 or -later. - -See also --------- -*kexec*(8) - - -// vim: set sw=4 ts=4 et tw=80 fdm=marker: :collapseFolds=1: diff --git a/kexec-tools-2.0.14.tar.gz b/kexec-tools-2.0.14.tar.gz deleted file mode 100644 index 9a368a1..0000000 --- a/kexec-tools-2.0.14.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fbfa2b603a1f422e04eb565251c10e53c16ad97096d7cc8e615abe7bc8270596 -size 360647 diff --git a/kexec-tools-2.0.16.tar.gz b/kexec-tools-2.0.16.tar.gz new file mode 100644 index 0000000..43837ed --- /dev/null +++ b/kexec-tools-2.0.16.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:79f442548d226fb09d92dec12be60e38b15b54a62054b54baceffb2215fa78e6 +size 367180 diff --git a/kexec-tools.changes b/kexec-tools.changes index 0dbe4fe..d55ab1b 100644 --- a/kexec-tools.changes +++ b/kexec-tools.changes @@ -1,3 +1,64 @@ +------------------------------------------------------------------- +Fri Jan 19 12:59:56 UTC 2018 - tchvatal@suse.com + +- Create compat link for rckexec-loader systemd service +- Convert the asciidoc file to normal man in order to drop asciidoc dep + * python2 only obsoletion and upstream has only raw manpages too +- Properly state all post/postun dependencies (systemd, suse-module-tools) +- There is no reason for exclusive arch if we state all archs +- Bump to version 2.0.16 + Changelog: http://git.kernel.org/cgit/utils/kernel/kexec/kexec-tools.git/log/?id=refs/tags/v2.0.14..v2.0.16 +- Remove support for older products to trivialize spec file +- Make sure to not pull python2 via asciidoc +- Drop merged patch 0001-kexec-tools-2.0.14.git.patch +- Drop all patches from upstream git: + * 0002-ppc64-Reduce-number-of-ELF-LOAD-segments.patch + * 0003-kexec-Increase-the-upper-limit-for-RAM-segments.patch + * 0004-alpha-add-missing-__NR_kexec_load-definition.patch + * 0005-kexec-implemented-XEN-KEXEC-STATUS-to-determine-if-a.patch + * 0006-kexec-Remove-redundant-space-from-help-message.patch + * 0007-purgatory-Add-purgatory.map-and-purgatory.ro.sym-to-.patch + * 0008-kexec-Add-option-to-get-crash-kernel-region-size.patch + * 0009-crashdump-arm-Add-get_crash_kernel_load_range-functi.patch + * 0010-crashdump-arm64-Add-get_crash_kernel_load_range-func.patch + * 0011-crashdump-cris-Add-get_crash_kernel_load_range-funct.patch + * 0012-crashdump-ia64-Add-get_crash_kernel_load_range-funct.patch + * 0013-crashdump-m68k-Add-get_crash_kernel_load_range-funct.patch + * 0014-crashdump-mips-Add-get_crash_kernel_load_range-funct.patch + * 0015-crashdump-ppc-Add-get_crash_kernel_load_range-functi.patch + * 0016-crashdump-ppc64-Add-get_crash_kernel_load_range-func.patch + * 0017-crashdump-s390-Add-get_crash_kernel_load_range-funct.patch + * 0018-crashdump-sh-Add-get_crash_kernel_load_range-functio.patch + * 0019-gitignore-add-two-generated-files-in-purgatory.patch + * 0020-Only-print-debug-message-when-failed-to-serach-for-k.patch + * 0021-build_mem_phdrs-check-if-p_paddr-is-invalid.patch + * 0022-uImage-fix-realloc-pointer-confusion.patch + * 0023-uImage-Fix-uImage_load-for-little-endian-machines.patch + * 0024-uImage-Add-new-IH_ARCH_xxx-definitions.patch + * 0025-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch + * 0026-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch + * 0027-arm64-add-uImage-support.patch + * 0028-vmcore-dmesg-Define-_GNU_SOURCE.patch + * 0029-Don-t-use-L-width-specifier-with-integer-values.patch + * 0030-x86-x86_64-Fix-format-warning-with-die.patch + * 0031-ppc-Fix-format-warning-with-die.patch + * 0032-crashdump-Remove-stray-get_crashkernel_region-declar.patch + * 0033-x86-Support-large-number-of-memory-ranges.patch + * 0034-Fix-broken-Xen-support-in-configure.ac.patch + * 0035-kexec-extend-the-semantics-of-kexec_iomem_for_each_l.patch + * 0036-kexec-generalize-and-rename-get_kernel_stext_sym.patch + * 0037-arm64-identify-PHYS_OFFSET-correctly.patch + * 0038-arm64-change-return-values-on-error-to-negative.patch + * 0039-arm64-kdump-identify-memory-regions.patch + * 0040-arm64-kdump-add-elf-core-header-segment.patch + * 0041-arm64-kdump-set-up-kernel-image-segment.patch + * 0042-arm64-kdump-set-up-other-segments.patch + * 0043-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch + * 0044-arm64-kdump-Add-support-for-binary-image-files.patch + * 0045-Handle-additional-e820-memmap-type-strings.patch + * 0046-powerpc-fix-command-line-overflow-error.patch + * 0047-fix-how-RMA-top-is-deduced.patch + ------------------------------------------------------------------- Mon Jan 8 15:14:57 UTC 2018 - msuchanek@suse.com diff --git a/kexec-tools.spec b/kexec-tools.spec index d074936..d47f0dc 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -17,89 +17,34 @@ Name: kexec-tools -%ifarch ppc -BuildRequires: gcc-64bit -BuildRequires: glibc-devel-64bit -%endif -Requires: perl-Bootloader -Requires(pre): %fillup_prereq -Requires(post): coreutils -Requires(postun): coreutils +Version: 2.0.16 +Release: 0 Summary: Tools for loading replacement kernels into memory License: GPL-2.0+ Group: System/Kernel -Version: 2.0.14 -Release: 0 +Url: ftp://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.bz2 Source: https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/snapshot/%{name}-%{version}.tar.gz Source1: kexec-bootloader -Source2: kexec-bootloader.8.txt +Source2: kexec-bootloader.8 Source3: kexec-load.service Source4: %{name}-rpmlintrc Patch1: %{name}-xen-static.patch Patch2: %{name}-xen-balloon-up.patch Patch3: %{name}-disable-test.patch -# upstream fixes -Patch101: 0001-kexec-tools-2.0.14.git.patch -Patch102: 0002-ppc64-Reduce-number-of-ELF-LOAD-segments.patch -Patch103: 0003-kexec-Increase-the-upper-limit-for-RAM-segments.patch -Patch104: 0004-alpha-add-missing-__NR_kexec_load-definition.patch -Patch105: 0005-kexec-implemented-XEN-KEXEC-STATUS-to-determine-if-a.patch -Patch106: 0006-kexec-Remove-redundant-space-from-help-message.patch -Patch107: 0007-purgatory-Add-purgatory.map-and-purgatory.ro.sym-to-.patch -Patch108: 0008-kexec-Add-option-to-get-crash-kernel-region-size.patch -Patch109: 0009-crashdump-arm-Add-get_crash_kernel_load_range-functi.patch -Patch110: 0010-crashdump-arm64-Add-get_crash_kernel_load_range-func.patch -Patch111: 0011-crashdump-cris-Add-get_crash_kernel_load_range-funct.patch -Patch112: 0012-crashdump-ia64-Add-get_crash_kernel_load_range-funct.patch -Patch113: 0013-crashdump-m68k-Add-get_crash_kernel_load_range-funct.patch -Patch114: 0014-crashdump-mips-Add-get_crash_kernel_load_range-funct.patch -Patch115: 0015-crashdump-ppc-Add-get_crash_kernel_load_range-functi.patch -Patch116: 0016-crashdump-ppc64-Add-get_crash_kernel_load_range-func.patch -Patch117: 0017-crashdump-s390-Add-get_crash_kernel_load_range-funct.patch -Patch118: 0018-crashdump-sh-Add-get_crash_kernel_load_range-functio.patch -Patch119: 0019-gitignore-add-two-generated-files-in-purgatory.patch -Patch120: 0020-Only-print-debug-message-when-failed-to-serach-for-k.patch -Patch121: 0021-build_mem_phdrs-check-if-p_paddr-is-invalid.patch -Patch122: 0022-uImage-fix-realloc-pointer-confusion.patch -Patch123: 0023-uImage-Fix-uImage_load-for-little-endian-machines.patch -Patch124: 0024-uImage-Add-new-IH_ARCH_xxx-definitions.patch -Patch125: 0025-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch -Patch126: 0026-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch -Patch127: 0027-arm64-add-uImage-support.patch -Patch128: 0028-vmcore-dmesg-Define-_GNU_SOURCE.patch -Patch129: 0029-Don-t-use-L-width-specifier-with-integer-values.patch -Patch130: 0030-x86-x86_64-Fix-format-warning-with-die.patch -Patch131: 0031-ppc-Fix-format-warning-with-die.patch -Patch132: 0032-crashdump-Remove-stray-get_crashkernel_region-declar.patch -Patch133: 0033-x86-Support-large-number-of-memory-ranges.patch -Patch134: 0034-Fix-broken-Xen-support-in-configure.ac.patch -Patch135: 0035-kexec-extend-the-semantics-of-kexec_iomem_for_each_l.patch -Patch136: 0036-kexec-generalize-and-rename-get_kernel_stext_sym.patch -Patch137: 0037-arm64-identify-PHYS_OFFSET-correctly.patch -Patch138: 0038-arm64-change-return-values-on-error-to-negative.patch -Patch139: 0039-arm64-kdump-identify-memory-regions.patch -Patch140: 0040-arm64-kdump-add-elf-core-header-segment.patch -Patch141: 0041-arm64-kdump-set-up-kernel-image-segment.patch -Patch142: 0042-arm64-kdump-set-up-other-segments.patch -Patch143: 0043-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch -Patch144: 0044-arm64-kdump-Add-support-for-binary-image-files.patch -Patch145: 0045-Handle-additional-e820-memmap-type-strings.patch -Patch146: 0046-powerpc-fix-command-line-overflow-error.patch -Patch147: 0047-fix-how-RMA-top-is-deduced.patch - -Url: ftp://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.bz2 -BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: autoconf +BuildRequires: automake +BuildRequires: systemd-rpm-macros +BuildRequires: zlib-devel #!BuildIgnore: fop #!BuildIgnore: gcc-PIE -BuildRequires: asciidoc -BuildRequires: automake -BuildRequires: libxslt -BuildRequires: zlib-devel +Requires: perl-Bootloader +Requires(post): suse-module-tools +Requires(postun): suse-module-tools +%{?systemd_requires} %ifarch x86_64 -BuildRequires: pkg-config +BuildRequires: pkgconfig BuildRequires: xen-devel %endif -ExclusiveArch: ppc64le aarch64 %ix86 x86_64 ia64 ppc ppc64 s390 s390x %arm sh mips mipsel m68k %description Kexec is a user space utility for loading another kernel and asking the @@ -108,84 +53,27 @@ kernel may be asked to start the loaded kernel on reboot, or to start the loaded kernel after it panics. %prep -%setup -q -n kexec-tools-%{version} -%patch101 -p1 -%patch102 -p1 -%patch103 -p1 -%patch104 -p1 -%patch105 -p1 -%patch106 -p1 -%patch107 -p1 -%patch108 -p1 -%patch109 -p1 -%patch110 -p1 -%patch111 -p1 -%patch112 -p1 -%patch113 -p1 -%patch114 -p1 -%patch115 -p1 -%patch116 -p1 -%patch117 -p1 -%patch118 -p1 -%patch119 -p1 -%patch120 -p1 -%patch121 -p1 -%patch122 -p1 -%patch123 -p1 -%patch124 -p1 -%patch125 -p1 -%patch126 -p1 -%patch127 -p1 -%patch128 -p1 -%patch129 -p1 -%patch130 -p1 -%patch131 -p1 -%patch132 -p1 -%patch133 -p1 -%patch134 -p1 -%patch135 -p1 -%patch136 -p1 -%patch137 -p1 -%patch138 -p1 -%patch139 -p1 -%patch140 -p1 -%patch141 -p1 -%patch142 -p1 -%patch143 -p1 -%patch144 -p1 -%patch145 -p1 -%patch146 -p1 -%patch147 -p1 - +%setup -q %patch1 -p1 %patch2 -p1 %patch3 -p1 %build -# disable as-needed -export SUSE_ASNEEDED=0 -%{?suse_update_config -f} -%ifarch ia64 -RPM_OPT_FLAGS=$(echo "%{optflags}" | sed -e 's/-fstack-protector//') -%endif -autoreconf -f -CFLAGS="$RPM_OPT_FLAGS" BUILD_CFLAGS="$RPM_OPT_FLAGS" \ -%ifarch ppc -%configure --host=powerpc64-suse-linux --build=powerpc64-suse-linux -%else +autoreconf -fvi +export CFLAGS="%{optflags}" +export BUILD_CFLAGS="%{optflags}" %configure -%endif -make -a2x -D . -d manpage -f manpage %{S:2} +make %{?_smp_mflags} %install %make_install -install -c -m 0644 kexec-bootloader.8 %{buildroot}/%{_mandir}/man8 +install -c -m 0644 %{SOURCE2} %{buildroot}/%{_mandir}/man8 rm -f %{buildroot}/%{_mandir}/man8/kdump.8 mkdir -p %{buildroot}/%{_sbindir} -install -m 0755 %{S:1} %{buildroot}/%{_sbindir} +install -m 0755 %{SOURCE1} %{buildroot}/%{_sbindir} mkdir -p %{buildroot}/%{_unitdir} -install -m644 %{S:3} %{buildroot}/%{_unitdir} +install -m644 %{SOURCE3} %{buildroot}/%{_unitdir} +ln -s service %{buildroot}%{_sbindir}/rckexec-load #UsrMerge mkdir -p %{buildroot}/sbin ln -s %{_sbindir}/kdump %{buildroot}/sbin @@ -210,13 +98,13 @@ ln -s %{_sbindir}/kexec %{buildroot}/sbin %{?regenerate_initrd_posttrans} %files -%defattr(-, root, root) %doc AUTHORS COPYING News TODO doc -%doc %{_mandir}/man*/* +%{_mandir}/man*/* #UsrMerge /sbin/kdump /sbin/kexec #EndUsrMerge +%{_sbindir}/rckexec-load %{_sbindir}/kdump %{_sbindir}/kexec %{_sbindir}/kexec-bootloader