From: Evgeniy Baskov <baskov@ispras.ru>
To: Borislav Petkov <bp@alien8.de>
Cc: Evgeniy Baskov <baskov@ispras.ru>,
Dave Hansen <dave.hansen@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org, x86@kernel.org,
Alexey Khoroshilov <khoroshilov@ispras.ru>
Subject: [PATCH v6 4/5] x86/boot: Use cmdline_prapare() in compressed kernel
Date: Sat, 27 Aug 2022 05:08:09 +0300 [thread overview]
Message-ID: <6d220213ad1a90bf905f2ea324dcc8a3db5707ca.1661565218.git.baskov@ispras.ru> (raw)
In-Reply-To: <cover.1661565218.git.baskov@ispras.ru>
CONFIG_CMDLINE_BOOL and CONFIG_CMDLINE_OVERRIDE were ignored during
options lookup in compressed kernel, including earlyprintk option,
so it was impossible to get earlyprintk messages from that stage
of boot process via command line provided at compile time.
Being able to enable earlyprintk via compile-time option might
be desirable for booting on systems with broken UEFI command line
arguments via EFISTUB.
Use a common helper function to handle CONFIG_CMDLINE_* in compressed
kernel.
Place command_line_init explicitly in '.data' section since it is
used before '.bss' section is zeroed and it is expected to be equal
to zero.
Signed-off-by: Evgeniy Baskov <baskov@ispras.ru>
---
arch/x86/boot/compressed/cmdline.c | 24 ++++++++++++++++++++++--
arch/x86/boot/compressed/misc.h | 1 +
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
index f1add5d85da9..717f450662aa 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -12,6 +12,15 @@ static inline char rdfs8(addr_t addr)
return *((char *)(fs + addr));
}
#include "../cmdline.c"
+
+static char command_line[COMMAND_LINE_SIZE] __section(".data") = COMMAND_LINE_INIT;
+static bool command_line_init __section(".data");
+
+/*
+ * This always returns runtime command line and does not account for built-in
+ * command line, so this should not be used for cmdline parsing.
+ * Use get_cmdline() instead.
+ */
unsigned long get_cmd_line_ptr(void)
{
unsigned long cmd_line_ptr = boot_params->hdr.cmd_line_ptr;
@@ -20,11 +29,22 @@ unsigned long get_cmd_line_ptr(void)
return cmd_line_ptr;
}
+
+static inline unsigned long get_cmdline(void)
+{
+ if (!command_line_init) {
+ cmdline_prepare(command_line, (char *)get_cmd_line_ptr());
+ command_line_init = 1;
+ }
+
+ return (unsigned long)command_line;
+}
+
int cmdline_find_option(const char *option, char *buffer, int bufsize)
{
- return __cmdline_find_option(get_cmd_line_ptr(), option, buffer, bufsize);
+ return __cmdline_find_option(get_cmdline(), option, buffer, bufsize);
}
int cmdline_find_option_bool(const char *option)
{
- return __cmdline_find_option_bool(get_cmd_line_ptr(), option);
+ return __cmdline_find_option_bool(get_cmdline(), option);
}
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 62208ec04ca4..5bf1357c054c 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -26,6 +26,7 @@
#include <asm/boot.h>
#include <asm/bootparam.h>
#include <asm/desc_defs.h>
+#include <asm/shared/cmdline.h>
#include "tdx.h"
--
2.37.2
next prev parent reply other threads:[~2022-08-27 2:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-27 2:08 [PATCH v6 0/5] Parse CONFIG_CMDLINE " Evgeniy Baskov
2022-08-27 2:08 ` [PATCH v6 1/5] x86/boot: Add strlcat() and strscpy() to " Evgeniy Baskov
2022-08-27 2:08 ` [PATCH v6 2/5] x86: Add cmdline_prepare() helper Evgeniy Baskov
2022-09-30 17:30 ` Borislav Petkov
2022-10-04 12:33 ` Evgeniy Baskov
2022-08-27 2:08 ` [PATCH v6 3/5] x86/setup: Use cmdline_prepare() in setup.c Evgeniy Baskov
2022-08-27 2:08 ` Evgeniy Baskov [this message]
2022-08-27 2:08 ` [PATCH v6 5/5] x86/boot: Remove no longer needed includes Evgeniy Baskov
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=6d220213ad1a90bf905f2ea324dcc8a3db5707ca.1661565218.git.baskov@ispras.ru \
--to=baskov@ispras.ru \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=khoroshilov@ispras.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@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®