[PATCH] efi/x86-stub: store acpi_rsdp_addr in bootparams

Dave Young posted 1 patch 1 month, 2 weeks ago
drivers/firmware/efi/libstub/x86-stub.c |   18 ++++++++++++++++++
1 file changed, 18 insertions(+)
[PATCH] efi/x86-stub: store acpi_rsdp_addr in bootparams
Posted by Dave Young 1 month, 2 weeks ago
Kernel panic occurs during a kexec reboot when EFI runtime services
are not enabled in the first kernel. The issue is that the second
kernel cannot find the ACPI RSDP address during boot.

In legacy boot, the acpi_rsdp_addr is set in early x86 boot code.
However, kernel decompression has moved to the EFI stub for EFI boot.
Therefore, the x86 EFI stub must also be updated to store the
acpi_rsdp_addr in the boot parameters to ensure the kexec kernel
can find it.

(Note: If the pre-kexec kernel was itself a kexec boot, the later kexec
reboot will still utilize the legacy decompressor path, so the original
code remains functional though some cleanups can be done later.)

Signed-off-by: Dave Young <dyoung@redhat.com>
---
 drivers/firmware/efi/libstub/x86-stub.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

Index: linux-x86/drivers/firmware/efi/libstub/x86-stub.c
===================================================================
--- linux-x86.orig/drivers/firmware/efi/libstub/x86-stub.c
+++ linux-x86/drivers/firmware/efi/libstub/x86-stub.c
@@ -484,6 +484,22 @@ static void setup_quirks(struct boot_par
 	}
 }
 
+static void setup_acpi_rsdp(struct boot_params *boot_params)
+{
+	u64 rsdp_addr;
+
+	/*
+	 * Search EFI system tables for RSDP. Preferred is ACPI_20_TABLE_GUID to
+	 * ACPI_TABLE_GUID because it has more features.
+	 */
+	rsdp_addr = (u64)get_efi_config_table(ACPI_20_TABLE_GUID);
+	if (!rsdp_addr)
+		rsdp_addr = (u64)get_efi_config_table(ACPI_TABLE_GUID);
+
+	if (rsdp_addr)
+		boot_params->acpi_rsdp_addr = rsdp_addr;
+}
+
 static void setup_graphics(struct boot_params *boot_params)
 {
 	struct screen_info *si = memset(&boot_params->screen_info, 0, sizeof(*si));
@@ -1017,6 +1033,8 @@ void __noreturn efi_stub_entry(efi_handl
 
 	setup_graphics(boot_params);
 
+	setup_acpi_rsdp(boot_params);
+
 	setup_efi_pci(boot_params);
 
 	setup_quirks(boot_params);
Re: [PATCH] efi/x86-stub: store acpi_rsdp_addr in bootparams
Posted by Ard Biesheuvel 1 month, 2 weeks ago
Hi Dave,

On Tue, 17 Feb 2026, at 09:04, Dave Young wrote:
> Kernel panic occurs during a kexec reboot when EFI runtime services
> are not enabled in the first kernel. The issue is that the second
> kernel cannot find the ACPI RSDP address during boot.
>
> In legacy boot, the acpi_rsdp_addr is set in early x86 boot code.
> However, kernel decompression has moved to the EFI stub for EFI boot.
> Therefore, the x86 EFI stub must also be updated to store the
> acpi_rsdp_addr in the boot parameters to ensure the kexec kernel
> can find it.
>
> (Note: If the pre-kexec kernel was itself a kexec boot, the later kexec
> reboot will still utilize the legacy decompressor path, so the original
> code remains functional though some cleanups can be done later.)
>
> Signed-off-by: Dave Young <dyoung@redhat.com>
> ---
>  drivers/firmware/efi/libstub/x86-stub.c |   18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
>

If this issue is kexec-specific, can we move this to where the kexec code prepares the boot_params struct for the next kernel?
Re: [PATCH] efi/x86-stub: store acpi_rsdp_addr in bootparams
Posted by Dave Young 1 month, 2 weeks ago
Hi Ard,

On Tue, 17 Feb 2026 at 16:10, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> Hi Dave,
>
> On Tue, 17 Feb 2026, at 09:04, Dave Young wrote:
> > Kernel panic occurs during a kexec reboot when EFI runtime services
> > are not enabled in the first kernel. The issue is that the second
> > kernel cannot find the ACPI RSDP address during boot.
> >
> > In legacy boot, the acpi_rsdp_addr is set in early x86 boot code.
> > However, kernel decompression has moved to the EFI stub for EFI boot.
> > Therefore, the x86 EFI stub must also be updated to store the
> > acpi_rsdp_addr in the boot parameters to ensure the kexec kernel
> > can find it.
> >
> > (Note: If the pre-kexec kernel was itself a kexec boot, the later kexec
> > reboot will still utilize the legacy decompressor path, so the original
> > code remains functional though some cleanups can be done later.)
> >
> > Signed-off-by: Dave Young <dyoung@redhat.com>
> > ---
> >  drivers/firmware/efi/libstub/x86-stub.c |   18 ++++++++++++++++++
> >  1 file changed, 18 insertions(+)
> >
>
> If this issue is kexec-specific, can we move this to where the kexec code prepares the boot_params struct for the next kernel?
>

The kexec use case is it depends on the pre-kexec kernel saving it
during boot for noefi case.  I do not have a better idea to do it in
kexec code for the time being.  Otherwise it seems the early
acpi_rsdp_addr was introduced for other reason (KASLR) although I'm
not sure about the exact background:   (Before this the original kexec
fallback just depend on end user to put acpi_rsdp in kernel cmdline
explictily or in kexec-tools)
commit 3a63f70bf4c3a17f5d9c9bf3bc3288a23bdfefce
Author: Chao Fan <fanc.fnst@cn.fujitsu.com>
Date:   Wed Jan 23 19:08:48 2019 +0800

    x86/boot: Early parse RSDP and save it in boot_params

Another thing is I do not have much time to work on big changes in
recent years, so if you suggest to have a resturcture I have to give
up :)   But I'm happy to do some trival thing during this week as I'm
in a holiday break and I have some time to play with it.

Thanks
Dave