From c9ff8452afd50f2d07205d8b699031e79d040d78e7f18a200c4c67d2f3f344d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Thu, 19 Apr 2018 16:38:08 +0000 Subject: [PATCH 1/3] Accepting request 598547 from home:ptesarik:branches:Kernel:kdump - Bump to version 2.0.17 Changelog: http://git.kernel.org/cgit/utils/kernel/kexec/kexec-tools.git/log/?id=refs/tags/v2.0.16..v2.0.17 - Drop kexec-tools-xen-static.patch: upstream uses run-time dynamic linking to address the same issue. - Drop all patches from upstream git: * kexec-tools-add-a-helper-function-to-add-ranges.patch * kexec-tools-ppc64-parse-ibm-dynamic-memory.patch * kexec-tools-ppc64-leverage-kexec_file_load-support.patch * kexec-tools-Return-ENOSYS-when-kexec-does-not-know.patch * kexec-tools-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch * kexec-tools-Do-not-special-case-the-s-option.patch * kexec-tools-Add-option-to-revert-s.patch * kexec-tools-Add-option-to-fall-back-to-KEXEC_LOAD.patch * kexec-tools-Document-s-c-and-a-options-in-the-man-page.patch * kexec-tools-fix-kexec-p-segfault.patch OBS-URL: https://build.opensuse.org/request/show/598547 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=99 --- kexec-tools-2.0.16.tar.gz | 3 - kexec-tools-2.0.17.tar.xz | 3 + ...dd-option-to-fall-back-to-KEXEC_LOAD.patch | 172 ---------- kexec-tools-Add-option-to-revert-s.patch | 70 ---- ...ols-Do-not-special-case-the-s-option.patch | 76 ----- ...nt-s-c-and-a-options-in-the-man-page.patch | 50 --- ...ption-checks-to-take-KEXEC_FILE_LOAD.patch | 51 --- ...turn-ENOSYS-when-kexec-does-not-know.patch | 32 -- ...-add-a-helper-function-to-add-ranges.patch | 177 ---------- kexec-tools-fix-kexec-p-segfault.patch | 25 -- ...c64-leverage-kexec_file_load-support.patch | 146 -------- ...tools-ppc64-parse-ibm-dynamic-memory.patch | 311 ------------------ kexec-tools-xen-static.patch | 67 ---- kexec-tools.changes | 19 ++ kexec-tools.spec | 28 +- 15 files changed, 25 insertions(+), 1205 deletions(-) delete mode 100644 kexec-tools-2.0.16.tar.gz create mode 100644 kexec-tools-2.0.17.tar.xz delete mode 100644 kexec-tools-Add-option-to-fall-back-to-KEXEC_LOAD.patch delete mode 100644 kexec-tools-Add-option-to-revert-s.patch delete mode 100644 kexec-tools-Do-not-special-case-the-s-option.patch delete mode 100644 kexec-tools-Document-s-c-and-a-options-in-the-man-page.patch delete mode 100644 kexec-tools-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch delete mode 100644 kexec-tools-Return-ENOSYS-when-kexec-does-not-know.patch delete mode 100644 kexec-tools-add-a-helper-function-to-add-ranges.patch delete mode 100644 kexec-tools-fix-kexec-p-segfault.patch delete mode 100644 kexec-tools-ppc64-leverage-kexec_file_load-support.patch delete mode 100644 kexec-tools-ppc64-parse-ibm-dynamic-memory.patch delete mode 100644 kexec-tools-xen-static.patch diff --git a/kexec-tools-2.0.16.tar.gz b/kexec-tools-2.0.16.tar.gz deleted file mode 100644 index 43837ed..0000000 --- a/kexec-tools-2.0.16.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:79f442548d226fb09d92dec12be60e38b15b54a62054b54baceffb2215fa78e6 -size 367180 diff --git a/kexec-tools-2.0.17.tar.xz b/kexec-tools-2.0.17.tar.xz new file mode 100644 index 0000000..0690f64 --- /dev/null +++ b/kexec-tools-2.0.17.tar.xz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:504c816b769da573167b63f3b6d4fce3740f231c98d8db0c4fda47a4b90482a9 +size 290612 diff --git a/kexec-tools-Add-option-to-fall-back-to-KEXEC_LOAD.patch b/kexec-tools-Add-option-to-fall-back-to-KEXEC_LOAD.patch deleted file mode 100644 index a7950fb..0000000 --- a/kexec-tools-Add-option-to-fall-back-to-KEXEC_LOAD.patch +++ /dev/null @@ -1,172 +0,0 @@ -From: Michal Suchanek -Date: Mon, 26 Feb 2018 12:24:44 +0100 -Subject: kexec: Add option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD - is not supported -References: bsc#1080916, boo#1076839 -Upstream: merged -Git-commit: 9fa99c42cb911727a962b358c5b1d36d0fe338ab - -Not all architectures implement KEXEC_FILE_LOAD. However, on some -archiectures KEXEC_FILE_LOAD is required when secure boot is enabled in -locked-down mode. Previously users had to select the KEXEC_FILE_LOAD -syscall with undocumented -s option. However, if they did pass the -option kexec would fail on architectures that do not support it. - -So add an -a option that tries KEXEC_FILE_LOAD and when it is not -supported tries KEXEC_LOAD. - -Signed-off-by: Michal Suchanek ---- -v3: instead of changing the deafult add extra option -v4: actually check -ENOSYS as well -v5: add missing break -v6: - - add note about ENOTSUPP - - add description to help text ---- - kexec/kexec.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- - kexec/kexec.h | 4 +++- - 2 files changed, 63 insertions(+), 6 deletions(-) - -diff --git a/kexec/kexec.c b/kexec/kexec.c -index 87689311af2f..612c1c2afbe5 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1007,6 +1007,10 @@ void usage(void) - " -s, --kexec-file-syscall Use file based syscall for kexec operation\n" - " -c, --kexec-syscall Use the kexec_load syscall for for compatibility\n" - " with systems that don't support -s (default)\n" -+ " -a, --kexec-syscall-auto Use file based syscall for kexec and fall\n" -+ " back to the compatibility syscall when file based\n" -+ " syscall is not supported or the kernel did not\n" -+ " understand the image\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" -@@ -1245,6 +1249,7 @@ int main(int argc, char *argv[]) - int do_unload = 0; - int do_reuse_initrd = 0; - int do_kexec_file_syscall = 0; -+ int do_kexec_fallback = 0; - int do_status = 0; - void *entry = 0; - char *type = 0; -@@ -1369,9 +1374,15 @@ int main(int argc, char *argv[]) - break; - case OPT_KEXEC_FILE_SYSCALL: - do_kexec_file_syscall = 1; -+ do_kexec_fallback = 0; - break; - case OPT_KEXEC_SYSCALL: - do_kexec_file_syscall = 0; -+ do_kexec_fallback = 0; -+ break; -+ case OPT_KEXEC_SYSCALL_AUTO: -+ do_kexec_file_syscall = 1; -+ do_kexec_fallback = 1; - break; - case OPT_STATUS: - do_status = 1; -@@ -1438,7 +1449,7 @@ int main(int argc, char *argv[]) - } - } - if (do_kexec_file_syscall) { -- if (do_load_jump_back_helper) -+ if (do_load_jump_back_helper && !do_kexec_fallback) - die("--load-jump-back-helper not supported with kexec_file_load\n"); - if (kexec_flags & KEXEC_PRESERVE_CONTEXT) - die("--load-preserve-context not supported with kexec_file_load\n"); -@@ -1452,16 +1463,60 @@ int main(int argc, char *argv[]) - result = k_status(kexec_flags); - } - if (do_unload) { -- if (do_kexec_file_syscall) -+ if (do_kexec_file_syscall) { - result = kexec_file_unload(kexec_file_flags); -- else -+ if ((result == -ENOSYS) && do_kexec_fallback) -+ do_kexec_file_syscall = 0; -+ } -+ if (!do_kexec_file_syscall) - result = k_unload(kexec_flags); - } - if (do_load && (result == 0)) { -- if (do_kexec_file_syscall) -+ if (do_kexec_file_syscall) { - result = do_kexec_file_load(fileind, argc, argv, - kexec_file_flags); -- else -+ if (do_kexec_fallback) switch (result) { -+ /* -+ * Something failed with signature verification. -+ * Reject the image. -+ */ -+ case -ELIBBAD: -+ case -EKEYREJECTED: -+ case -ENOPKG: -+ case -ENOKEY: -+ case -EBADMSG: -+ case -EMSGSIZE: -+ /* -+ * By default reject or do nothing if -+ * succeded -+ */ -+ default: break; -+ case -ENOSYS: /* not implemented */ -+ /* -+ * Parsing image or other options failed -+ * The image may be invalid or image -+ * type may not supported by kernel so -+ * retry parsing in kexec-tools. -+ */ -+ case -EINVAL: -+ case -ENOEXEC: -+ /* -+ * ENOTSUP can be unsupported image -+ * type or unsupported PE signature -+ * wrapper type, duh -+ * -+ * The kernel sometimes wrongly -+ * returns ENOTSUPP (524) - ignore -+ * that. It is not supposed to be seen -+ * by userspace so seeing it is a -+ * kernel bug -+ */ -+ case -ENOTSUP: -+ do_kexec_file_syscall = 0; -+ break; -+ } -+ } -+ if (!do_kexec_file_syscall) - result = my_load(type, fileind, argc, argv, - kexec_flags, entry); - } -diff --git a/kexec/kexec.h b/kexec/kexec.h -index 9fd0355eacd0..d445fbe3e486 100644 ---- a/kexec/kexec.h -+++ b/kexec/kexec.h -@@ -220,6 +220,7 @@ extern int file_types; - #define OPT_PANIC 'p' - #define OPT_KEXEC_FILE_SYSCALL 's' - #define OPT_KEXEC_SYSCALL 'c' -+#define OPT_KEXEC_SYSCALL_AUTO 'a' - #define OPT_STATUS 'S' - #define OPT_MEM_MIN 256 - #define OPT_MEM_MAX 257 -@@ -248,11 +249,12 @@ extern int file_types; - { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ - { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ - { "kexec-syscall", 0, 0, OPT_KEXEC_SYSCALL }, \ -+ { "kexec-syscall-auto", 0, 0, OPT_KEXEC_SYSCALL_AUTO }, \ - { "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:pscS" -+#define KEXEC_OPT_STR "h?vdfxyluet:pscaS" - - extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr); - extern void die(const char *fmt, ...) --- -2.13.6 - diff --git a/kexec-tools-Add-option-to-revert-s.patch b/kexec-tools-Add-option-to-revert-s.patch deleted file mode 100644 index c5f509c..0000000 --- a/kexec-tools-Add-option-to-revert-s.patch +++ /dev/null @@ -1,70 +0,0 @@ -From: Michal Suchanek -Date: Mon, 26 Feb 2018 12:24:44 +0100 -Subject: kexec: Add option to revert -s -References: bsc#1080916, boo#1076839 -Upstream: merged -Git-commit: a8639a304b7b62384fc1c747c35eee7728ce583f - -The undocumented -s option selects KEXEC_FILE_LOAD syscall but there is -no option to select KEXEC_LOAD syscall. Add it so -s can be reverted. - -Signed-off-by: Michal Suchanek ---- -v6: add description to help text ---- - kexec/kexec.c | 5 +++++ - kexec/kexec.h | 4 +++- - 2 files changed, 8 insertions(+), 1 deletion(-) - -diff --git a/kexec/kexec.c b/kexec/kexec.c -index 68ae0594d4a7..87689311af2f 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1005,6 +1005,8 @@ void usage(void) - " preserve context)\n" - " to original kernel.\n" - " -s, --kexec-file-syscall Use file based syscall for kexec operation\n" -+ " -c, --kexec-syscall Use the kexec_load syscall for for compatibility\n" -+ " with systems that don't support -s (default)\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" -@@ -1368,6 +1370,9 @@ int main(int argc, char *argv[]) - case OPT_KEXEC_FILE_SYSCALL: - do_kexec_file_syscall = 1; - break; -+ case OPT_KEXEC_SYSCALL: -+ do_kexec_file_syscall = 0; -+ break; - case OPT_STATUS: - do_status = 1; - break; -diff --git a/kexec/kexec.h b/kexec/kexec.h -index 26225d2c002a..9fd0355eacd0 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_KEXEC_SYSCALL 'c' - #define OPT_STATUS 'S' - #define OPT_MEM_MIN 256 - #define OPT_MEM_MAX 257 -@@ -246,11 +247,12 @@ extern int file_types; - { "mem-max", 1, 0, OPT_MEM_MAX }, \ - { "reuseinitrd", 0, 0, OPT_REUSE_INITRD }, \ - { "kexec-file-syscall", 0, 0, OPT_KEXEC_FILE_SYSCALL }, \ -+ { "kexec-syscall", 0, 0, OPT_KEXEC_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" -+#define KEXEC_OPT_STR "h?vdfxyluet:pscS" - - extern void dbgprint_mem_range(const char *prefix, struct memory_range *mr, int nr_mr); - extern void die(const char *fmt, ...) --- -2.13.6 - diff --git a/kexec-tools-Do-not-special-case-the-s-option.patch b/kexec-tools-Do-not-special-case-the-s-option.patch deleted file mode 100644 index 7c6f070..0000000 --- a/kexec-tools-Do-not-special-case-the-s-option.patch +++ /dev/null @@ -1,76 +0,0 @@ -From: Michal Suchanek -Date: Mon, 26 Feb 2018 12:17:01 +0100 -Subject: kexec: Do not special-case the -s option -References: bsc#1080916, boo#1076839 -Upstream: merged -Git-commit: 1ce7ef9717b1e1a721a1012d1de1ed2b4eae9485 - -It is parsed separately to save a few CPU cycles when setting up other -options but it just complicates the code. So fold it back and set up all -flags for both KEXEC_LOAD and KEXEC_FILE_LOAD - -Signed-off-by: Michal Suchanek ---- - kexec/kexec.c | 25 ++++--------------------- - 1 file changed, 4 insertions(+), 21 deletions(-) - -diff --git a/kexec/kexec.c b/kexec/kexec.c -index b793f31ea501..68ae0594d4a7 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1256,19 +1256,6 @@ int main(int argc, char *argv[]) - }; - static const char short_options[] = KEXEC_ALL_OPT_STR; - -- /* -- * First check if --use-kexec-file-syscall is set. That changes lot of -- * things -- */ -- while ((opt = getopt_long(argc, argv, short_options, -- options, 0)) != -1) { -- switch(opt) { -- case OPT_KEXEC_FILE_SYSCALL: -- do_kexec_file_syscall = 1; -- break; -- } -- } -- - /* Reset getopt for the next pass. */ - opterr = 1; - optind = 1; -@@ -1310,8 +1297,7 @@ int main(int argc, char *argv[]) - do_shutdown = 0; - do_sync = 0; - do_unload = 1; -- if (do_kexec_file_syscall) -- kexec_file_flags |= KEXEC_FILE_UNLOAD; -+ kexec_file_flags |= KEXEC_FILE_UNLOAD; - break; - case OPT_EXEC: - do_load = 0; -@@ -1354,11 +1340,8 @@ int main(int argc, char *argv[]) - do_exec = 0; - do_shutdown = 0; - do_sync = 0; -- if (do_kexec_file_syscall) -- kexec_file_flags |= KEXEC_FILE_ON_CRASH; -- else -- kexec_flags = KEXEC_ON_CRASH; -- break; -+ kexec_file_flags |= KEXEC_FILE_ON_CRASH; -+ kexec_flags = KEXEC_ON_CRASH; - case OPT_MEM_MIN: - mem_min = strtoul(optarg, &endptr, 0); - if (*endptr) { -@@ -1383,7 +1366,7 @@ int main(int argc, char *argv[]) - do_reuse_initrd = 1; - break; - case OPT_KEXEC_FILE_SYSCALL: -- /* We already parsed it. Nothing to do. */ -+ do_kexec_file_syscall = 1; - break; - case OPT_STATUS: - do_status = 1; --- -2.13.6 - diff --git a/kexec-tools-Document-s-c-and-a-options-in-the-man-page.patch b/kexec-tools-Document-s-c-and-a-options-in-the-man-page.patch deleted file mode 100644 index 5f95588..0000000 --- a/kexec-tools-Document-s-c-and-a-options-in-the-man-page.patch +++ /dev/null @@ -1,50 +0,0 @@ -From: Michal Suchanek -Date: Mon, 26 Feb 2018 12:51:21 +0100 -Subject: kexec: Document -s, -c and -a options in the man page -References: bsc#1080916, boo#1076839 -Upstream: merged -Git-commit: 1ded8729a29ff36880fc5169e93361971f4cab35 - -Signed-off-by: Michal Suchanek ---- -v5: document that KEXEC_LOAD may be disabled -v6: document that fallback happens in case the kernel does not -understand the image ---- - kexec/kexec.8 | 20 ++++++++++++++++++++ - 1 file changed, 20 insertions(+) - -diff --git a/kexec/kexec.8 b/kexec/kexec.8 -index e0131b4ea827..fb8a4c9caa45 100644 ---- a/kexec/kexec.8 -+++ b/kexec/kexec.8 -@@ -144,6 +144,26 @@ Load the new kernel for use on panic. - Specify that the new kernel is of this - .I type. - .TP -+.BI \-s\ (\-\-kexec-file-syscall) -+Specify that the new KEXEC_FILE_LOAD syscall should be used exclusively. -+.TP -+.BI \-c\ (\-\-kexec-syscall) -+Specify that the old KEXEC_LOAD syscall should be used exclusively (the default). -+.TP -+.BI \-a\ (\-\-kexec-syscall-auto) -+Try the new KEXEC_FILE_LOAD syscall first and when it is not supported or the -+kernel does not understand the supplied image fall back to the old KEXEC_LOAD -+interface. -+ -+There is no one single interface that always works. -+ -+KEXEC_FILE_LOAD is required on systems that use locked-down secure boot to -+verify the kernel signature. KEXEC_LOAD may be also disabled in the kernel -+configuration. -+ -+KEXEC_LOAD is required for some kernel image formats and on architectures that -+do not implement KEXEC_FILE_LOAD. -+.TP - .B \-u\ (\-\-unload) - Unload the current - .B kexec --- -2.13.6 - diff --git a/kexec-tools-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch b/kexec-tools-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch deleted file mode 100644 index 3e378be..0000000 --- a/kexec-tools-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch +++ /dev/null @@ -1,51 +0,0 @@ -From: Michal Suchanek -Date: Fri, 16 Mar 2018 16:40:27 +0100 -Subject: kexec: Fix option checks to take KEXEC_FILE_LOAD into account -References: bsc#1080916, boo#1076839 -Upstream: merged -Git-commit: bf36a4623b5ef67b3ae9722972fc135c608df963 - -When kexec_file_load support was added some sanity checks were not updated. - -Some options are set only in the kexec_load flags so cannot be supported -wiht kexec_file_load. On the other hand, reserved memory is needed for -kdump with both kexec_load and kexec_file_load. - -Signed-off-by: Michal Suchanek ---- -Added in v5 ---- - kexec/kexec.c | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/kexec/kexec.c b/kexec/kexec.c -index ab8cff7fe083..b793f31ea501 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1415,7 +1415,9 @@ int main(int argc, char *argv[]) - do_load_jump_back_helper = 0; - } - -- if (do_load && (kexec_flags & KEXEC_ON_CRASH) && -+ if (do_load && -+ ((kexec_flags & KEXEC_ON_CRASH) || -+ (kexec_file_flags & KEXEC_FILE_ON_CRASH)) && - !is_crashkernel_mem_reserved()) { - die("Memory for crashkernel is not reserved\n" - "Please reserve memory by passing" -@@ -1447,6 +1449,12 @@ int main(int argc, char *argv[]) - } - } - } -+ if (do_kexec_file_syscall) { -+ if (do_load_jump_back_helper) -+ die("--load-jump-back-helper not supported with kexec_file_load\n"); -+ if (kexec_flags & KEXEC_PRESERVE_CONTEXT) -+ die("--load-preserve-context not supported with kexec_file_load\n"); -+ } - - if (do_reuse_initrd){ - check_reuse_initrd(); --- -2.13.6 - diff --git a/kexec-tools-Return-ENOSYS-when-kexec-does-not-know.patch b/kexec-tools-Return-ENOSYS-when-kexec-does-not-know.patch deleted file mode 100644 index 6aa2ac7..0000000 --- a/kexec-tools-Return-ENOSYS-when-kexec-does-not-know.patch +++ /dev/null @@ -1,32 +0,0 @@ -From: Michal Suchanek -Date: Mon, 26 Feb 2018 12:12:38 +0100 -Subject: kexec: Return -ENOSYS when kexec does not know how to call KEXEC_FILE_LOAD -References: bsc#1080916, boo#1076839 -Upstream: merged -Git-commit: e810acd57d9fc2d7ba3b0e95d470c20de9948462 - -When the kernel does not know a syscall number it returns -ENOSYS but -when kexec does not know a syscall number it returns -1. Return -ENOSYS -from kexec as well. - -Signed-off-by: Michal Suchanek ---- - kexec/kexec.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/kexec/kexec.c b/kexec/kexec.c -index cfd837c1b6bb..ab8cff7fe083 100644 ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1166,7 +1166,7 @@ static int do_kexec_file_load(int fileind, int argc, char **argv, - - if (!is_kexec_file_load_implemented()) { - fprintf(stderr, "syscall kexec_file_load not available.\n"); -- return -1; -+ return -ENOSYS; - } - - if (argc - fileind <= 0) { --- -2.13.6 - diff --git a/kexec-tools-add-a-helper-function-to-add-ranges.patch b/kexec-tools-add-a-helper-function-to-add-ranges.patch deleted file mode 100644 index 6e2303a..0000000 --- a/kexec-tools-add-a-helper-function-to-add-ranges.patch +++ /dev/null @@ -1,177 +0,0 @@ -From: Hari Bathini -Date: Tue, 20 Feb 2018 19:48:00 +0530 -Subject: kexec: add a helper function to add ranges -References: bsc#1081789, LTC#164625 -Upstream: merged -Git-commit: c740fdb2048265551f77d3f0fe53b2fddc0c8489 Mon Sep 17 00:00:00 2001 - -Add a helper function for adding ranges to avoid duplicating code. - -Signed-off-by: Hari Bathini -Reviewed-by: Mahesh Salgaonkar -Signed-off-by: Simon Horman -Acked-by: Petr Tesarik - ---- - kexec/fs2dt.c | 115 ++++++++++++++++++++++++++-------------------------------- - 1 file changed, 53 insertions(+), 62 deletions(-) - ---- a/kexec/fs2dt.c -+++ b/kexec/fs2dt.c -@@ -169,6 +169,50 @@ static unsigned propnum(const char *name - return offset; - } - -+/* -+ * Add ranges by comparing 'base' and 'end' addresses with usable -+ * memory ranges. Returns the number of ranges added. Each range added -+ * increments 'idx' by 2. -+ */ -+static uint64_t add_ranges(uint64_t **ranges, int *ranges_size, int idx, -+ uint64_t base, uint64_t end) -+{ -+ uint64_t loc_base, loc_end, rngs_cnt = 0; -+ size_t range; -+ int add = 0; -+ -+ for (range = 0; range < usablemem_rgns.size; range++) { -+ loc_base = usablemem_rgns.ranges[range].start; -+ loc_end = usablemem_rgns.ranges[range].end; -+ if (loc_base >= base && loc_end <= end) { -+ add = 1; -+ } else if (base < loc_end && end > loc_base) { -+ if (loc_base < base) -+ loc_base = base; -+ if (loc_end > end) -+ loc_end = end; -+ add = 1; -+ } -+ -+ if (add) { -+ if (idx >= ((*ranges_size) - 2)) { -+ (*ranges_size) += MEM_RANGE_CHUNK_SZ; -+ *ranges = realloc(*ranges, (*ranges_size)*8); -+ if (!(*ranges)) -+ die("unrecoverable error: can't realloc" -+ "%d bytes for ranges.\n", -+ (*ranges_size)*8); -+ } -+ (*ranges)[idx++] = cpu_to_be64(loc_base); -+ (*ranges)[idx++] = cpu_to_be64(loc_end - loc_base); -+ -+ rngs_cnt++; -+ } -+ } -+ -+ return rngs_cnt; -+} -+ - #ifdef HAVE_DYNAMIC_MEMORY - static void add_dyn_reconf_usable_mem_property__(int fd) - { -@@ -176,8 +220,8 @@ static void add_dyn_reconf_usable_mem_pr - uint64_t buf[32]; - uint64_t *ranges; - int ranges_size = MEM_RANGE_CHUNK_SZ; -- uint64_t base, end, loc_base, loc_end; -- size_t i, rngs_cnt, range; -+ uint64_t base, end, rngs_cnt; -+ size_t i; - int rlen = 0; - int tmp_indx; - -@@ -210,36 +254,8 @@ static void add_dyn_reconf_usable_mem_pr - - tmp_indx = rlen++; - -- rngs_cnt = 0; -- for (range = 0; range < usablemem_rgns.size; range++) { -- int add = 0; -- loc_base = usablemem_rgns.ranges[range].start; -- loc_end = usablemem_rgns.ranges[range].end; -- if (loc_base >= base && loc_end <= end) { -- add = 1; -- } else if (base < loc_end && end > loc_base) { -- if (loc_base < base) -- loc_base = base; -- if (loc_end > end) -- loc_end = end; -- add = 1; -- } -- -- if (add) { -- if (rlen >= (ranges_size-2)) { -- ranges_size += MEM_RANGE_CHUNK_SZ; -- ranges = realloc(ranges, ranges_size*8); -- if (!ranges) -- die("unrecoverable error: can't" -- " realloc %d bytes for" -- " ranges.\n", -- ranges_size*8); -- } -- ranges[rlen++] = cpu_to_be64(loc_base); -- ranges[rlen++] = cpu_to_be64(loc_end - loc_base); -- rngs_cnt++; -- } -- } -+ rngs_cnt = add_ranges(&ranges, &ranges_size, rlen, -+ base, end); - if (rngs_cnt == 0) { - /* We still need to add a counter for every LMB because - * the kernel parsing code is dumb. We just have -@@ -261,7 +277,8 @@ static void add_dyn_reconf_usable_mem_pr - } - } else { - /* Store the count of (base, size) duple */ -- ranges[tmp_indx] = cpu_to_be64((uint64_t) rngs_cnt); -+ ranges[tmp_indx] = cpu_to_be64(rngs_cnt); -+ rlen += rngs_cnt * 2; - } - } - -@@ -294,8 +311,7 @@ static void add_usable_mem_property(int - uint64_t buf[2]; - uint64_t *ranges; - int ranges_size = MEM_RANGE_CHUNK_SZ; -- uint64_t base, end, loc_base, loc_end; -- size_t range; -+ uint64_t base, end, rngs_cnt; - int rlen = 0; - - strcpy(fname, pathname); -@@ -326,33 +342,8 @@ static void add_usable_mem_property(int - die("unrecoverable error: can't alloc %zu bytes for ranges.\n", - ranges_size * sizeof(*ranges)); - -- for (range = 0; range < usablemem_rgns.size; range++) { -- int add = 0; -- loc_base = usablemem_rgns.ranges[range].start; -- loc_end = usablemem_rgns.ranges[range].end; -- if (loc_base >= base && loc_end <= end) { -- add = 1; -- } else if (base < loc_end && end > loc_base) { -- if (loc_base < base) -- loc_base = base; -- if (loc_end > end) -- loc_end = end; -- add = 1; -- } -- if (add) { -- if (rlen >= (ranges_size-2)) { -- ranges_size += MEM_RANGE_CHUNK_SZ; -- ranges = realloc(ranges, ranges_size * -- sizeof(*ranges)); -- if (!ranges) -- die("unrecoverable error: can't realloc" -- "%zu bytes for ranges.\n", -- ranges_size*sizeof(*ranges)); -- } -- ranges[rlen++] = cpu_to_be64(loc_base); -- ranges[rlen++] = cpu_to_be64(loc_end - loc_base); -- } -- } -+ rngs_cnt = add_ranges(&ranges, &ranges_size, rlen, base, end); -+ rlen += rngs_cnt * 2; - - if (!rlen) { - /* diff --git a/kexec-tools-fix-kexec-p-segfault.patch b/kexec-tools-fix-kexec-p-segfault.patch deleted file mode 100644 index b619095..0000000 --- a/kexec-tools-fix-kexec-p-segfault.patch +++ /dev/null @@ -1,25 +0,0 @@ -From: Petr Tesarik -Date: Thu, 5 Apr 2018 13:07:49 +0200 -Subject: Fix a segmentation fault when trying to run "kexec -p". -References: bsc#1080916 -Upstream: not yet, to be posted after more testing - -Do not fall through to "--mem-min" when "-p" option is parsed. The -break statement was apparently removed by mistake... - -Fixes: cb434cbe6f401037e448276bb12056d1fdc3dbfc -Signed-off-by: Petr Tesarik ---- - kexec/kexec.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/kexec/kexec.c -+++ b/kexec/kexec.c -@@ -1352,6 +1352,7 @@ int main(int argc, char *argv[]) - do_sync = 0; - kexec_file_flags |= KEXEC_FILE_ON_CRASH; - kexec_flags = KEXEC_ON_CRASH; -+ break; - case OPT_MEM_MIN: - mem_min = strtoul(optarg, &endptr, 0); - if (*endptr) { diff --git a/kexec-tools-ppc64-leverage-kexec_file_load-support.patch b/kexec-tools-ppc64-leverage-kexec_file_load-support.patch deleted file mode 100644 index 6e9484e..0000000 --- a/kexec-tools-ppc64-leverage-kexec_file_load-support.patch +++ /dev/null @@ -1,146 +0,0 @@ -From: Hari Bathini -Date: Mon, 26 Mar 2018 14:16:34 +0530 -Subject: kexec/ppc64: leverage kexec_file_load support -References: bsc#1080916 -Upstream: merged -Git-commit: 3720b743ae3ced0407e811a4223228d305dc4705 - -PPC64 kernel now supports kexec_file_load system call. Leverage it by -enabling that support here. Note that loading crash kernel with this -system call is not yet supported in the kernel and trying to load one -will fail with '-ENOTSUPP' error. - -Signed-off-by: Hari Bathini -Reviewed-by: Thiago Jung Bauermann -Signed-off-by: Simon Horman ---- - kexec/arch/ppc64/kexec-elf-ppc64.c | 84 ++++++++++++++++++++++++++++++++++++++ - kexec/kexec-syscall.h | 3 ++ - 2 files changed, 87 insertions(+) - -diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c -index ddd3de8235fd..3510b70821da 100644 ---- a/kexec/arch/ppc64/kexec-elf-ppc64.c -+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c -@@ -93,6 +93,85 @@ static int read_prop(char *name, void *value, size_t len) - return 0; - } - -+static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info) -+{ -+ int ret = 0; -+ char *cmdline, *dtb; -+ int opt, cmdline_len = 0; -+ -+ /* See options.h -- add any more there, too. */ -+ static const struct option options[] = { -+ KEXEC_ARCH_OPTIONS -+ { "command-line", 1, NULL, OPT_APPEND }, -+ { "append", 1, NULL, OPT_APPEND }, -+ { "ramdisk", 1, NULL, OPT_RAMDISK }, -+ { "initrd", 1, NULL, OPT_RAMDISK }, -+ { "devicetreeblob", 1, NULL, OPT_DEVICETREEBLOB }, -+ { "dtb", 1, NULL, OPT_DEVICETREEBLOB }, -+ { "args-linux", 0, NULL, OPT_ARGS_IGNORE }, -+ { 0, 0, NULL, 0 }, -+ }; -+ -+ static const char short_options[] = KEXEC_OPT_STR ""; -+ -+ /* Parse command line arguments */ -+ cmdline = 0; -+ dtb = 0; -+ ramdisk = 0; -+ -+ while ((opt = getopt_long(argc, argv, short_options, -+ options, 0)) != -1) { -+ switch (opt) { -+ default: -+ /* Ignore core options */ -+ if (opt < OPT_ARCH_MAX) -+ break; -+ case OPT_APPEND: -+ cmdline = optarg; -+ break; -+ case OPT_RAMDISK: -+ ramdisk = optarg; -+ break; -+ case OPT_DEVICETREEBLOB: -+ dtb = optarg; -+ break; -+ case OPT_ARGS_IGNORE: -+ break; -+ } -+ } -+ -+ if (dtb) -+ die("--dtb not supported while using --kexec-file-syscall.\n"); -+ -+ if (reuse_initrd) -+ die("--reuseinitrd not supported with --kexec-file-syscall.\n"); -+ -+ if (cmdline) { -+ cmdline_len = strlen(cmdline) + 1; -+ } else { -+ cmdline = strdup("\0"); -+ cmdline_len = 1; -+ } -+ -+ if (ramdisk) { -+ info->initrd_fd = open(ramdisk, O_RDONLY); -+ if (info->initrd_fd == -1) { -+ fprintf(stderr, "Could not open initrd file %s:%s\n", -+ ramdisk, strerror(errno)); -+ ret = -1; -+ goto out; -+ } -+ } -+ -+ info->command_line = cmdline; -+ info->command_line_len = cmdline_len; -+ return ret; -+out: -+ if (cmdline_len == 1) -+ free(cmdline); -+ return ret; -+} -+ - int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len, - struct kexec_info *info) - { -@@ -132,6 +211,9 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len, - - static const char short_options[] = KEXEC_OPT_STR ""; - -+ if (info->file_mode) -+ return elf_ppc64_load_file(argc, argv, info); -+ - /* Parse command line arguments */ - initrd_base = 0; - initrd_size = 0; -@@ -387,6 +469,8 @@ void elf_ppc64_usage(void) - fprintf(stderr, " --ramdisk= Initial RAM disk.\n"); - fprintf(stderr, " --initrd= same as --ramdisk.\n"); - fprintf(stderr, " --devicetreeblob= Specify device tree blob file.\n"); -+ fprintf(stderr, " "); -+ fprintf(stderr, "Not applicable while using --kexec-file-syscall.\n"); - fprintf(stderr, " --dtb= same as --devicetreeblob.\n"); - - fprintf(stderr, "elf support is still broken\n"); -diff --git a/kexec/kexec-syscall.h b/kexec/kexec-syscall.h -index 3b5c528d8aac..33638c25794c 100644 ---- a/kexec/kexec-syscall.h -+++ b/kexec/kexec-syscall.h -@@ -61,6 +61,9 @@ - #ifdef __x86_64__ - #define __NR_kexec_file_load 320 - #endif -+#ifdef __powerpc64__ -+#define __NR_kexec_file_load 382 -+#endif - - #ifndef __NR_kexec_file_load - /* system call not available for the arch */ --- -2.13.6 - diff --git a/kexec-tools-ppc64-parse-ibm-dynamic-memory.patch b/kexec-tools-ppc64-parse-ibm-dynamic-memory.patch deleted file mode 100644 index 5836a75..0000000 --- a/kexec-tools-ppc64-parse-ibm-dynamic-memory.patch +++ /dev/null @@ -1,311 +0,0 @@ -From: Hari Bathini -Date: Tue, 20 Feb 2018 19:48:09 +0530 -Subject: kexec/ppc64: add support to parse ibm, dynamic-memory-v2 property -References: bsc#1081789, LTC#164625 -Upstream: merged -Git-commit: b10924a7da3ca48c04982cd23daf04882afb1a87 - -Add support to parse the new 'ibm,dynamic-memory-v2' property in the -'ibm,dynamic-reconfiguration-memory' node. This replaces the old -'ibm,dynamic-memory' property and is enabled in the kernel with a -patch series that starts with commit 0c38ed6f6f0b ("powerpc/pseries: -Enable support of ibm,dynamic-memory-v2"). All LMBs that share the same -flags and are adjacent are grouped together in the newer version of the -property making it compact to represent larger memory configurations. - -Signed-off-by: Hari Bathini -Mahesh Jagannath Salgaonkar -Signed-off-by: Simon Horman -Acked-by: Petr Tesarik - ---- - kexec/arch/ppc64/crashdump-ppc64.c | 23 +++++++-- - kexec/arch/ppc64/crashdump-ppc64.h | 14 ++++- - kexec/arch/ppc64/kexec-ppc64.c | 35 ++++++++++---- - kexec/fs2dt.c | 92 ++++++++++++++++++++++--------------- - 4 files changed, 111 insertions(+), 53 deletions(-) - ---- a/kexec/arch/ppc64/crashdump-ppc64.c -+++ b/kexec/arch/ppc64/crashdump-ppc64.c -@@ -39,6 +39,10 @@ - #define DEVTREE_CRASHKERNEL_BASE "/proc/device-tree/chosen/linux,crashkernel-base" - #define DEVTREE_CRASHKERNEL_SIZE "/proc/device-tree/chosen/linux,crashkernel-size" - -+unsigned int num_of_lmb_sets; -+unsigned int is_dyn_mem_v2; -+uint64_t lmb_size; -+ - static struct crash_elf_info elf_info64 = - { - class: ELFCLASS64, -@@ -127,6 +131,7 @@ static int get_dyn_reconf_crash_memory_r - { - uint64_t start, end; - uint64_t startrange, endrange; -+ uint64_t size; - char fname[128], buf[32]; - FILE *file; - unsigned int i; -@@ -135,6 +140,8 @@ static int get_dyn_reconf_crash_memory_r - - strcpy(fname, "/proc/device-tree/"); - strcat(fname, "ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory"); -+ if (is_dyn_mem_v2) -+ strcat(fname, "-v2"); - if ((file = fopen(fname, "r")) == NULL) { - perror(fname); - return -1; -@@ -142,8 +149,9 @@ static int get_dyn_reconf_crash_memory_r - - fseek(file, 4, SEEK_SET); - startrange = endrange = 0; -- for (i = 0; i < num_of_lmbs; i++) { -- if ((n = fread(buf, 1, 24, file)) < 0) { -+ size = lmb_size; -+ for (i = 0; i < num_of_lmb_sets; i++) { -+ if ((n = fread(buf, 1, LMB_ENTRY_SIZE, file)) < 0) { - perror(fname); - fclose(file); - return -1; -@@ -156,8 +164,15 @@ static int get_dyn_reconf_crash_memory_r - return -1; - } - -- start = be64_to_cpu(((uint64_t *)buf)[DRCONF_ADDR]); -- end = start + lmb_size; -+ /* -+ * If the property is ibm,dynamic-memory-v2, the first 4 bytes -+ * tell the number of sequential LMBs in this entry. -+ */ -+ if (is_dyn_mem_v2) -+ size = be32_to_cpu(((unsigned int *)buf)[0]) * lmb_size; -+ -+ start = be64_to_cpu(*((uint64_t *)&buf[DRCONF_ADDR])); -+ end = start + size; - if (start == 0 && end >= (BACKUP_SRC_END + 1)) - start = BACKUP_SRC_END + 1; - ---- a/kexec/arch/ppc64/crashdump-ppc64.h -+++ b/kexec/arch/ppc64/crashdump-ppc64.h -@@ -34,10 +34,18 @@ extern unsigned int rtas_size; - extern uint64_t opal_base; - extern uint64_t opal_size; - --uint64_t lmb_size; --unsigned int num_of_lmbs; -+/* -+ * In case of ibm,dynamic-memory-v2 property, this is the number of LMB -+ * sets where each set represents a group of sequential LMB entries. In -+ * case of ibm,dynamic-memory property, the number of LMB sets is nothing -+ * but the total number of LMB entries. -+ */ -+extern unsigned int num_of_lmb_sets; -+extern unsigned int is_dyn_mem_v2; -+extern uint64_t lmb_size; - --#define DRCONF_ADDR 0 -+#define LMB_ENTRY_SIZE 24 -+#define DRCONF_ADDR (is_dyn_mem_v2 ? 4 : 0) - #define DRCONF_FLAGS 20 - - #endif /* CRASHDUMP_PPC64_H */ ---- a/kexec/arch/ppc64/kexec-ppc64.c -+++ b/kexec/arch/ppc64/kexec-ppc64.c -@@ -149,6 +149,7 @@ static void add_base_memory_range(uint64 - static int get_dyn_reconf_base_ranges(void) - { - uint64_t start, end; -+ uint64_t size; - char fname[128], buf[32]; - FILE *file; - unsigned int i; -@@ -166,29 +167,35 @@ static int get_dyn_reconf_base_ranges(vo - return -1; - } - /* -- * lmb_size, num_of_lmbs(global variables) are -+ * lmb_size, num_of_lmb_sets(global variables) are - * initialized once here. - */ -- lmb_size = be64_to_cpu(((uint64_t *)buf)[0]); -+ size = lmb_size = be64_to_cpu(((uint64_t *)buf)[0]); - fclose(file); - - strcpy(fname, "/proc/device-tree/"); - strcat(fname, - "ibm,dynamic-reconfiguration-memory/ibm,dynamic-memory"); - if ((file = fopen(fname, "r")) == NULL) { -- perror(fname); -- return -1; -+ strcat(fname, "-v2"); -+ if ((file = fopen(fname, "r")) == NULL) { -+ perror(fname); -+ return -1; -+ } -+ -+ is_dyn_mem_v2 = 1; - } -- /* first 4 bytes tell the number of lmbs */ -+ -+ /* first 4 bytes tell the number of lmb set entries */ - if (fread(buf, 1, 4, file) != 4) { - perror(fname); - fclose(file); - return -1; - } -- num_of_lmbs = be32_to_cpu(((unsigned int *)buf)[0]); -+ num_of_lmb_sets = be32_to_cpu(((unsigned int *)buf)[0]); - -- for (i = 0; i < num_of_lmbs; i++) { -- if ((n = fread(buf, 1, 24, file)) < 0) { -+ for (i = 0; i < num_of_lmb_sets; i++) { -+ if ((n = fread(buf, 1, LMB_ENTRY_SIZE, file)) < 0) { - perror(fname); - fclose(file); - return -1; -@@ -196,13 +203,21 @@ static int get_dyn_reconf_base_ranges(vo - if (nr_memory_ranges >= max_memory_ranges) - return -1; - -- start = be64_to_cpu(((uint64_t *)buf)[0]); -- end = start + lmb_size; -+ /* -+ * If the property is ibm,dynamic-memory-v2, the first 4 bytes -+ * tell the number of sequential LMBs in this entry. -+ */ -+ if (is_dyn_mem_v2) -+ size = be32_to_cpu(((unsigned int *)buf)[0]) * lmb_size; -+ -+ start = be64_to_cpu(*((uint64_t *)&buf[DRCONF_ADDR])); -+ end = start + size; - add_base_memory_range(start, end); - } - fclose(file); - return 0; - } -+ - /* Sort the base ranges in memory - this is useful for ensuring that our - * ranges are in ascending order, even if device-tree read of memory nodes - * is done differently. Also, could be used for other range coalescing later ---- a/kexec/fs2dt.c -+++ b/kexec/fs2dt.c -@@ -217,11 +217,12 @@ static uint64_t add_ranges(uint64_t **ra - static void add_dyn_reconf_usable_mem_property__(int fd) - { - char fname[MAXPATH], *bname; -- uint64_t buf[32]; -+ char buf[32]; -+ uint32_t lmbs_in_set = 1; - uint64_t *ranges; - int ranges_size = MEM_RANGE_CHUNK_SZ; - uint64_t base, end, rngs_cnt; -- size_t i; -+ size_t i, j; - int rlen = 0; - int tmp_indx; - -@@ -242,43 +243,61 @@ static void add_dyn_reconf_usable_mem_pr - ranges_size*8); - - rlen = 0; -- for (i = 0; i < num_of_lmbs; i++) { -- if (read(fd, buf, 24) < 0) -+ for (i = 0; i < num_of_lmb_sets; i++) { -+ if (read(fd, buf, LMB_ENTRY_SIZE) < 0) - die("unrecoverable error: error reading \"%s\": %s\n", - pathname, strerror(errno)); - -- base = be64_to_cpu((uint64_t) buf[0]); -- end = base + lmb_size; -- if (~0ULL - base < end) -- die("unrecoverable error: mem property overflow\n"); -- -- tmp_indx = rlen++; -- -- rngs_cnt = add_ranges(&ranges, &ranges_size, rlen, -- base, end); -- if (rngs_cnt == 0) { -- /* We still need to add a counter for every LMB because -- * the kernel parsing code is dumb. We just have -- * a zero in this case, with no following base/len. -- */ -- ranges[tmp_indx] = 0; -- /* rlen is already just tmp_indx+1 as we didn't write -- * anything. Check array size here, as we'll probably -- * go on for a while writing zeros now. -- */ -- if (rlen >= (ranges_size-1)) { -- ranges_size += MEM_RANGE_CHUNK_SZ; -- ranges = realloc(ranges, ranges_size*8); -- if (!ranges) -- die("unrecoverable error: can't" -- " realloc %d bytes for" -- " ranges.\n", -- ranges_size*8); -+ /* -+ * If the property is ibm,dynamic-memory-v2, the first 4 bytes -+ * tell the number of sequential LMBs in this entry. Else, if -+ * the property is ibm,dynamic-memory, each entry represents -+ * one LMB. Make sure to add an entry for each LMB as kernel -+ * looks for a counter for every LMB. -+ */ -+ if (is_dyn_mem_v2) -+ lmbs_in_set = be32_to_cpu(((unsigned int *)buf)[0]); -+ -+ base = be64_to_cpu(*((uint64_t *)&buf[DRCONF_ADDR])); -+ for (j = 0; j < lmbs_in_set; j++) { -+ end = base + lmb_size; -+ if (~0ULL - base < end) { -+ die("unrecoverable error: mem property" -+ " overflow\n"); - } -- } else { -- /* Store the count of (base, size) duple */ -- ranges[tmp_indx] = cpu_to_be64(rngs_cnt); -- rlen += rngs_cnt * 2; -+ -+ tmp_indx = rlen++; -+ -+ rngs_cnt = add_ranges(&ranges, &ranges_size, rlen, -+ base, end); -+ if (rngs_cnt == 0) { -+ /* We still need to add a counter for every LMB -+ * because the kernel parsing code is dumb. We -+ * just have a zero in this case, with no -+ * following base/len. -+ */ -+ ranges[tmp_indx] = 0; -+ -+ /* rlen is already just tmp_indx+1 as we didn't -+ * write anything. Check array size here, as we -+ * will probably go on writing zeros for a while -+ */ -+ if (rlen >= (ranges_size-1)) { -+ ranges_size += MEM_RANGE_CHUNK_SZ; -+ ranges = realloc(ranges, ranges_size*8); -+ if (!ranges) -+ die("unrecoverable error: can't" -+ " realloc %d bytes for" -+ " ranges.\n", -+ ranges_size*8); -+ } -+ } else { -+ /* Store the count of (base, size) duple */ -+ ranges[tmp_indx] = cpu_to_be64(rngs_cnt); -+ rlen += rngs_cnt * 2; -+ } -+ -+ base = end; - } - } - -@@ -298,7 +317,8 @@ static void add_dyn_reconf_usable_mem_pr - - static void add_dyn_reconf_usable_mem_property(struct dirent *dp, int fd) - { -- if (!strcmp(dp->d_name, "ibm,dynamic-memory") && usablemem_rgns.size) -+ if ((!strcmp(dp->d_name, "ibm,dynamic-memory-v2") || -+ !strcmp(dp->d_name, "ibm,dynamic-memory")) && usablemem_rgns.size) - add_dyn_reconf_usable_mem_property__(fd); - } - #else diff --git a/kexec-tools-xen-static.patch b/kexec-tools-xen-static.patch deleted file mode 100644 index 76da12b..0000000 --- a/kexec-tools-xen-static.patch +++ /dev/null @@ -1,67 +0,0 @@ -From: Bernhard Walle -Subject: [PATCH] Link xenctrl statically -Upstream: no -Signed-off-by: Tony Jones - -This patch just links the xenctrl library statically. That allows -to use Xen support without a runtime dependency to the Xen package. - -31Oct2017: Updated to handle Xen 4.10 with new xentoolcore library - -Signed-off-by: Bernhard Walle -Signed-off-by: Charles Arnold - -================================================================================ ---- - configure.ac | 17 ++++++++++++++++- - 1 file changed, 16 insertions(+), 1 deletion(-) - -Index: kexec-tools-2.0.14/configure.ac -=================================================================== ---- kexec-tools-2.0.14.orig/configure.ac -+++ kexec-tools-2.0.14/configure.ac -@@ -164,8 +164,10 @@ fi - - dnl find Xen control stack libraries - if test "$with_xen" = yes ; then -+ if pkg-config --exists 'xenlight > 4.9.0' ; then - AC_CHECK_HEADER(xenctrl.h, -- [AC_CHECK_LIB(xenctrl, xc_kexec_load, , -+ [AC_CHECK_LIB(xenctrl, xc_kexec_load, -+ [AC_DEFINE([HAVE_LIBXENCTRL], [1], [libxenctrl]) [LIBS="-Wl,-Bstatic -lxenctrl -lxencall -lxentoolcore -lxentoollog -lxendevicemodel -lxenforeignmemory -Wl,-Bdynamic -lpthread -ldl $LIBS"]], - AC_MSG_NOTICE([Xen support disabled]))]) - if test "$ac_cv_lib_xenctrl_xc_kexec_load" = yes ; then - AC_CHECK_LIB(xenctrl, xc_kexec_status, -@@ -173,6 +175,32 @@ if test "$with_xen" = yes ; then - [The kexec_status call is available]), - AC_MSG_NOTICE([The kexec_status call is not available])) - fi -+ else -+ if pkg-config --exists 'xenlight > 4.8.0' ; then -+ AC_CHECK_HEADER(xenctrl.h, -+ [AC_CHECK_LIB(xenctrl, xc_kexec_load, -+ [AC_DEFINE([HAVE_LIBXENCTRL], [1], [libxenctrl]) [LIBS="-Wl,-Bstatic -lxenctrl -lxencall -lxentoollog -lxendevicemodel -lxenforeignmemory -Wl,-Bdynamic -lpthread -ldl $LIBS"]], -+ AC_MSG_NOTICE([Xen support disabled]))]) -+ 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]), -+ AC_MSG_NOTICE([The kexec_status call is not available])) -+ fi -+ else -+ if pkg-config --exists 'xenlight > 4.6.0' ; then -+ AC_CHECK_HEADER(xenctrl.h, -+ [AC_CHECK_LIB(xenctrl, xc_kexec_load, -+ [AC_DEFINE([HAVE_LIBXENCTRL], [1], [libxenctrl]) [LIBS="-Wl,-Bstatic -lxenctrl -lxencall -lxentoollog -lxenforeignmemory -Wl,-Bdynamic -lpthread -ldl $LIBS"]], -+ AC_MSG_NOTICE([Xen support disabled]))]) -+ else -+ AC_CHECK_HEADER(xenctrl.h, -+ [AC_CHECK_LIB(xenctrl, xc_kexec_load, -+ [AC_DEFINE([HAVE_LIBXENCTRL], [1], [libxenctrl]) [LIBS="-Wl,-Bstatic -lxenctrl -Wl,-Bdynamic -lpthread -ldl $LIBS"]], -+ AC_MSG_NOTICE([Xen support disabled]))]) -+ fi -+ fi -+ fi - fi - - dnl ---Sanity checks diff --git a/kexec-tools.changes b/kexec-tools.changes index 100769a..a5b1646 100644 --- a/kexec-tools.changes +++ b/kexec-tools.changes @@ -1,3 +1,22 @@ +------------------------------------------------------------------- +Thu Apr 19 11:54:10 UTC 2018 - ptesarik@suse.com + +- Bump to version 2.0.17 + Changelog: http://git.kernel.org/cgit/utils/kernel/kexec/kexec-tools.git/log/?id=refs/tags/v2.0.16..v2.0.17 +- Drop kexec-tools-xen-static.patch: upstream uses run-time dynamic + linking to address the same issue. +- Drop all patches from upstream git: + * kexec-tools-add-a-helper-function-to-add-ranges.patch + * kexec-tools-ppc64-parse-ibm-dynamic-memory.patch + * kexec-tools-ppc64-leverage-kexec_file_load-support.patch + * kexec-tools-Return-ENOSYS-when-kexec-does-not-know.patch + * kexec-tools-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch + * kexec-tools-Do-not-special-case-the-s-option.patch + * kexec-tools-Add-option-to-revert-s.patch + * kexec-tools-Add-option-to-fall-back-to-KEXEC_LOAD.patch + * kexec-tools-Document-s-c-and-a-options-in-the-man-page.patch + * kexec-tools-fix-kexec-p-segfault.patch + ------------------------------------------------------------------- Thu Apr 5 11:12:53 UTC 2018 - ptesarik@suse.com diff --git a/kexec-tools.spec b/kexec-tools.spec index 07c82d7..af24d30 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -17,30 +17,19 @@ Name: kexec-tools -Version: 2.0.16 +Version: 2.0.17 Release: 0 Summary: Tools for loading replacement kernels into memory License: GPL-2.0+ Group: System/Kernel -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 +Url: ftp://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz +Source: https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/snapshot/%{name}-%{version}.tar.xz Source1: kexec-bootloader 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 -Patch4: %{name}-add-a-helper-function-to-add-ranges.patch -Patch5: %{name}-ppc64-parse-ibm-dynamic-memory.patch -Patch6: %{name}-ppc64-leverage-kexec_file_load-support.patch -Patch7: %{name}-Return-ENOSYS-when-kexec-does-not-know.patch -Patch8: %{name}-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch -Patch9: %{name}-Do-not-special-case-the-s-option.patch -Patch10: %{name}-Add-option-to-revert-s.patch -Patch11: %{name}-Add-option-to-fall-back-to-KEXEC_LOAD.patch -Patch12: %{name}-Document-s-c-and-a-options-in-the-man-page.patch -Patch13: %{name}-fix-kexec-p-segfault.patch Patch14: %{name}-vmcoreinfo-in-xen.patch BuildRequires: autoconf BuildRequires: automake @@ -65,19 +54,8 @@ the loaded kernel after it panics. %prep %setup -q -%patch1 -p1 %patch2 -p1 %patch3 -p1 -%patch4 -p1 -%patch5 -p1 -%patch6 -p1 -%patch7 -p1 -%patch8 -p1 -%patch9 -p1 -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 -%patch13 -p1 %patch14 -p1 %build From 779edd17cb61d32d5d0357b3259d983f86ab20138c3c3af0229bbb05c364c57c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Fri, 20 Apr 2018 06:13:05 +0000 Subject: [PATCH 2/3] Adjust upstream tarball URL. OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=100 --- kexec-tools.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kexec-tools.spec b/kexec-tools.spec index af24d30..833d8c7 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -22,7 +22,7 @@ Release: 0 Summary: Tools for loading replacement kernels into memory License: GPL-2.0+ Group: System/Kernel -Url: ftp://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz +Url: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz Source: https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/snapshot/%{name}-%{version}.tar.xz Source1: kexec-bootloader Source2: kexec-bootloader.8 From b71a0fdea6a5ea3b7f15753cb3213210e122ae929906d1480a02627e2b5dd872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Tesa=C5=99=C3=ADk?= Date: Fri, 20 Apr 2018 06:16:02 +0000 Subject: [PATCH 3/3] The download_files service apparently does not handle redirections... OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=101 --- kexec-tools-2.0.17.tar.xz | 4 ++-- kexec-tools.spec | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kexec-tools-2.0.17.tar.xz b/kexec-tools-2.0.17.tar.xz index 0690f64..821683b 100644 --- a/kexec-tools-2.0.17.tar.xz +++ b/kexec-tools-2.0.17.tar.xz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:504c816b769da573167b63f3b6d4fce3740f231c98d8db0c4fda47a4b90482a9 -size 290612 +oid sha256:44bb637f7094ca1e175ac1c101cbc10b813500908f03004f13a3d8eb9ee0d336 +size 370820 diff --git a/kexec-tools.spec b/kexec-tools.spec index 833d8c7..c93e110 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -22,7 +22,7 @@ Release: 0 Summary: Tools for loading replacement kernels into memory License: GPL-2.0+ Group: System/Kernel -Url: https://kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz +Url: https://www.kernel.org/pub/linux/utils/kernel/kexec/%{name}-%{version}.tar.xz Source: https://git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git/snapshot/%{name}-%{version}.tar.xz Source1: kexec-bootloader Source2: kexec-bootloader.8