Accepting request 593211 from home:michals

- kexec: add -a option to fall back to KEXEC_LOAD when KEXEC_FILE_LOAD is not
  supported (bsc#1080916, boo#1076839).
  * kexec-Return-ENOSYS-when-kexec-does-not-know-how-to-.patch
  * kexec-Fix-option-checks-to-take-KEXEC_FILE_LOAD-into.patch
  * kexec-Do-not-special-case-the-s-option.patch
  * kexec-Add-option-to-revert-s.patch
  * kexec-Add-option-to-fall-back-to-KEXEC_LOAD-when-KEX.patch
  * kexec-Document-s-c-and-a-options-in-the-man-page.patch
- kexec/ppc64: leverage kexec_file_load support (bsc#1080916)
  * kexec-ppc64-leverage-kexec_file_load-support.patch

Patches accepted upstream.

OBS-URL: https://build.opensuse.org/request/show/593211
OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=95
This commit is contained in:
Petr Tesařík 2018-04-05 06:58:41 +00:00 committed by Git OBS Bridge
parent 13bc6e358c
commit f3fb4b072a
9 changed files with 629 additions and 0 deletions

View File

@ -0,0 +1,173 @@
From 9fa99c42cb911727a962b358c5b1d36d0fe338ab Mon Sep 17 00:00:00 2001
Message-Id: <9fa99c42cb911727a962b358c5b1d36d0fe338ab.1522755494.git.msuchanek@suse.de>
In-Reply-To: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
References: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
From: Michal Suchanek <msuchanek@suse.de>
Date: Mon, 26 Feb 2018 12:24:44 +0100
Subject: [PATCH v6 5/6] kexec: Add option to fall back to KEXEC_LOAD when
KEXEC_FILE_LOAD is not supported
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

View File

@ -0,0 +1,71 @@
From a8639a304b7b62384fc1c747c35eee7728ce583f Mon Sep 17 00:00:00 2001
Message-Id: <a8639a304b7b62384fc1c747c35eee7728ce583f.1522755494.git.msuchanek@suse.de>
In-Reply-To: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
References: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
From: Michal Suchanek <msuchanek@suse.de>
Date: Mon, 26 Feb 2018 12:24:44 +0100
Subject: [PATCH v6 4/6] kexec: Add option to revert -s
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

View File

@ -0,0 +1,77 @@
From 1ce7ef9717b1e1a721a1012d1de1ed2b4eae9485 Mon Sep 17 00:00:00 2001
Message-Id: <1ce7ef9717b1e1a721a1012d1de1ed2b4eae9485.1522755494.git.msuchanek@suse.de>
In-Reply-To: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
References: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
From: Michal Suchanek <msuchanek@suse.de>
Date: Mon, 26 Feb 2018 12:17:01 +0100
Subject: [PATCH v6 3/6] kexec: Do not special-case the -s option
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

View File

@ -0,0 +1,51 @@
From 1ded8729a29ff36880fc5169e93361971f4cab35 Mon Sep 17 00:00:00 2001
Message-Id: <1ded8729a29ff36880fc5169e93361971f4cab35.1522755494.git.msuchanek@suse.de>
In-Reply-To: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
References: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
From: Michal Suchanek <msuchanek@suse.de>
Date: Mon, 26 Feb 2018 12:51:21 +0100
Subject: [PATCH v6 6/6] kexec: Document -s, -c and -a options in the man page
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

View File

@ -0,0 +1,53 @@
From bf36a4623b5ef67b3ae9722972fc135c608df963 Mon Sep 17 00:00:00 2001
Message-Id: <bf36a4623b5ef67b3ae9722972fc135c608df963.1522755494.git.msuchanek@suse.de>
In-Reply-To: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
References: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
From: Michal Suchanek <msuchanek@suse.de>
Date: Fri, 16 Mar 2018 16:40:27 +0100
Subject: [PATCH v6 2/6] kexec: Fix option checks to take KEXEC_FILE_LOAD into
account
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

View File

@ -0,0 +1,32 @@
From e810acd57d9fc2d7ba3b0e95d470c20de9948462 Mon Sep 17 00:00:00 2001
Message-Id: <e810acd57d9fc2d7ba3b0e95d470c20de9948462.1522755494.git.msuchanek@suse.de>
From: Michal Suchanek <msuchanek@suse.de>
Date: Mon, 26 Feb 2018 12:12:38 +0100
Subject: [PATCH v6 1/6] kexec: Return -ENOSYS when kexec does not know how to
call KEXEC_FILE_LOAD
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

View File

@ -0,0 +1,144 @@
From 3720b743ae3ced0407e811a4223228d305dc4705 Mon Sep 17 00:00:00 2001
From: Hari Bathini <hbathini@linux.vnet.ibm.com>
Date: Mon, 26 Mar 2018 14:16:34 +0530
Subject: [PATCH] kexec/ppc64: leverage kexec_file_load support
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

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
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-Return-ENOSYS-when-kexec-does-not-know-how-to-.patch
* kexec-Fix-option-checks-to-take-KEXEC_FILE_LOAD-into.patch
* kexec-Do-not-special-case-the-s-option.patch
* kexec-Add-option-to-revert-s.patch
* kexec-Add-option-to-fall-back-to-KEXEC_LOAD-when-KEX.patch
* kexec-Document-s-c-and-a-options-in-the-man-page.patch
- kexec/ppc64: leverage kexec_file_load support (bsc#1080916)
* kexec-ppc64-leverage-kexec_file_load-support.patch
-------------------------------------------------------------------
Fri Feb 23 07:38:55 UTC 2018 - ptesarik@suse.com

View File

@ -33,6 +33,13 @@ 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: kexec-ppc64-leverage-kexec_file_load-support.patch
Patch7: kexec-Return-ENOSYS-when-kexec-does-not-know-how-to-.patch
Patch8: kexec-Fix-option-checks-to-take-KEXEC_FILE_LOAD-into.patch
Patch9: kexec-Do-not-special-case-the-s-option.patch
Patch10: kexec-Add-option-to-revert-s.patch
Patch11: kexec-Add-option-to-fall-back-to-KEXEC_LOAD-when-KEX.patch
Patch12: kexec-Document-s-c-and-a-options-in-the-man-page.patch
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: systemd-rpm-macros
@ -61,6 +68,13 @@ 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
%build
autoreconf -fvi