Message ID | 20210115083255.12744-3-rppt@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | x86/setup: consolidate early memory reservations | expand |
On 15.01.21 09:32, Mike Rapoport wrote: > From: Mike Rapoport <rppt@linux.ibm.com> > > Currently the first several pages are reserved both to avoid leaking their > contents on systems with L1TF and to avoid corrupting BIOS memory. > > Merge the two memory reservations. > > Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> > --- > arch/x86/kernel/setup.c | 29 +++++++++++------------------ > 1 file changed, 11 insertions(+), 18 deletions(-) > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index 32cd2e790a0a..3f2fd67240f8 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -715,20 +715,6 @@ static int __init parse_reservelow(char *p) > > early_param("reservelow", parse_reservelow); > > -static void __init trim_low_memory_range(void) > -{ > - /* > - * A special case is the first 4Kb of memory; > - * This is a BIOS owned area, not kernel ram, but generally > - * not listed as such in the E820 table. > - * > - * This typically reserves additional memory (64KiB by default) > - * since some BIOSes are known to corrupt low memory. See the > - * Kconfig help text for X86_RESERVE_LOW. > - */ > - memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); > -} > - > static void __init early_reserve_memory(void) > { > /* > @@ -741,10 +727,18 @@ static void __init early_reserve_memory(void) > (unsigned long)__end_of_kernel_reserve - (unsigned long)_text); > > /* > - * Make sure page 0 is always reserved because on systems with > - * L1TF its contents can be leaked to user processes. > + * The first 4Kb of memory is a BIOS owned area, but generally it is > + * not listed as such in the E820 table. > + * > + * Reserve the first memory page and typically some additional > + * memory (64KiB by default) since some BIOSes are known to corrupt > + * low memory. See the Kconfig help text for X86_RESERVE_LOW. > + * > + * In addition, we must make sure page 0 is always reserved because > + * on systems with L1TF its contents can be leaked to user > + * processes. > */ > - memblock_reserve(0, PAGE_SIZE); > + memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); > > early_reserve_initrd(); > > @@ -757,7 +751,6 @@ static void __init early_reserve_memory(void) > reserve_bios_regions(); > > trim_platform_memory_ranges(); > - trim_low_memory_range(); > } > > /* > Reviewed-by: David Hildenbrand <david@redhat.com>
On Fri, Jan 15, 2021 at 10:32:55AM +0200, Mike Rapoport wrote: > From: Mike Rapoport <rppt@linux.ibm.com> > > Currently the first several pages are reserved both to avoid leaking their > contents on systems with L1TF and to avoid corrupting BIOS memory. > > Merge the two memory reservations. > > Signed-off-by: Mike Rapoport <rppt@linux.ibm.com> > --- > arch/x86/kernel/setup.c | 29 +++++++++++------------------ > 1 file changed, 11 insertions(+), 18 deletions(-) > > diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c > index 32cd2e790a0a..3f2fd67240f8 100644 > --- a/arch/x86/kernel/setup.c > +++ b/arch/x86/kernel/setup.c > @@ -715,20 +715,6 @@ static int __init parse_reservelow(char *p) > > early_param("reservelow", parse_reservelow); > > -static void __init trim_low_memory_range(void) > -{ > - /* > - * A special case is the first 4Kb of memory; > - * This is a BIOS owned area, not kernel ram, but generally > - * not listed as such in the E820 table. > - * > - * This typically reserves additional memory (64KiB by default) > - * since some BIOSes are known to corrupt low memory. See the > - * Kconfig help text for X86_RESERVE_LOW. > - */ > - memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); > -} > - > static void __init early_reserve_memory(void) > { > /* > @@ -741,10 +727,18 @@ static void __init early_reserve_memory(void) > (unsigned long)__end_of_kernel_reserve - (unsigned long)_text); > > /* > - * Make sure page 0 is always reserved because on systems with > - * L1TF its contents can be leaked to user processes. > + * The first 4Kb of memory is a BIOS owned area, but generally it is > + * not listed as such in the E820 table. > + * > + * Reserve the first memory page and typically some additional > + * memory (64KiB by default) since some BIOSes are known to corrupt > + * low memory. See the Kconfig help text for X86_RESERVE_LOW. > + * > + * In addition, we must make sure page 0 is always reserved because s/we must// Other than that: Reviewed-by: Borislav Petkov <bp@suse.de>
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 32cd2e790a0a..3f2fd67240f8 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -715,20 +715,6 @@ static int __init parse_reservelow(char *p) early_param("reservelow", parse_reservelow); -static void __init trim_low_memory_range(void) -{ - /* - * A special case is the first 4Kb of memory; - * This is a BIOS owned area, not kernel ram, but generally - * not listed as such in the E820 table. - * - * This typically reserves additional memory (64KiB by default) - * since some BIOSes are known to corrupt low memory. See the - * Kconfig help text for X86_RESERVE_LOW. - */ - memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); -} - static void __init early_reserve_memory(void) { /* @@ -741,10 +727,18 @@ static void __init early_reserve_memory(void) (unsigned long)__end_of_kernel_reserve - (unsigned long)_text); /* - * Make sure page 0 is always reserved because on systems with - * L1TF its contents can be leaked to user processes. + * The first 4Kb of memory is a BIOS owned area, but generally it is + * not listed as such in the E820 table. + * + * Reserve the first memory page and typically some additional + * memory (64KiB by default) since some BIOSes are known to corrupt + * low memory. See the Kconfig help text for X86_RESERVE_LOW. + * + * In addition, we must make sure page 0 is always reserved because + * on systems with L1TF its contents can be leaked to user + * processes. */ - memblock_reserve(0, PAGE_SIZE); + memblock_reserve(0, ALIGN(reserve_low, PAGE_SIZE)); early_reserve_initrd(); @@ -757,7 +751,6 @@ static void __init early_reserve_memory(void) reserve_bios_regions(); trim_platform_memory_ranges(); - trim_low_memory_range(); } /*