Accepting request 593775 from Kernel:kdump
OBS-URL: https://build.opensuse.org/request/show/593775 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/kexec-tools?expand=0&rev=125
This commit is contained in:
commit
e428b14de9
172
kexec-tools-Add-option-to-fall-back-to-KEXEC_LOAD.patch
Normal file
172
kexec-tools-Add-option-to-fall-back-to-KEXEC_LOAD.patch
Normal file
@ -0,0 +1,172 @@
|
||||
From: Michal Suchanek <msuchanek@suse.de>
|
||||
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 <msuchanek@suse.de>
|
||||
---
|
||||
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
|
||||
|
70
kexec-tools-Add-option-to-revert-s.patch
Normal file
70
kexec-tools-Add-option-to-revert-s.patch
Normal file
@ -0,0 +1,70 @@
|
||||
From: Michal Suchanek <msuchanek@suse.de>
|
||||
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 <msuchanek@suse.de>
|
||||
---
|
||||
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
|
||||
|
76
kexec-tools-Do-not-special-case-the-s-option.patch
Normal file
76
kexec-tools-Do-not-special-case-the-s-option.patch
Normal file
@ -0,0 +1,76 @@
|
||||
From: Michal Suchanek <msuchanek@suse.de>
|
||||
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 <msuchanek@suse.de>
|
||||
---
|
||||
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
|
||||
|
50
kexec-tools-Document-s-c-and-a-options-in-the-man-page.patch
Normal file
50
kexec-tools-Document-s-c-and-a-options-in-the-man-page.patch
Normal file
@ -0,0 +1,50 @@
|
||||
From: Michal Suchanek <msuchanek@suse.de>
|
||||
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 <msuchanek@suse.de>
|
||||
---
|
||||
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
|
||||
|
51
kexec-tools-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch
Normal file
51
kexec-tools-Fix-option-checks-to-take-KEXEC_FILE_LOAD.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From: Michal Suchanek <msuchanek@suse.de>
|
||||
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 <msuchanek@suse.de>
|
||||
---
|
||||
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
|
||||
|
32
kexec-tools-Return-ENOSYS-when-kexec-does-not-know.patch
Normal file
32
kexec-tools-Return-ENOSYS-when-kexec-does-not-know.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From: Michal Suchanek <msuchanek@suse.de>
|
||||
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 <msuchanek@suse.de>
|
||||
---
|
||||
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
|
||||
|
25
kexec-tools-fix-kexec-p-segfault.patch
Normal file
25
kexec-tools-fix-kexec-p-segfault.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From: Petr Tesarik <petr@tesarici.cz>
|
||||
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 <petr@tesarici.cz>
|
||||
---
|
||||
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) {
|
146
kexec-tools-ppc64-leverage-kexec_file_load-support.patch
Normal file
146
kexec-tools-ppc64-leverage-kexec_file_load-support.patch
Normal file
@ -0,0 +1,146 @@
|
||||
From: Hari Bathini <hbathini@linux.vnet.ibm.com>
|
||||
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 <hbathini@linux.vnet.ibm.com>
|
||||
Reviewed-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
|
||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
||||
---
|
||||
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=<filename> Initial RAM disk.\n");
|
||||
fprintf(stderr, " --initrd=<filename> same as --ramdisk.\n");
|
||||
fprintf(stderr, " --devicetreeblob=<filename> Specify device tree blob file.\n");
|
||||
+ fprintf(stderr, " ");
|
||||
+ fprintf(stderr, "Not applicable while using --kexec-file-syscall.\n");
|
||||
fprintf(stderr, " --dtb=<filename> 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
|
||||
|
79
kexec-tools-vmcoreinfo-in-xen.patch
Normal file
79
kexec-tools-vmcoreinfo-in-xen.patch
Normal file
@ -0,0 +1,79 @@
|
||||
From: Petr Tesarik <petr@tesarici.cz>
|
||||
Date: Thu, 5 Apr 2018 10:57:05 +0200
|
||||
Subject: Revert "kexec-tools: Read always one vmcoreinfo file"
|
||||
References: bsc#1085626, bsc#951740
|
||||
Upstream: not yet, upstream wants to stay broken
|
||||
|
||||
This reverts commit 455d79f57e9367e5c59093fd74798905bd5762fc.
|
||||
|
||||
The explanation seems bogus. The file under /sys/kernel
|
||||
refers to the Linux kernel VMCOREINFO note, while the
|
||||
file under /sys/hypervisor refers to the Xen hypervisor
|
||||
VMCOREINFO_XEN note. The former note contains information
|
||||
about the Linux kernel. The latter contains information
|
||||
about the Xen hypervisor. Both are needed to allow page
|
||||
filtering in makedumpfile.
|
||||
|
||||
Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
|
||||
|
||||
---
|
||||
kexec/crashdump-elf.c | 33 ++++++++++++++++++++++++++-------
|
||||
1 file changed, 26 insertions(+), 7 deletions(-)
|
||||
|
||||
--- a/kexec/crashdump-elf.c
|
||||
+++ b/kexec/crashdump-elf.c
|
||||
@@ -40,6 +40,8 @@ int FUNC(struct kexec_info *info,
|
||||
uint64_t notes_addr, notes_len;
|
||||
uint64_t vmcoreinfo_addr, vmcoreinfo_len;
|
||||
int has_vmcoreinfo = 0;
|
||||
+ uint64_t vmcoreinfo_addr_xen, vmcoreinfo_len_xen;
|
||||
+ int has_vmcoreinfo_xen = 0;
|
||||
int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len);
|
||||
long int count_cpu;
|
||||
|
||||
@@ -52,14 +54,16 @@ int FUNC(struct kexec_info *info,
|
||||
return -1;
|
||||
}
|
||||
|
||||
- if (xen_present()) {
|
||||
- if (!get_xen_vmcoreinfo(&vmcoreinfo_addr, &vmcoreinfo_len))
|
||||
- has_vmcoreinfo = 1;
|
||||
- } else
|
||||
- if (!get_kernel_vmcoreinfo(&vmcoreinfo_addr, &vmcoreinfo_len))
|
||||
- has_vmcoreinfo = 1;
|
||||
+ if (get_kernel_vmcoreinfo(&vmcoreinfo_addr, &vmcoreinfo_len) == 0) {
|
||||
+ has_vmcoreinfo = 1;
|
||||
+ }
|
||||
+
|
||||
+ if (xen_present() &&
|
||||
+ get_xen_vmcoreinfo(&vmcoreinfo_addr_xen, &vmcoreinfo_len_xen) == 0) {
|
||||
+ has_vmcoreinfo_xen = 1;
|
||||
+ }
|
||||
|
||||
- sz = sizeof(EHDR) + (nr_cpus + has_vmcoreinfo) * sizeof(PHDR) +
|
||||
+ sz = sizeof(EHDR) + (nr_cpus + has_vmcoreinfo + has_vmcoreinfo_xen) * sizeof(PHDR) +
|
||||
ranges * sizeof(PHDR);
|
||||
|
||||
/*
|
||||
@@ -178,6 +182,21 @@ int FUNC(struct kexec_info *info,
|
||||
dbgprintf_phdr("vmcoreinfo header", phdr);
|
||||
}
|
||||
|
||||
+ if (has_vmcoreinfo_xen) {
|
||||
+ phdr = (PHDR *) bufp;
|
||||
+ bufp += sizeof(PHDR);
|
||||
+ phdr->p_type = PT_NOTE;
|
||||
+ phdr->p_flags = 0;
|
||||
+ phdr->p_offset = phdr->p_paddr = vmcoreinfo_addr_xen;
|
||||
+ phdr->p_vaddr = 0;
|
||||
+ phdr->p_filesz = phdr->p_memsz = vmcoreinfo_len_xen;
|
||||
+ /* Do we need any alignment of segments? */
|
||||
+ phdr->p_align = 0;
|
||||
+
|
||||
+ (elf->e_phnum)++;
|
||||
+ dbgprintf_phdr("vmcoreinfo_xen header", phdr);
|
||||
+ }
|
||||
+
|
||||
/* Setup an PT_LOAD type program header for the region where
|
||||
* Kernel is mapped if elf_info->kern_size is non-zero.
|
||||
*/
|
@ -1,3 +1,29 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Apr 5 11:12:53 UTC 2018 - ptesarik@suse.com
|
||||
|
||||
- kexec-tools-vmcoreinfo-in-xen.patch: Revert "kexec-tools: Read
|
||||
always one vmcoreinfo file" (bsc#1085626, bsc#951740).
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Apr 5 09:05:11 UTC 2018 - ptesarik@suse.com
|
||||
|
||||
- kexec-tools-fix-kexec-p-segfault.patch: Fix a segmentation fault
|
||||
when trying to run "kexec -p" (bsc#1080916).
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Apr 3 11:43:18 UTC 2018 - msuchanek@suse.com
|
||||
|
||||
- kexec: add -a option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not
|
||||
supported (bsc#1080916, boo#1076839).
|
||||
* 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-ppc64-leverage-kexec_file_load-support.patch: kexec/ppc64:
|
||||
leverage kexec_file_load support (bsc#1080916).
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Feb 23 07:38:55 UTC 2018 - ptesarik@suse.com
|
||||
|
||||
|
@ -33,6 +33,15 @@ 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
|
||||
BuildRequires: systemd-rpm-macros
|
||||
@ -61,6 +70,15 @@ the loaded kernel after it panics.
|
||||
%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
|
||||
autoreconf -fvi
|
||||
|
Loading…
Reference in New Issue
Block a user