Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756736AbeAIM5w (ORCPT + 1 other); Tue, 9 Jan 2018 07:57:52 -0500 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:39128 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756673AbeAIM5t (ORCPT ); Tue, 9 Jan 2018 07:57:49 -0500 From: Willy Tarreau To: linux-kernel@vger.kernel.org, x86@kernel.org Cc: Willy Tarreau , Andy Lutomirski , Borislav Petkov , Brian Gerst , Dave Hansen , Ingo Molnar , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Josh Poimboeuf , "H. Peter Anvin" , Kees Cook Subject: [RFC PATCH v2 3/6] x86/pti: add a per-cpu variable pti_disable Date: Tue, 9 Jan 2018 13:56:17 +0100 Message-Id: <1515502580-12261-4-git-send-email-w@1wt.eu> X-Mailer: git-send-email 2.8.0.rc2.1.gbe9624a In-Reply-To: <1515502580-12261-1-git-send-email-w@1wt.eu> References: <1515502580-12261-1-git-send-email-w@1wt.eu> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: This one is updated upon each context switch to reflect the crrent mm's pti_disable field. Signed-off-by: Willy Tarreau Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: Ingo Molnar Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Josh Poimboeuf Cc: "H. Peter Anvin" Cc: Kees Cook --- 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