]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0200-x86-mm-pti-Share-cpu_entry_area-with-user-space-page.patch
update ZFS to 0.7.4 + ARC hit rate cherry-pick
[pve-kernel.git] / patches / kernel / 0200-x86-mm-pti-Share-cpu_entry_area-with-user-space-page.patch
CommitLineData
59d5af67 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
321d628a
FG
2From: Andy Lutomirski <luto@kernel.org>
3Date: Mon, 4 Dec 2017 15:07:45 +0100
59d5af67 4Subject: [PATCH] x86/mm/pti: Share cpu_entry_area with user space page tables
321d628a
FG
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5754
10
11Share the cpu entry area so the user space and kernel space page tables
12have the same P4D page.
13
14Signed-off-by: Andy Lutomirski <luto@kernel.org>
15Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
16Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
17Cc: Borislav Petkov <bp@alien8.de>
18Cc: Brian Gerst <brgerst@gmail.com>
19Cc: Dave Hansen <dave.hansen@linux.intel.com>
20Cc: David Laight <David.Laight@aculab.com>
21Cc: Denys Vlasenko <dvlasenk@redhat.com>
22Cc: Eduardo Valentin <eduval@amazon.com>
23Cc: Greg KH <gregkh@linuxfoundation.org>
24Cc: H. Peter Anvin <hpa@zytor.com>
25Cc: Josh Poimboeuf <jpoimboe@redhat.com>
26Cc: Juergen Gross <jgross@suse.com>
27Cc: Linus Torvalds <torvalds@linux-foundation.org>
28Cc: Peter Zijlstra <peterz@infradead.org>
29Cc: Will Deacon <will.deacon@arm.com>
30Cc: aliguori@amazon.com
31Cc: daniel.gruss@iaik.tugraz.at
32Cc: hughd@google.com
33Cc: keescook@google.com
34Signed-off-by: Ingo Molnar <mingo@kernel.org>
35(cherry picked from commit f7cfbee91559ca7e3e961a00ffac921208a115ad)
36Signed-off-by: Andy Whitcroft <apw@canonical.com>
37Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
38(cherry picked from commit 6e8142de3a6e84a82a421b66a74ba37976912282)
39Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
40---
41 arch/x86/mm/pti.c | 25 +++++++++++++++++++++++++
42 1 file changed, 25 insertions(+)
43
44diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
45index d58bcee470fc..59290356f19f 100644
46--- a/arch/x86/mm/pti.c
47+++ b/arch/x86/mm/pti.c
48@@ -264,6 +264,29 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
49 }
50 }
51
52+/*
53+ * Clone a single p4d (i.e. a top-level entry on 4-level systems and a
54+ * next-level entry on 5-level systems.
55+ */
56+static void __init pti_clone_p4d(unsigned long addr)
57+{
58+ p4d_t *kernel_p4d, *user_p4d;
59+ pgd_t *kernel_pgd;
60+
61+ user_p4d = pti_user_pagetable_walk_p4d(addr);
62+ kernel_pgd = pgd_offset_k(addr);
63+ kernel_p4d = p4d_offset(kernel_pgd, addr);
64+ *user_p4d = *kernel_p4d;
65+}
66+
67+/*
68+ * Clone the CPU_ENTRY_AREA into the user space visible page table.
69+ */
70+static void __init pti_clone_user_shared(void)
71+{
72+ pti_clone_p4d(CPU_ENTRY_AREA_BASE);
73+}
74+
75 /*
76 * Initialize kernel page table isolation
77 */
78@@ -273,4 +296,6 @@ void __init pti_init(void)
79 return;
80
81 pr_info("enabled\n");
82+
83+ pti_clone_user_shared();
84 }
85--
862.14.2
87