[patch V163 31/51] x86/mm/pti: Share cpu_entry_area PMDs
From: Thomas Gleixner
Date: Mon Dec 18 2017 - 07:00:19 EST
From: Andy Lutomirski <luto@xxxxxxxxxx>
Share the FIX_USR_SHARED PMDs so the user space and kernel space page
tables have the same PMD page.
[ tglx: Made it use the FIX_USR_SHARED range so later additions
are covered automatically ]
Signed-off-by: Andy Lutomirski <luto@xxxxxxxxxx>
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Brian Gerst <brgerst@xxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: David Laight <David.Laight@xxxxxxxxxx>
Cc: Denys Vlasenko <dvlasenk@xxxxxxxxxx>
Cc: Eduardo Valentin <eduval@xxxxxxxxxx>
Cc: Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Cc: Juergen Gross <jgross@xxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Will Deacon <will.deacon@xxxxxxx>
Cc: aliguori@xxxxxxxxxx
Cc: daniel.gruss@xxxxxxxxxxxxxx
Cc: hughd@xxxxxxxxxx
Cc: keescook@xxxxxxxxxx
---
arch/x86/mm/pti.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -233,6 +233,23 @@ pti_clone_pmds(unsigned long start, unsi
}
/*
+ * Clone the populated PMDs of the user shared fixmaps into the user space
+ * visible page table.
+ */
+static void __init pti_clone_user_shared(void)
+{
+ unsigned long bot, top;
+
+ bot = __fix_to_virt(FIX_USR_SHARED_BOTTOM);
+ top = __fix_to_virt(FIX_USR_SHARED_TOP) + PAGE_SIZE;
+
+ /* Top of the user shared block must be PMD-aligned. */
+ WARN_ON(top & ~PMD_MASK);
+
+ pti_clone_pmds(bot, top, 0);
+}
+
+/*
* Initialize kernel page table isolation
*/
void __init pti_init(void)
@@ -241,4 +258,6 @@ void __init pti_init(void)
return;
pr_info("enabled\n");
+
+ pti_clone_user_shared();
}