From: Mike Rapoport <rppt@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>,
Baoquan He <bhe@redhat.com>, Borislav Petkov <bp@alien8.de>,
David Hildenbrand <david@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>, Ingo Molnar <mingo@redhat.com>,
Mel Gorman <mgorman@suse.de>, Michal Hocko <mhocko@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Mike Rapoport <rppt@linux.ibm.com>, Qian Cai <cai@lca.pw>,
Thomas Gleixner <tglx@linutronix.de>,
Vlastimil Babka <vbabka@suse.cz>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
Borislav Petkov <bp@suse.de>
Subject: [PATCH v2 2/2] x86/setup: merge several reservations of start of the memory
Date: Thu, 28 Jan 2021 12:57:11 +0200 [thread overview]
Message-ID: <20210128105711.10428-3-rppt@kernel.org> (raw)
In-Reply-To: <20210128105711.10428-1-rppt@kernel.org>
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>
Reviewed-by: David Hildenbrand <david@redhat.com>
Acked-by: Borislav Petkov <bp@suse.de>
---
arch/x86/kernel/setup.c | 28 ++++++++++------------------
1 file changed, 10 insertions(+), 18 deletions(-)
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 3b582406363a..b36624e3dc9e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -703,20 +703,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)
{
/*
@@ -729,10 +715,17 @@ 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, 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();
@@ -745,7 +738,6 @@ static void __init early_reserve_memory(void)
reserve_bios_regions();
trim_snb_memory();
- trim_low_memory_range();
}
/*
--
2.28.0
next prev parent reply other threads:[~2021-01-28 10:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-28 10:57 [PATCH v2 0/2] x86/setup: consolidate early memory reservations Mike Rapoport
2021-01-28 10:57 ` [PATCH v2 1/2] " Mike Rapoport
2021-01-28 10:57 ` Mike Rapoport [this message]
2021-02-05 19:47 ` [PATCH v2 0/2] " Mike Rapoport
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210128105711.10428-3-rppt@kernel.org \
--to=rppt@kernel.org \
--cc=aarcange@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=bp@alien8.de \
--cc=bp@suse.de \
--cc=cai@lca.pw \
--cc=david@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@kernel.org \
--cc=mingo@redhat.com \
--cc=rppt@linux.ibm.com \
--cc=tglx@linutronix.de \
--cc=vbabka@suse.cz \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).