[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-b234e8a09003af108d3573f0369e25c080676b14@git.kernel.org>
Date: Fri, 8 Jul 2016 13:35:01 -0700
From: tip-bot for Thomas Garnier <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: dvlasenk@...hat.com, schwidefsky@...ibm.com,
dan.j.williams@...el.com, JBeulich@...e.com,
guangrong.xiao@...ux.intel.com, keescook@...omium.org,
lv.zheng@...el.com, aneesh.kumar@...ux.vnet.ibm.com,
dave.hansen@...ux.intel.com, hpa@...or.com,
matt@...eblueprint.co.uk, luto@...nel.org, peterz@...radead.org,
akpm@...ux-foundation.org, dvyukov@...gle.com, yinghai@...nel.org,
dyoung@...hat.com, mingo@...nel.org, corbet@....net,
linux-kernel@...r.kernel.org, bhe@...hat.com, bp@...en8.de,
jgross@...e.com, jroedel@...e.de, alpopov@...ecurity.com,
torvalds@...ux-foundation.org, thgarnie@...gle.com,
tglx@...utronix.de, kuleshovmail@...il.com, toshi.kani@....com,
msalter@...hat.com, jpoimboe@...hat.com, brgerst@...il.com,
kirill.shutemov@...ux.intel.com, bp@...e.de, sds@...ho.nsa.gov,
boris.ostrovsky@...cle.com, borntraeger@...ibm.com
Subject: [tip:x86/boot] x86/mm: Separate variable for trampoline PGD
Commit-ID: b234e8a09003af108d3573f0369e25c080676b14
Gitweb: http://git.kernel.org/tip/b234e8a09003af108d3573f0369e25c080676b14
Author: Thomas Garnier <thgarnie@...gle.com>
AuthorDate: Tue, 21 Jun 2016 17:47:01 -0700
Committer: Ingo Molnar <mingo@...nel.org>
CommitDate: Fri, 8 Jul 2016 17:33:46 +0200
x86/mm: Separate variable for trampoline PGD
Use a separate global variable to define the trampoline PGD used to
start other processors. This change will allow KALSR memory
randomization to change the trampoline PGD to be correctly aligned with
physical memory.
Signed-off-by: Thomas Garnier <thgarnie@...gle.com>
Signed-off-by: Kees Cook <keescook@...omium.org>
Cc: Alexander Kuleshov <kuleshovmail@...il.com>
Cc: Alexander Popov <alpopov@...ecurity.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: Andy Lutomirski <luto@...nel.org>
Cc: Aneesh Kumar K.V <aneesh.kumar@...ux.vnet.ibm.com>
Cc: Baoquan He <bhe@...hat.com>
Cc: Boris Ostrovsky <boris.ostrovsky@...cle.com>
Cc: Borislav Petkov <bp@...en8.de>
Cc: Borislav Petkov <bp@...e.de>
Cc: Brian Gerst <brgerst@...il.com>
Cc: Christian Borntraeger <borntraeger@...ibm.com>
Cc: Dan Williams <dan.j.williams@...el.com>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>
Cc: Dave Young <dyoung@...hat.com>
Cc: Denys Vlasenko <dvlasenk@...hat.com>
Cc: Dmitry Vyukov <dvyukov@...gle.com>
Cc: H. Peter Anvin <hpa@...or.com>
Cc: Jan Beulich <JBeulich@...e.com>
Cc: Joerg Roedel <jroedel@...e.de>
Cc: Jonathan Corbet <corbet@....net>
Cc: Josh Poimboeuf <jpoimboe@...hat.com>
Cc: Juergen Gross <jgross@...e.com>
Cc: Kirill A. Shutemov <kirill.shutemov@...ux.intel.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Lv Zheng <lv.zheng@...el.com>
Cc: Mark Salter <msalter@...hat.com>
Cc: Martin Schwidefsky <schwidefsky@...ibm.com>
Cc: Matt Fleming <matt@...eblueprint.co.uk>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Stephen Smalley <sds@...ho.nsa.gov>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Toshi Kani <toshi.kani@....com>
Cc: Xiao Guangrong <guangrong.xiao@...ux.intel.com>
Cc: Yinghai Lu <yinghai@...nel.org>
Cc: kernel-hardening@...ts.openwall.com
Cc: linux-doc@...r.kernel.org
Link: http://lkml.kernel.org/r/1466556426-32664-5-git-send-email-keescook@chromium.org
Signed-off-by: Ingo Molnar <mingo@...nel.org>
---
arch/x86/include/asm/pgtable.h | 12 ++++++++++++
arch/x86/mm/init.c | 3 +++
arch/x86/realmode/init.c | 5 ++++-
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 1a27396..d455bef 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -729,6 +729,18 @@ extern int direct_gbpages;
void init_mem_mapping(void);
void early_alloc_pgt_buf(void);
+#ifdef CONFIG_X86_64
+/* Realmode trampoline initialization. */
+extern pgd_t trampoline_pgd_entry;
+static inline void __meminit init_trampoline(void)
+{
+ /* Default trampoline pgd value */
+ trampoline_pgd_entry = init_level4_pgt[pgd_index(__PAGE_OFFSET)];
+}
+#else
+static inline void init_trampoline(void) { }
+#endif
+
/* local pte updates need not use xchg for locking */
static inline pte_t native_local_ptep_get_and_clear(pte_t *ptep)
{
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index 372aad2..4252acd 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -590,6 +590,9 @@ void __init init_mem_mapping(void)
/* the ISA range is always mapped regardless of memory holes */
init_memory_mapping(0, ISA_END_ADDRESS);
+ /* Init the trampoline, possibly with KASLR memory offset */
+ init_trampoline();
+
/*
* If the allocation is in bottom-up direction, we setup direct mapping
* in bottom-up, otherwise we setup direct mapping in top-down.
diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
index 0b7a63d..705e3ff 100644
--- a/arch/x86/realmode/init.c
+++ b/arch/x86/realmode/init.c
@@ -8,6 +8,9 @@
struct real_mode_header *real_mode_header;
u32 *trampoline_cr4_features;
+/* Hold the pgd entry used on booting additional CPUs */
+pgd_t trampoline_pgd_entry;
+
void __init reserve_real_mode(void)
{
phys_addr_t mem;
@@ -84,7 +87,7 @@ void __init setup_real_mode(void)
*trampoline_cr4_features = __read_cr4();
trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
- trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
+ trampoline_pgd[0] = trampoline_pgd_entry.pgd;
trampoline_pgd[511] = init_level4_pgt[511].pgd;
#endif
}
Powered by blists - more mailing lists