Re: [PATCH v16 5/7] x86/boot: Early parse RSDP and fill in boot_params

From: Chao Fan
Date: Wed Jan 23 2019 - 06:18:29 EST


On Wed, Jan 23, 2019 at 07:08:48PM +0800, Chao Fan wrote:
[...]
> #endif /* CONFIG_ACPI */
>diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
>index 8dd1d5ccae58..86fa8bf56d68 100644
>--- a/arch/x86/boot/compressed/misc.c
>+++ b/arch/x86/boot/compressed/misc.c
>@@ -382,6 +382,13 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
> debug_putaddr(trampoline_32bit);
> #endif
>
>+ /*
>+ * Very early parse RSDP and fill in boot_params.
>+ * Early parsing is only executed once, and later anyone who
>+ * needs RSDP can gain RSDP address by boot_params but not parse again.
>+ */
>+ boot_params->acpi_rsdp_addr = get_rsdp_addr();
>+

Hi Boris and Kairui,

I splite my v15 PATCH 5/6 to two patches, this v16 5/7 is new added.
Since as Boris said much code such as Kairui's need RSDP where is not
related to KASLR, but in my v15 version, the function entry is only
in kaslr.c. So I expose get_rsdp_addr() as not static, and fill in
boot_params without #ifdef KASLR issue ot MEMORY_HOTREMOVE and so on.
More code can gain the RSDP by boot_params.

Since in KALSR, we need RSDP to parse SRAT and gain memroy information,
so I put boot_params->acpi_rsdp_addr = get_rsdp_addr(); just before
choose_random_location(), in which KASLR works. Then in this version
v16 PATCH 6/7, only try to gain RSDP by boot_params and not parse again.

So I think this method can cover other people's usage, such as Kairui
Song, how do you think this change.

Thanks,
Chao Fan

> /*
> * The memory hole needed for the kernel is the larger of either
> * the entire decompressed kernel plus relocation table, or the
>diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
>index 764ad50c0119..e1dd15769cf3 100644
>--- a/arch/x86/boot/compressed/misc.h
>+++ b/arch/x86/boot/compressed/misc.h
>@@ -119,3 +119,10 @@ static inline void console_init(void)
> void set_sev_encryption_mask(void);
>
> #endif
>+
>+/* acpi.c */
>+#ifdef CONFIG_ACPI
>+acpi_physical_address get_rsdp_addr(void);
>+#else
>+static inline acpi_physical_address get_rsdp_addr(void) { return 0; }
>+#endif
>--
>2.20.1
>