[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220504204123.22967-3-baskov@ispras.ru>
Date: Wed, 4 May 2022 23:41:23 +0300
From: Baskov Evgeniy <baskov@...ras.ru>
To: Borislav Petkov <bp@...en8.de>
Cc: Baskov Evgeniy <baskov@...ras.ru>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 2/2] x86: Parse CONFIG_CMDLINE in compressed kernel
CONFIG_CMDLINE, CONFIG_CMDLINE_BOOL, and CONFIG_CMDLINE_OVERRIDE were
ignored during options lookup in compressed kernel.
Parse CONFIG_CMDLINE-related options correctly in compressed kernel
code.
cmd_line_ptr is explicitly placed in .data section since it is used
and expected to be equal to zero before .bss section is cleared.
Signed-off-by: Baskov Evgeniy <baskov@...ras.ru>
diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c
index f1add5d85da9..58723983933d 100644
--- a/arch/x86/boot/compressed/cmdline.c
+++ b/arch/x86/boot/compressed/cmdline.c
@@ -1,22 +1,46 @@
// SPDX-License-Identifier: GPL-2.0
#include "misc.h"
+#define COMMAND_LINE_SIZE 2048
+
static unsigned long fs;
+
static inline void set_fs(unsigned long seg)
{
fs = seg << 4; /* shift it back */
}
+
typedef unsigned long addr_t;
+
static inline char rdfs8(addr_t addr)
{
return *((char *)(fs + addr));
}
+
#include "../cmdline.c"
+
+static unsigned long cmd_line_ptr __section(".data");
+#ifdef CONFIG_CMDLINE_BOOL
+static char builtin_cmdline[COMMAND_LINE_SIZE] = CONFIG_CMDLINE;
+#endif
+
unsigned long get_cmd_line_ptr(void)
{
- unsigned long cmd_line_ptr = boot_params->hdr.cmd_line_ptr;
+ if (!cmd_line_ptr) {
+ cmd_line_ptr = boot_params->hdr.cmd_line_ptr;
+
+ cmd_line_ptr |= (u64)boot_params->ext_cmd_line_ptr << 32;
+
+#ifdef CONFIG_CMDLINE_BOOL
+ if (!IS_ENABLED(CONFIG_CMDLINE_OVERRIDE)) {
+ strlcat(builtin_cmdline, " ", COMMAND_LINE_SIZE);
+ strlcat(builtin_cmdline,
+ (char *)cmd_line_ptr, COMMAND_LINE_SIZE);
+ }
- cmd_line_ptr |= (u64)boot_params->ext_cmd_line_ptr << 32;
+ cmd_line_ptr = (unsigned long)builtin_cmdline;
+#endif
+ }
return cmd_line_ptr;
}
--
2.36.0
Powered by blists - more mailing lists