This one is updated upon each context switch to reflect the
crrent mm's pti_disable field.

Signed-off-by: Willy Tarreau <w...@1wt.eu>
Cc: Andy Lutomirski <l...@kernel.org>
Cc: Borislav Petkov <b...@alien8.de>
Cc: Brian Gerst <brge...@gmail.com>
Cc: Dave Hansen <dave.han...@linux.intel.com>
Cc: Ingo Molnar <mi...@kernel.org>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: Josh Poimboeuf <jpoim...@redhat.com>
Cc: "H. Peter Anvin" <h...@zytor.com>
Cc: Kees Cook <keesc...@chromium.org>
---
 arch/x86/kernel/process_64.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 9516310..9bb5908 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -61,6 +61,10 @@
 
 __visible DEFINE_PER_CPU(unsigned long, rsp_scratch);
 
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+__visible DEFINE_PER_CPU(unsigned char, pti_disable);
+#endif
+
 /* Prints also some state that isn't saved in the pt_regs */
 void __show_regs(struct pt_regs *regs, int all)
 {
@@ -473,6 +477,11 @@ void compat_start_thread(struct pt_regs *regs, u32 new_ip, 
u32 new_sp)
                     task_thread_info(prev_p)->flags & _TIF_WORK_CTXSW_PREV))
                __switch_to_xtra(prev_p, next_p, tss);
 
+#ifdef CONFIG_PAGE_TABLE_ISOLATION
+       this_cpu_write(pti_disable,
+                      next_p->mm && next_p->mm->context.pti_disable);
+#endif
+
 #ifdef CONFIG_XEN_PV
        /*
         * On Xen PV, IOPL bits in pt_regs->flags have no effect, and
-- 
1.7.12.1

Reply via email to