From: "H. Peter Anvin" <hpa@zytor.com>
To: Ingo Molnar <mingo@kernel.org>, James Le Cuirot <chewi@gentoo.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH] x86: fix oops caused by old EFI info on kexec boot
Date: Wed, 3 Dec 2025 13:27:40 -0800 [thread overview]
Message-ID: <05db807e-887a-4502-8de1-ec9910f66b60@zytor.com> (raw)
In-Reply-To: <76520AF9-9A09-4D9C-850F-04761E1C1484@zytor.com>
[-- Attachment #1: Type: text/plain, Size: 528 bytes --]
On 2025-12-03 12:59, H. Peter Anvin wrote:
>>
>> Yeah, so this looks like a good fix - but please let's
>> introduce some sort of enum for the bootloader IDs
>> in arch/x86/include/uapi/asm/bootparam.h, I had to search
>> way too long to figure out what 0xD is and where it
>> was defined :-)
>>
>> Also, please introduce a "x86_bootloader_is_kexec()" kind
>> of helper inline function as well.
>>
>
> An enum and an accessor, please, that decodes the extended ID if necessary.
>
Maybe something like this (untested.)
-hpa
[-- Attachment #2: 0001-x86-boot-add-enumeration-and-accessors-for-boot-load.patch --]
[-- Type: text/x-patch, Size: 2802 bytes --]
From b65a27b0096bd953f56facee7c41213bce5cb13e Mon Sep 17 00:00:00 2001
From: "H. Peter Anvin" <hpa@zytor.com>
Date: Wed, 3 Dec 2025 13:20:07 -0800
Subject: [PATCH 1/1] x86/boot: add enumeration and accessors for boot loader
ID and version
Add an enumeration of boot loader type IDs; since both the type ID and
the version number is split between two fields, add accessors to read
and write these fields (the latter is intended for boot loaders to use
as this is a uapi header.)
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
---
arch/x86/include/uapi/asm/bootparam.h | 44 +++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/arch/x86/include/uapi/asm/bootparam.h b/arch/x86/include/uapi/asm/bootparam.h
index dafbf581c515..38f98012fd2b 100644
--- a/arch/x86/include/uapi/asm/bootparam.h
+++ b/arch/x86/include/uapi/asm/bootparam.h
@@ -26,6 +26,28 @@
#define XLF_5LEVEL_ENABLED (1<<6)
#define XLF_MEM_ENCRYPTION (1<<7)
+/* bootloader ID */
+#define BOOTLOADER_LILO 0x00
+#define BOOTLOADER_LOADLIN 0x01
+/* 0x02 used by kernel internal boot sector - long since obsolete */
+#define BOOTLOADER_SYSLINUX 0x03
+#define BOOTLOADER_IPXE 0x04
+#define BOOTLOADER_ELILO 0x05
+/* 0x06 unknown user */
+#define BOOTLOADER_GRUB 0x07
+#define BOOTLOADER_UBOOT 0x08
+#define BOOTLOADER_XEN 0x09
+#define BOOTLOADER_GUJIN 0x0a
+#define BOOTLOADER_QEMU 0x0b
+#define BOOTLOADER_ARCTURUS 0x0c /* "Arcturus Networks uCbootloader" */
+#define BOOTLOADER_KEXEC_TOOLS 0x0d
+#define BOOTLOADER_EXTENDED_ID 0x0e /* Escape into the 0x10+ space */
+#define BOOTLOADER_MISSING_ID 0x0f /* Bootloader unknown */
+#define BOOTLOADER_EXTID_BASE 0x10 /* Error: ext_loader_type never set */
+#define BOOTLOADER_MINIMAL 0x11 /* "Minimal Linux Bootloader" */
+#define BOOTLOADER_OVMF 0x12
+#define BOOTLOADER_BAREBOX 0x13
+
#ifndef __ASSEMBLER__
#include <linux/types.h>
@@ -162,6 +184,28 @@ struct boot_params {
__u8 _pad9[276]; /* 0xeec */
} __attribute__((packed));
+static inline unsigned int boot_loader_type(const struct boot_params *_bp)
+{
+ unsigned int _type = _bp->type_of_loader >> 4;
+ if (_type == BOOTLOADER_EXTENDED_ID)
+ _type = _bp->ext_loader_type + BOOTLOADER_EXTID_BASE
+ return _type;
+}
+static inline unsigned int boot_loader_ver(const struct boot_params *_bp)
+{
+ return (_bp->type_of_loader & 0x0f) + (_bp->ext_loader_ver << 4);
+}
+static inline void set_boot_loader(struct boot_params *_bp,
+ unsigned int _type, unsigned int _ver)
+{
+ if (_type >= BOOTLOADER_EXTID_BASE) {
+ _bp->ext_loader_type = _type - BOOTLOADER_EXTID_BASE;
+ _type = BOOTLOADER_EXTENDED_ID;
+ }
+ _bp->ext_loader_ver = _ver >> 4;
+ _bp->type_of_loader = _type + (_ver & 0x0f);
+}
+
/**
* enum x86_hardware_subarch - x86 hardware subarchitecture
*
--
2.52.0
next prev parent reply other threads:[~2025-12-03 21:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 17:32 James Le Cuirot
2025-12-03 18:12 ` Ingo Molnar
2025-12-03 20:59 ` H. Peter Anvin
2025-12-03 21:27 ` H. Peter Anvin [this message]
2025-12-06 11:45 ` Ingo Molnar
2025-12-03 22:57 ` Ard Biesheuvel
2025-12-03 23:01 ` Ard Biesheuvel
2025-12-04 21:40 ` James Le Cuirot
2025-12-04 23:18 ` H. Peter Anvin
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=05db807e-887a-4502-8de1-ec9910f66b60@zytor.com \
--to=hpa@zytor.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=chewi@gentoo.org \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@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®