From: Andy Lutomirski <[email protected]>

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 <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Brian Gerst <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: David Laight <[email protected]>
Cc: Denys Vlasenko <[email protected]>
Cc: Eduardo Valentin <[email protected]>
Cc: Greg KH <[email protected]>
Cc: H. Peter Anvin <[email protected]>
Cc: Josh Poimboeuf <[email protected]>
Cc: Juergen Gross <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Will Deacon <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
 arch/x86/mm/pti.c |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -187,6 +187,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)
@@ -195,4 +212,6 @@ void __init pti_init(void)
                return;
 
        pr_info("enabled\n");
+
+       pti_clone_user_shared();
 }


Reply via email to