Re: [PATCH] x86: fix oops caused by old EFI info on kexec boot

From: H. Peter Anvin

Date: Wed Dec 03 2025 - 16:29:01 EST


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
From b65a27b0096bd953f56facee7c41213bce5cb13e Mon Sep 17 00:00:00 2001
From: "H. Peter Anvin" <hpa@xxxxxxxxx>
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@xxxxxxxxx>
---
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