* [PATCH] ppc64: add --reuse-cmdline parameter support
@ 2023-02-01 8:53 Sourabh Jain
2023-02-07 15:07 ` Simon Horman
0 siblings, 1 reply; 3+ messages in thread
From: Sourabh Jain @ 2023-02-01 8:53 UTC (permalink / raw)
To: kexec; +Cc: horms, Sourabh Jain, hbathini
An option to copy the command line arguments from running kernel
to kexec'd kernel. This option works for both kexec and kdump.
In case --append=<args> or --command-line=<args> is provided along
with --reuse-cmdline parameter then args listed against append and
command-line parameter will be combined with command line argument
from running kernel.
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
kexec/arch/ppc64/include/arch/options.h | 4 +++-
kexec/arch/ppc64/kexec-elf-ppc64.c | 25 +++++++++++++++++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/kexec/arch/ppc64/include/arch/options.h b/kexec/arch/ppc64/include/arch/options.h
index 71632ec..2bca96a 100644
--- a/kexec/arch/ppc64/include/arch/options.h
+++ b/kexec/arch/ppc64/include/arch/options.h
@@ -10,6 +10,7 @@
#define OPT_RAMDISK (OPT_ARCH_MAX+1)
#define OPT_DEVICETREEBLOB (OPT_ARCH_MAX+2)
#define OPT_ARGS_IGNORE (OPT_ARCH_MAX+3)
+#define OPT_REUSE_CMDLINE (OPT_ARCH_MAX+4)
/* Options relevant to the architecture (excluding loader-specific ones): */
#define KEXEC_ARCH_OPTIONS \
@@ -41,7 +42,8 @@
{ "initrd", 1, NULL, OPT_RAMDISK }, \
{ "devicetreeblob", 1, NULL, OPT_DEVICETREEBLOB }, \
{ "dtb", 1, NULL, OPT_DEVICETREEBLOB }, \
- { "args-linux", 0, NULL, OPT_ARGS_IGNORE },
+ { "args-linux", 0, NULL, OPT_ARGS_IGNORE }, \
+ { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE },
#define KEXEC_ALL_OPT_STR KEXEC_OPT_STR
diff --git a/kexec/arch/ppc64/kexec-elf-ppc64.c b/kexec/arch/ppc64/kexec-elf-ppc64.c
index 695b8b0..01d045f 100644
--- a/kexec/arch/ppc64/kexec-elf-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-ppc64.c
@@ -95,6 +95,8 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
{
int ret = 0;
char *cmdline, *dtb;
+ char *append_cmdline = NULL;
+ char *reuse_cmdline = NULL;
int opt, cmdline_len = 0;
/* See options.h -- add any more there, too. */
@@ -107,6 +109,7 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
{ "devicetreeblob", 1, NULL, OPT_DEVICETREEBLOB },
{ "dtb", 1, NULL, OPT_DEVICETREEBLOB },
{ "args-linux", 0, NULL, OPT_ARGS_IGNORE },
+ { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE},
{ 0, 0, NULL, 0 },
};
@@ -125,7 +128,7 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
if (opt < OPT_ARCH_MAX)
break;
case OPT_APPEND:
- cmdline = optarg;
+ append_cmdline = optarg;
break;
case OPT_RAMDISK:
ramdisk = optarg;
@@ -135,6 +138,9 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
break;
case OPT_ARGS_IGNORE:
break;
+ case OPT_REUSE_CMDLINE:
+ reuse_cmdline = get_command_line();
+ break;
}
}
@@ -144,6 +150,10 @@ static int elf_ppc64_load_file(int argc, char **argv, struct kexec_info *info)
if (reuse_initrd)
die("--reuseinitrd not supported with --kexec-file-syscall.\n");
+ cmdline = concat_cmdline(reuse_cmdline, append_cmdline);
+ if (!reuse_cmdline)
+ free(reuse_cmdline);
+
if (cmdline) {
cmdline_len = strlen(cmdline) + 1;
} else {
@@ -175,6 +185,8 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
{
struct mem_ehdr ehdr;
char *cmdline, *modified_cmdline = NULL;
+ char *reuse_cmdline = NULL;
+ char *append_cmdline = NULL;
const char *devicetreeblob;
uint64_t max_addr, hole_addr;
char *seg_buf = NULL;
@@ -204,6 +216,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
{ "devicetreeblob", 1, NULL, OPT_DEVICETREEBLOB },
{ "dtb", 1, NULL, OPT_DEVICETREEBLOB },
{ "args-linux", 0, NULL, OPT_ARGS_IGNORE },
+ { "reuse-cmdline", 0, NULL, OPT_REUSE_CMDLINE},
{ 0, 0, NULL, 0 },
};
@@ -229,7 +242,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
if (opt < OPT_ARCH_MAX)
break;
case OPT_APPEND:
- cmdline = optarg;
+ append_cmdline = optarg;
break;
case OPT_RAMDISK:
ramdisk = optarg;
@@ -239,9 +252,16 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,
break;
case OPT_ARGS_IGNORE:
break;
+ case OPT_REUSE_CMDLINE:
+ reuse_cmdline = get_command_line();
+ break;
}
}
+ cmdline = concat_cmdline(reuse_cmdline, append_cmdline);
+ if (!reuse_cmdline)
+ free(reuse_cmdline);
+
if (!cmdline)
fprintf(stdout, "Warning: append= option is not passed. Using the first kernel root partition\n");
@@ -469,6 +489,7 @@ void elf_ppc64_usage(void)
fprintf(stderr, " --devicetreeblob=<filename> Specify device tree blob file.\n");
fprintf(stderr, " ");
fprintf(stderr, "Not applicable while using --kexec-file-syscall.\n");
+ fprintf(stderr, " --reuse-cmdline Use kernel command line from running system.\n");
fprintf(stderr, " --dtb=<filename> same as --devicetreeblob.\n");
fprintf(stderr, "elf support is still broken\n");
--
2.39.1
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ppc64: add --reuse-cmdline parameter support
2023-02-01 8:53 [PATCH] ppc64: add --reuse-cmdline parameter support Sourabh Jain
@ 2023-02-07 15:07 ` Simon Horman
2023-02-08 6:31 ` Sourabh Jain
0 siblings, 1 reply; 3+ messages in thread
From: Simon Horman @ 2023-02-07 15:07 UTC (permalink / raw)
To: Sourabh Jain; +Cc: kexec, hbathini
On Wed, Feb 01, 2023 at 02:23:31PM +0530, Sourabh Jain wrote:
> An option to copy the command line arguments from running kernel
> to kexec'd kernel. This option works for both kexec and kdump.
>
> In case --append=<args> or --command-line=<args> is provided along
> with --reuse-cmdline parameter then args listed against append and
> command-line parameter will be combined with command line argument
> from running kernel.
>
> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Thanks, applied.
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ppc64: add --reuse-cmdline parameter support
2023-02-07 15:07 ` Simon Horman
@ 2023-02-08 6:31 ` Sourabh Jain
0 siblings, 0 replies; 3+ messages in thread
From: Sourabh Jain @ 2023-02-08 6:31 UTC (permalink / raw)
To: Simon Horman; +Cc: kexec, hbathini
On 07/02/23 20:37, Simon Horman wrote:
> On Wed, Feb 01, 2023 at 02:23:31PM +0530, Sourabh Jain wrote:
>> An option to copy the command line arguments from running kernel
>> to kexec'd kernel. This option works for both kexec and kdump.
>>
>> In case --append=<args> or --command-line=<args> is provided along
>> with --reuse-cmdline parameter then args listed against append and
>> command-line parameter will be combined with command line argument
>> from running kernel.
>>
>> Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Thanks for accepting the patch.
- Sourabh Jain
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-08 6:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-01 8:53 [PATCH] ppc64: add --reuse-cmdline parameter support Sourabh Jain
2023-02-07 15:07 ` Simon Horman
2023-02-08 6:31 ` Sourabh Jain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox