All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baskov Evgeniy <baskov@ispras.ru>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Baskov Evgeniy <baskov@ispras.ru>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] x86: Parse CONFIG_CMDLINE in compressed kernel
Date: Thu,  7 Apr 2022 05:40:14 +0300	[thread overview]
Message-ID: <20220407024014.6916-1-baskov@ispras.ru> (raw)

CONFIG_CMDLINE_BOOL and CONFIG_CMDLINE_OVERRIDE was 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.

Parse CONFIG_CMDLINE-related options correctly in compressed
kernel code.

Signed-off-by: Baskov Evgeniy <baskov@ispras.ru>

diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
index f1add5d85da9..dd8cbbe61dff 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -22,9 +22,49 @@ unsigned long get_cmd_line_ptr(void)
 }
 int cmdline_find_option(const char *option, char *buffer, int bufsize)
 {
-	return __cmdline_find_option(get_cmd_line_ptr(), option, buffer, bufsize);
+	int len = -1;
+	unsigned long cmdline_ptr;
+
+	/*
+	 * First try command line string provided by user,
+	 * then try command line string configured at comple time.
+	 * Skip first step if CONFIG_CMDLINE_OVERRIDE is enabled
+	 * and parse only compile time command line.
+	 */
+
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+		cmdline_ptr = get_cmd_line_ptr();
+		len = __cmdline_find_option(cmdline_ptr, option,
+					    buffer, bufsize);
+	}
+
+#ifdef CONFIG_CMDLINE_BOOL
+	if (len < 0) {
+		cmdline_ptr = (unsigned long)CONFIG_CMDLINE;
+		len = __cmdline_find_option(cmdline_ptr, option,
+					    buffer, bufsize);
+	}
+#endif
+
+	return len;
 }
 int cmdline_find_option_bool(const char *option)
 {
-	return __cmdline_find_option_bool(get_cmd_line_ptr(), option);
+	int len = -1;
+	unsigned long cmdline_ptr;
+
+	if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+		cmdline_ptr = get_cmd_line_ptr();
+		len = __cmdline_find_option_bool(cmdline_ptr, option);
+	}
+
+
+#ifdef CONFIG_CMDLINE_BOOL
+	if (len < 0) {
+		cmdline_ptr = (unsigned long)CONFIG_CMDLINE;
+		len = __cmdline_find_option_bool(cmdline_ptr, option);
+	}
+#endif
+
+	return len;
 }
-- 
2.35.1


             reply	other threads:[~2022-04-07  2:41 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-07  2:40 Baskov Evgeniy [this message]
2022-05-04  8:59 ` [PATCH] x86: Parse CONFIG_CMDLINE in compressed kernel Borislav Petkov
2022-05-04 20:40   ` baskov
2022-05-04 20:41   ` [PATCH v2 0/2] " Baskov Evgeniy
2022-05-04 20:41     ` [PATCH v2 1/2] x86: add strlcat() to " Baskov Evgeniy
2022-05-04 20:41     ` [PATCH v2 2/2] x86: Parse CONFIG_CMDLINE in " Baskov Evgeniy
2022-05-05 10:32   ` [PATCH v3 0/2] " Baskov Evgeniy
2022-05-05 10:32     ` [PATCH v3 1/2] x86: Add strlcat() to " Baskov Evgeniy
2022-05-12 11:10       ` Borislav Petkov
2022-05-25  5:18         ` baskov
2022-05-05 10:32     ` [PATCH v3 2/2] x86: Parse CONFIG_CMDLINE in " Baskov Evgeniy
2022-05-12 11:21       ` Borislav Petkov
2022-05-25  5:25         ` baskov
2022-05-25  8:22           ` Borislav Petkov
2022-05-25  9:41             ` baskov
2022-05-25 10:10     ` [PATCH v4 0/5] " Evgeniy Baskov
2022-05-25 10:10       ` [PATCH v4 1/5] x86/boot: Add strlcat() to " Evgeniy Baskov
2022-05-25 10:10       ` [PATCH v4 2/5] x86: Add resolve_cmdline() helper Evgeniy Baskov
2022-08-26 11:35         ` Borislav Petkov
2022-08-27  1:51           ` Evgeniy Baskov
2022-05-25 10:10       ` [PATCH v4 3/5] x86/setup: Use resolve_cmdline() in setup.c Evgeniy Baskov
2022-05-25 10:10       ` [PATCH v4 4/5] x86/boot: Use resolve_cmdline() in compressed kernel Evgeniy Baskov
2022-05-25 10:10       ` [PATCH v4 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=20220407024014.6916-1-baskov@ispras.ru \
    --to=baskov@ispras.ru \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.