[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260120195407.1163051-11-hpa@zytor.com>
Date: Tue, 20 Jan 2026 11:54:02 -0800
From: "H. Peter Anvin" <hpa@...or.com>
To: Thomas Gleixner <tglx@...nel.org>, Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Uros Bizjak <ubizjak@...il.com>, Petr Mladek <pmladek@...e.com>,
Andrew Morton <akpm@...ux-foundation.org>, Kees Cook <kees@...nel.org>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
Nathan Chancellor <nathan@...nel.org>,
Kiryl Shutsemau <kas@...nel.org>,
Rick Edgecombe <rick.p.edgecombe@...el.com>
Cc: "H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org,
linux-coco@...ts.linux.dev, x86@...nel.org
Subject: [PATCH v1 10/14] x86/boot: explicitly put the old command line pointer in header.S
Put the location for the old command line pointer into header.S. This
not only makes the layout of the header data more explicit, but it
also removes the need for the absolute_pointer() hack in
arch/x86/boot/main.c.
Signed-off-by: H. Peter Anvin (Intel) <hpa@...or.com>
---
arch/x86/boot/header.S | 7 +++++++
arch/x86/boot/main.c | 32 ++++++++++++++++----------------
2 files changed, 23 insertions(+), 16 deletions(-)
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
index 2828b25707bb..4eb12443dafa 100644
--- a/arch/x86/boot/header.S
+++ b/arch/x86/boot/header.S
@@ -43,6 +43,13 @@ SYSSEG = 0x1000 /* historical load address >> 4 */
.section ".header", "a"
# "MZ", MS-DOS header
.word IMAGE_DOS_SIGNATURE
+
+ .org 0x20
+ # Used for the command line protocol in boot protocols 2.00-2.01
+ .globl old_cmdline
+old_cmdline:
+ .word 0, 0
+
.org 0x38
#
# Offset to the PE header.
diff --git a/arch/x86/boot/main.c b/arch/x86/boot/main.c
index ad8869aad6db..864da3deab18 100644
--- a/arch/x86/boot/main.c
+++ b/arch/x86/boot/main.c
@@ -22,36 +22,36 @@ char *HEAP = _end;
char *heap_end = _end; /* Default end of heap = no heap */
/*
- * Copy the header into the boot parameter block. Since this
- * screws up the old-style command line protocol, adjust by
- * filling in the new-style command line pointer instead.
+ * Copy the header into the boot parameter block. Since this screws
+ * up the old-style command line protocol (protocol 2.00-2.01), adjust
+ * by filling in the new-style command line pointer instead.
*/
+struct old_cmdline {
+ u16 cl_magic;
+ u16 cl_offset;
+};
+extern const struct old_cmdline old_cmdline;
+
static void copy_boot_params(void)
{
- struct old_cmdline {
- u16 cl_magic;
- u16 cl_offset;
- };
- const struct old_cmdline * const oldcmd = absolute_pointer(OLD_CL_ADDRESS);
-
BUILD_BUG_ON(sizeof(boot_params) != 4096);
memcpy(&boot_params.hdr, &hdr, sizeof(hdr));
- if (!boot_params.hdr.cmd_line_ptr && oldcmd->cl_magic == OLD_CL_MAGIC) {
+ if (!boot_params.hdr.cmd_line_ptr &&
+ old_cmdline.cl_magic == OLD_CL_MAGIC) {
/* Old-style command line protocol */
- u16 cmdline_seg;
+ u32 cmdline_base = 0x90000;
/*
* Figure out if the command line falls in the region
* of memory that an old kernel would have copied up
* to 0x90000...
*/
- if (oldcmd->cl_offset < boot_params.hdr.setup_move_size)
- cmdline_seg = ds();
- else
- cmdline_seg = 0x9000;
+ if (old_cmdline.cl_offset < boot_params.hdr.setup_move_size)
+ cmdline_base = ds() << 4;
- boot_params.hdr.cmd_line_ptr = (cmdline_seg << 4) + oldcmd->cl_offset;
+ boot_params.hdr.cmd_line_ptr =
+ cmdline_base + old_cmdline.cl_offset;
}
}
--
2.52.0
Powered by blists - more mailing lists