|
|
f69881 |
From e63fefd4fc355f29d839ca47484b0f8070e38ccb Mon Sep 17 00:00:00 2001
|
|
|
f69881 |
From: Sourabh Jain <sourabhjain@linux.ibm.com>
|
|
|
f69881 |
Date: Wed, 1 Feb 2023 14:23:31 +0530
|
|
|
f69881 |
Subject: [PATCH 1/6] ppc64: add --reuse-cmdline parameter support
|
|
|
f69881 |
|
|
|
f69881 |
An option to copy the command line arguments from running kernel
|
|
|
f69881 |
to kexec'd kernel. This option works for both kexec and kdump.
|
|
|
f69881 |
|
|
|
f69881 |
In case --append=<args> or --command-line=<args> is provided along
|
|
|
f69881 |
with --reuse-cmdline parameter then args listed against append and
|
|
|
f69881 |
command-line parameter will be combined with command line argument
|
|
|
f69881 |
from running kernel.
|
|
|
f69881 |
|
|
|
f69881 |
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
|
|
|
f69881 |
Signed-off-by: Simon Horman <horms@kernel.org>
|
|
|
f69881 |
---
|
|
|
f69881 |
kexec/arch/ppc64/include/arch/options.h | 4 +++-
|
|
|
f69881 |
kexec/arch/ppc64/kexec-elf-ppc64.c | 25 +++++++++++++++++++++++--
|
|
|
f69881 |
2 files changed, 26 insertions(+), 3 deletions(-)
|
|
|
f69881 |
|
|
|
f69881 |
diff --git a/kexec/arch/ppc64/include/arch/options.h b/kexec/arch/ppc64/include/arch/options.h
|
|
|
f69881 |
index 71632ec..2bca96a 100644
|
|
|
f69881 |
--- a/kexec/arch/ppc64/include/arch/options.h
|
|
|
f69881 |
+++ b/kexec/arch/ppc64/include/arch/options.h
|
|
|
f69881 |
@@ -10,6 +10,7 @@
|
|
|
f69881 |
#define OPT_RAMDISK (OPT_ARCH_MAX+1)
|
|
|
f69881 |
#define OPT_DEVICETREEBLOB (OPT_ARCH_MAX+2)
|
|
|
f69881 |
#define OPT_ARGS_IGNORE (OPT_ARCH_MAX+3)
|
|
|
f69881 |
+#define OPT_REUSE_CMDLINE (OPT_ARCH_MAX+4)
|
|
|
f69881 |
|
|
|
f69881 |
/* Options relevant to the architecture (excluding loader-specific ones): */
|
|
|
f69881 |
#define KEXEC_ARCH_OPTIONS \
|
|
|
f69881 |
@@ -41,7 +42,8 @@
|
|
|
f69881 |
{ "initrd", 1, NULL, OPT_RAMDISK }, \
|
|
|
f69881 |
{ "devicetreeblob", 1, NULL, OPT_DEVICETREEBLOB }, \
|
|
|
f69881 |
{ "dtb", 1, NULL, OPT_DEVICETREEBLOB }, \
|
|
|
f69881 |
- { "args-linux", 0, NULL, OPT_ARGS_IGNORE },
|
|
|
f69881 |
+ { "args-linux", 0, NULL, OPT_ARGS_IGNORE }, \
|
|
|
f69881 |
+ { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE },
|
|
|
f69881 |
|
|
|
f69881 |
#define KEXEC_ALL_OPT_STR KEXEC_OPT_STR
|
|
|
f69881 |
|
|
|
f69881 |
diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
|
|
|
f69881 |
index 695b8b0..01d045f 100644
|
|
|
f69881 |
--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
|
|
|
f69881 |
+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
|
|
|
f69881 |
@@ -95,6 +95,8 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
|
|
|
f69881 |
{
|
|
|
f69881 |
int ret = 0;
|
|
|
f69881 |
char *cmdline, *dtb;
|
|
|
f69881 |
+ char *append_cmdline = NULL;
|
|
|
f69881 |
+ char *reuse_cmdline = NULL;
|
|
|
f69881 |
int opt, cmdline_len = 0;
|
|
|
f69881 |
|
|
|
f69881 |
/* See options.h -- add any more there, too. */
|
|
|
f69881 |
@@ -107,6 +109,7 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
|
|
|
f69881 |
{ "devicetreeblob", 1, NULL, OPT_DEVICETREEBLOB },
|
|
|
f69881 |
{ "dtb", 1, NULL, OPT_DEVICETREEBLOB },
|
|
|
f69881 |
{ "args-linux", 0, NULL, OPT_ARGS_IGNORE },
|
|
|
f69881 |
+ { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE},
|
|
|
f69881 |
{ 0, 0, NULL, 0 },
|
|
|
f69881 |
};
|
|
|
f69881 |
|
|
|
f69881 |
@@ -125,7 +128,7 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
|
|
|
f69881 |
if (opt < OPT_ARCH_MAX)
|
|
|
f69881 |
break;
|
|
|
f69881 |
case OPT_APPEND:
|
|
|
f69881 |
- cmdline = optarg;
|
|
|
f69881 |
+ append_cmdline = optarg;
|
|
|
f69881 |
break;
|
|
|
f69881 |
case OPT_RAMDISK:
|
|
|
f69881 |
ramdisk = optarg;
|
|
|
f69881 |
@@ -135,6 +138,9 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
|
|
|
f69881 |
break;
|
|
|
f69881 |
case OPT_ARGS_IGNORE:
|
|
|
f69881 |
break;
|
|
|
f69881 |
+ case OPT_REUSE_CMDLINE:
|
|
|
f69881 |
+ reuse_cmdline = get_command_line();
|
|
|
f69881 |
+ break;
|
|
|
f69881 |
}
|
|
|
f69881 |
}
|
|
|
f69881 |
|
|
|
f69881 |
@@ -144,6 +150,10 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
|
|
|
f69881 |
if (reuse_initrd)
|
|
|
f69881 |
die("--reuseinitrd not supported with --kexec-file-syscall.\n");
|
|
|
f69881 |
|
|
|
f69881 |
+ cmdline = concat_cmdline(reuse_cmdline, append_cmdline);
|
|
|
f69881 |
+ if (!reuse_cmdline)
|
|
|
f69881 |
+ free(reuse_cmdline);
|
|
|
f69881 |
+
|
|
|
f69881 |
if (cmdline) {
|
|
|
f69881 |
cmdline_len = strlen(cmdline) + 1;
|
|
|
f69881 |
} else {
|
|
|
f69881 |
@@ -175,6 +185,8 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
|
|
|
f69881 |
{
|
|
|
f69881 |
struct mem_ehdr ehdr;
|
|
|
f69881 |
char *cmdline, *modified_cmdline = NULL;
|
|
|
f69881 |
+ char *reuse_cmdline = NULL;
|
|
|
f69881 |
+ char *append_cmdline = NULL;
|
|
|
f69881 |
const char *devicetreeblob;
|
|
|
f69881 |
uint64_t max_addr, hole_addr;
|
|
|
f69881 |
char *seg_buf = NULL;
|
|
|
f69881 |
@@ -204,6 +216,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
|
|
|
f69881 |
{ "devicetreeblob", 1, NULL, OPT_DEVICETREEBLOB },
|
|
|
f69881 |
{ "dtb", 1, NULL, OPT_DEVICETREEBLOB },
|
|
|
f69881 |
{ "args-linux", 0, NULL, OPT_ARGS_IGNORE },
|
|
|
f69881 |
+ { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE},
|
|
|
f69881 |
{ 0, 0, NULL, 0 },
|
|
|
f69881 |
};
|
|
|
f69881 |
|
|
|
f69881 |
@@ -229,7 +242,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
|
|
|
f69881 |
if (opt < OPT_ARCH_MAX)
|
|
|
f69881 |
break;
|
|
|
f69881 |
case OPT_APPEND:
|
|
|
f69881 |
- cmdline = optarg;
|
|
|
f69881 |
+ append_cmdline = optarg;
|
|
|
f69881 |
break;
|
|
|
f69881 |
case OPT_RAMDISK:
|
|
|
f69881 |
ramdisk = optarg;
|
|
|
f69881 |
@@ -239,9 +252,16 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
|
|
|
f69881 |
break;
|
|
|
f69881 |
case OPT_ARGS_IGNORE:
|
|
|
f69881 |
break;
|
|
|
f69881 |
+ case OPT_REUSE_CMDLINE:
|
|
|
f69881 |
+ reuse_cmdline = get_command_line();
|
|
|
f69881 |
+ break;
|
|
|
f69881 |
}
|
|
|
f69881 |
}
|
|
|
f69881 |
|
|
|
f69881 |
+ cmdline = concat_cmdline(reuse_cmdline, append_cmdline);
|
|
|
f69881 |
+ if (!reuse_cmdline)
|
|
|
f69881 |
+ free(reuse_cmdline);
|
|
|
f69881 |
+
|
|
|
f69881 |
if (!cmdline)
|
|
|
f69881 |
fprintf(stdout, "Warning: append= option is not passed. Using the first kernel root partition\n");
|
|
|
f69881 |
|
|
|
f69881 |
@@ -469,6 +489,7 @@ void elf_ppc64_usage(void)
|
|
|
f69881 |
fprintf(stderr, " --devicetreeblob=<filename> Specify device tree blob file.\n");
|
|
|
f69881 |
fprintf(stderr, " ");
|
|
|
f69881 |
fprintf(stderr, "Not applicable while using --kexec-file-syscall.\n");
|
|
|
f69881 |
+ fprintf(stderr, " --reuse-cmdline Use kernel command line from running system.\n");
|
|
|
f69881 |
fprintf(stderr, " --dtb=<filename> same as --devicetreeblob.\n");
|
|
|
f69881 |
|
|
|
f69881 |
fprintf(stderr, "elf support is still broken\n");
|
|
|
f69881 |
--
|
|
|
f69881 |
2.33.1
|
|
|
f69881 |
|