From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: [for-next][PATCH 05/12] init/bootconfig: Reorder init parameter from bootconfig and cmdline
Date: Wed, 08 Sep 2021 15:18:56 -0400 [thread overview]
Message-ID: <20210908191954.051463779@goodmis.org> (raw)
In-Reply-To: <20210908191851.381347939@goodmis.org>
From: Masami Hiramatsu <mhiramat@kernel.org>
Reorder the init parameters from bootconfig and kernel cmdline
so that the kernel cmdline always be the last part of the
parameters as below.
" -- "[bootconfig init params][cmdline init params]
This change will help us to prevent that bootconfig init params
overwrite the init params which user gives in the command line.
Link: https://lkml.kernel.org/r/163077085675.222577.5665176468023636160.stgit@devnote2
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
init/main.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/init/main.c b/init/main.c
index d35c4a865adb..d08caed17c7f 100644
--- a/init/main.c
+++ b/init/main.c
@@ -153,10 +153,10 @@ static char *extra_init_args;
#ifdef CONFIG_BOOT_CONFIG
/* Is bootconfig on command line? */
static bool bootconfig_found;
-static bool initargs_found;
+static size_t initargs_offs;
#else
# define bootconfig_found false
-# define initargs_found false
+# define initargs_offs 0
#endif
static char *execute_command;
@@ -422,9 +422,9 @@ static void __init setup_boot_config(void)
if (IS_ERR(err) || !bootconfig_found)
return;
- /* parse_args() stops at '--' and returns an address */
+ /* parse_args() stops at the next param of '--' and returns an address */
if (err)
- initargs_found = true;
+ initargs_offs = err - tmp_cmdline;
if (!data) {
pr_err("'bootconfig' found on command line, but no bootconfig found\n");
@@ -655,16 +655,21 @@ static void __init setup_command_line(char *command_line)
* Append supplemental init boot args to saved_command_line
* so that user can check what command line options passed
* to init.
+ * The order should always be
+ * " -- "[bootconfig init-param][cmdline init-param]
*/
- len = strlen(saved_command_line);
- if (initargs_found) {
- saved_command_line[len++] = ' ';
+ if (initargs_offs) {
+ len = xlen + initargs_offs;
+ strcpy(saved_command_line + len, extra_init_args);
+ len += ilen - 4; /* strlen(extra_init_args) */
+ strcpy(saved_command_line + len,
+ boot_command_line + initargs_offs - 1);
} else {
+ len = strlen(saved_command_line);
strcpy(saved_command_line + len, " -- ");
len += 4;
+ strcpy(saved_command_line + len, extra_init_args);
}
-
- strcpy(saved_command_line + len, extra_init_args);
}
}
--
2.32.0
next prev parent reply other threads:[~2021-09-08 19:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-08 19:18 [for-next][PATCH 00/12] tracing: More updates for 5.15 Steven Rostedt
2021-09-08 19:18 ` [for-next][PATCH 01/12] tracing: Add migrate-disabled counter to tracing output Steven Rostedt
2021-09-08 19:18 ` [for-next][PATCH 02/12] tracing: Fix some alloc_event_probe() error handling bugs Steven Rostedt
2021-09-08 19:18 ` [for-next][PATCH 03/12] tracing/osnoise: Fix missed cpus_read_unlock() in start_per_cpu_kthreads() Steven Rostedt
2021-09-08 19:18 ` [for-next][PATCH 04/12] init: bootconfig: Remove all bootconfig data when the init memory is removed Steven Rostedt
2021-09-08 19:18 ` Steven Rostedt [this message]
2021-09-08 19:18 ` [for-next][PATCH 06/12] docs: bootconfig: Add how to use bootconfig for kernel parameters Steven Rostedt
2021-09-08 19:18 ` [for-next][PATCH 07/12] tools/bootconfig: Fix tracing_on option checking in ftrace2bconf.sh Steven Rostedt
2021-09-08 19:18 ` [for-next][PATCH 08/12] bootconfig: Fix missing return check of xbc_node_compose_key function Steven Rostedt
2021-09-08 19:28 ` Steven Rostedt
2021-09-08 19:19 ` [for-next][PATCH 09/12] tools/bootconfig: Show whole test command for each test case Steven Rostedt
2021-09-08 19:19 ` [for-next][PATCH 10/12] tracing: synth events: increase max fields count Steven Rostedt
2021-09-08 19:19 ` [for-next][PATCH 11/12] tracing: Dynamically allocate the per-elt hist_elt_data array Steven Rostedt
2021-09-08 19:19 ` [for-next][PATCH 12/12] selftests/ftrace: Exclude "(fault)" in testing add/remove eprobe events Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210908191954.051463779@goodmis.org \
--to=rostedt@goodmis.org \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®