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

From: Ingo Molnar

Date: Sat Dec 06 2025 - 06:45:34 EST


* H. Peter Anvin <hpa@xxxxxxxxx> wrote:

> --- 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);
> +}

Ack, with a s/_bp/bp, s/_type/type and s/_ver/ver side note, as this
isn't a macro and thus there's no need to obfuscate the inline
function's parameter name to avoid unintended shadowing?

Thanks,

Ingo