Skip to content

Commit 3a63f70

Browse files
Vidossuryasaimadhu
authored andcommitted
x86/boot: Early parse RSDP and save it in boot_params
The RSDP is needed by KASLR so parse it early and save it in boot_params.acpi_rsdp_addr, before KASLR setup runs. RSDP is needed by other kernel facilities so have the parsing code built-in instead of a long "depends on" line in Kconfig. [ bp: - Trim commit message and comments - Add CONFIG_ACPI dependency in the Makefile - Move ->acpi_rsdp_addr assignment with the rest of boot_params massaging in extract_kernel(). ] Signed-off-by: Chao Fan <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Cc: [email protected] Cc: Cao jin <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: Juergen Gross <[email protected]> Cc: [email protected] Cc: Kees Cook <[email protected]> Cc: "Kirill A. Shutemov" <[email protected]> Cc: Masahiro Yamada <[email protected]> Cc: [email protected] Cc: Thomas Gleixner <[email protected]> Cc: Tom Lendacky <[email protected]> Cc: x86-ml <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 93a209a commit 3a63f70

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

arch/x86/boot/compressed/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ ifdef CONFIG_X86_64
8484
vmlinux-objs-y += $(obj)/pgtable_64.o
8585
endif
8686

87+
vmlinux-objs-$(CONFIG_ACPI) += $(obj)/acpi.o
88+
8789
$(obj)/eboot.o: KBUILD_CFLAGS += -fshort-wchar -mno-red-zone
8890

8991
vmlinux-objs-$(CONFIG_EFI_STUB) += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o \

arch/x86/boot/compressed/acpi.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,22 @@ static acpi_physical_address bios_get_rsdp_addr(void)
184184

185185
return 0;
186186
}
187+
188+
/* Return RSDP address on success, otherwise 0. */
189+
acpi_physical_address get_rsdp_addr(void)
190+
{
191+
acpi_physical_address pa;
192+
193+
pa = get_acpi_rsdp();
194+
195+
if (!pa)
196+
pa = boot_params->acpi_rsdp_addr;
197+
198+
if (!pa)
199+
pa = efi_get_rsdp_addr();
200+
201+
if (!pa)
202+
pa = bios_get_rsdp_addr();
203+
204+
return pa;
205+
}

arch/x86/boot/compressed/misc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,9 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
351351
/* Clear flags intended for solely in-kernel use. */
352352
boot_params->hdr.loadflags &= ~KASLR_FLAG;
353353

354+
/* Save RSDP address for later use. */
355+
boot_params->acpi_rsdp_addr = get_rsdp_addr();
356+
354357
sanitize_boot_params(boot_params);
355358

356359
if (boot_params->screen_info.orig_video_mode == 7) {

arch/x86/boot/compressed/misc.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,10 @@ static inline void console_init(void)
119119
void set_sev_encryption_mask(void);
120120

121121
#endif
122+
123+
/* acpi.c */
124+
#ifdef CONFIG_ACPI
125+
acpi_physical_address get_rsdp_addr(void);
126+
#else
127+
static inline acpi_physical_address get_rsdp_addr(void) { return 0; }
128+
#endif

0 commit comments

Comments
 (0)