From: tip-bot for Thomas Lendacky <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: dave.hansen@intel.com, keescook@chromium.org,
ndesaulniers@google.com, luto@kernel.org,
samitolvanen@google.com, mingo@redhat.com, dyoung@redhat.com,
x86@kernel.org, Thomas.Lendacky@amd.com, hpa@zytor.com,
brijesh.singh@amd.com, okaya@codeaurora.org, jgross@suse.com,
linux-kernel@vger.kernel.org, mingo@kernel.org,
lijiang@redhat.com, rrichter@marvell.com,
pasha.tatashin@oracle.com, peterz@infradead.org, bp@suse.de,
jroedel@suse.de, bhe@redhat.com, tglx@linutronix.de,
thomas.lendacky@amd.com
Subject: [tip:x86/kdump] x86/mm: Identify the end of the kernel area to be reserved
Date: Thu, 20 Jun 2019 02:58:16 -0700 [thread overview]
Message-ID: <tip-c603a309cc75f3dd018ddb20ee44c05047918cbf@git.kernel.org> (raw)
In-Reply-To: <7db7da45b435f8477f25e66f292631ff766a844c.1560969363.git.thomas.lendacky@amd.com>
Commit-ID: c603a309cc75f3dd018ddb20ee44c05047918cbf
Gitweb: https://git.kernel.org/tip/c603a309cc75f3dd018ddb20ee44c05047918cbf
Author: Thomas Lendacky <Thomas.Lendacky@amd.com>
AuthorDate: Wed, 19 Jun 2019 18:40:57 +0000
Committer: Borislav Petkov <bp@suse.de>
CommitDate: Thu, 20 Jun 2019 09:22:47 +0200
x86/mm: Identify the end of the kernel area to be reserved
The memory occupied by the kernel is reserved using memblock_reserve()
in setup_arch(). Currently, the area is from symbols _text to __bss_stop.
Everything after __bss_stop must be specifically reserved otherwise it
is discarded. This is not clearly documented.
Add a new symbol, __end_of_kernel_reserve, that more readily identifies
what is reserved, along with comments that indicate what is reserved,
what is discarded and what needs to be done to prevent a section from
being discarded.
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
Tested-by: Lianbo Jiang <lijiang@redhat.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Joerg Roedel <jroedel@suse.de>
Cc: Juergen Gross <jgross@suse.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Pavel Tatashin <pasha.tatashin@oracle.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Robert Richter <rrichter@marvell.com>
Cc: Sami Tolvanen <samitolvanen@google.com>
Cc: Sinan Kaya <okaya@codeaurora.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "x86@kernel.org" <x86@kernel.org>
Link: https://lkml.kernel.org/r/7db7da45b435f8477f25e66f292631ff766a844c.1560969363.git.thomas.lendacky@amd.com
---
arch/x86/include/asm/sections.h | 2 ++
arch/x86/kernel/setup.c | 8 +++++++-
arch/x86/kernel/vmlinux.lds.S | 9 ++++++++-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/arch/x86/include/asm/sections.h b/arch/x86/include/asm/sections.h
index 8ea1cfdbeabc..71b32f2570ab 100644
--- a/arch/x86/include/asm/sections.h
+++ b/arch/x86/include/asm/sections.h
@@ -13,4 +13,6 @@ extern char __end_rodata_aligned[];
extern char __end_rodata_hpage_align[];
#endif
+extern char __end_of_kernel_reserve[];
+
#endif /* _ASM_X86_SECTIONS_H */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index 08a5f4a131f5..dac60ad37e5e 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -827,8 +827,14 @@ dump_kernel_offset(struct notifier_block *self, unsigned long v, void *p)
void __init setup_arch(char **cmdline_p)
{
+ /*
+ * Reserve the memory occupied by the kernel between _text and
+ * __end_of_kernel_reserve symbols. Any kernel sections after the
+ * __end_of_kernel_reserve symbol must be explicitly reserved with a
+ * separate memblock_reserve() or they will be discarded.
+ */
memblock_reserve(__pa_symbol(_text),
- (unsigned long)__bss_stop - (unsigned long)_text);
+ (unsigned long)__end_of_kernel_reserve - (unsigned long)_text);
/*
* Make sure page 0 is always reserved because on systems with
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 0850b5149345..ca2252ca6ad7 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -368,6 +368,14 @@ SECTIONS
__bss_stop = .;
}
+ /*
+ * The memory occupied from _text to here, __end_of_kernel_reserve, is
+ * automatically reserved in setup_arch(). Anything after here must be
+ * explicitly reserved using memblock_reserve() or it will be discarded
+ * and treated as available memory.
+ */
+ __end_of_kernel_reserve = .;
+
. = ALIGN(PAGE_SIZE);
.brk : AT(ADDR(.brk) - LOAD_OFFSET) {
__brk_base = .;
@@ -382,7 +390,6 @@ SECTIONS
STABS_DEBUG
DWARF_DEBUG
- /* Sections to be discarded */
DISCARDS
/DISCARD/ : {
*(.eh_frame)
next prev parent reply other threads:[~2019-06-20 10:00 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-19 18:40 [PATCH v3 0/2] x86: SME: Kexec/kdump memory loading fix Lendacky, Thomas
2019-06-19 18:40 ` [PATCH v3 1/2] x86/mm: Identify the end of the kernel area to be reserved Lendacky, Thomas
2019-06-20 9:58 ` tip-bot for Thomas Lendacky [this message]
2019-07-13 14:59 ` Mike Lothian
2019-07-14 10:16 ` Thomas Gleixner
2019-07-14 10:27 ` Mike Lothian
2019-07-15 8:12 ` Thomas Gleixner
[not found] ` <CAHbf0-F9yUDJ=DKug+MZqsjW+zPgwWaLUC40BLOsr5+t4kYOLQ@mail.gmail.com>
2019-07-15 9:25 ` Thomas Gleixner
2019-07-15 10:35 ` Thomas Gleixner
2019-07-15 20:16 ` H.J. Lu
2019-07-23 13:05 ` Greg KH
2019-07-23 13:31 ` Thomas Gleixner
2019-07-23 13:44 ` Greg KH
2019-07-24 15:34 ` Greg KH
2019-07-24 15:49 ` Thomas Gleixner
2019-07-24 15:57 ` Greg KH
2019-07-24 16:03 ` Thomas Gleixner
2019-07-24 16:16 ` Greg KH
2019-07-24 20:02 ` Thomas Gleixner
2019-07-24 20:20 ` Thomas Gleixner
2019-07-25 6:24 ` Greg KH
2019-08-14 11:09 ` Mike Lothian
2019-08-19 12:53 ` Mike Lothian
2019-08-19 13:08 ` Thomas Gleixner
2019-08-19 13:21 ` Mike Lothian
2019-08-19 13:31 ` Thomas Gleixner
2019-08-20 12:46 ` Mike Lothian
2019-07-24 16:22 ` Peter Zijlstra
2019-07-24 16:01 ` Thomas Gleixner
2019-07-23 13:43 ` Greg KH
2019-06-19 18:40 ` [PATCH v3 2/2] x86/mm: Create a workarea in the kernel for SME early encryption Lendacky, Thomas
2019-06-20 9:58 ` [tip:x86/kdump] " tip-bot for Thomas Lendacky
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=tip-c603a309cc75f3dd018ddb20ee44c05047918cbf@git.kernel.org \
--to=tipbot@zytor.com \
--cc=Thomas.Lendacky@amd.com \
--cc=bhe@redhat.com \
--cc=bp@suse.de \
--cc=brijesh.singh@amd.com \
--cc=dave.hansen@intel.com \
--cc=dyoung@redhat.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=jroedel@suse.de \
--cc=keescook@chromium.org \
--cc=lijiang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=ndesaulniers@google.com \
--cc=okaya@codeaurora.org \
--cc=pasha.tatashin@oracle.com \
--cc=peterz@infradead.org \
--cc=rrichter@marvell.com \
--cc=samitolvanen@google.com \
--cc=tglx@linutronix.de \
--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).