From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linutronix.de (146.0.238.70:993) by crypto-ml.lab.linutronix.de with IMAP4-SSL for ; 19 Feb 2019 13:38:14 -0000 Received: from localhost ([127.0.0.1] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1gw5b1-0004AC-8b for speck@linutronix.de; Tue, 19 Feb 2019 14:38:03 +0100 Message-Id: <20190219125346.051578613@linutronix.de> Date: Tue, 19 Feb 2019 13:44:09 +0100 From: Thomas Gleixner References: <20190219124406.449727187@linutronix.de> MIME-Version: 1.0 Subject: [patch 3/8] MDS basics 3 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: speck@linutronix.de List-ID: Subject: [patch 3/8] x86/speculation/mds: Clear CPU buffers on exit to user From: Thomas Gleixner Add a static key which controls the invocation of the CPU buffer clear mechanism on exit to user space and add the call into prepare_exit_to_usermode() right before actually returning. Signed-off-by: Thomas Gleixner --- arch/x86/entry/common.c | 3 +++ arch/x86/include/asm/nospec-branch.h | 2 ++ arch/x86/kernel/cpu/bugs.c | 4 +++- 3 files changed, 8 insertions(+), 1 deletion(-) --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -31,6 +31,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -211,6 +212,8 @@ static void exit_to_usermode_loop(struct ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED); #endif + mds_clear_cpu_buffers(&user_mds_clear_cpu_buffers); + user_enter_irqoff(); } --- a/arch/x86/include/asm/nospec-branch.h +++ b/arch/x86/include/asm/nospec-branch.h @@ -337,6 +337,8 @@ DECLARE_STATIC_KEY_FALSE(switch_to_cond_ DECLARE_STATIC_KEY_FALSE(switch_mm_cond_ibpb); DECLARE_STATIC_KEY_FALSE(switch_mm_always_ibpb); +DECLARE_STATIC_KEY_FALSE(user_mds_clear_cpu_buffers); + #endif /* __ASSEMBLY__ */ /* --- a/arch/x86/kernel/cpu/bugs.c +++ b/arch/x86/kernel/cpu/bugs.c @@ -63,10 +63,12 @@ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_i /* Control unconditional IBPB in switch_mm() */ DEFINE_STATIC_KEY_FALSE(switch_mm_always_ibpb); +/* Control MDS CPU buffer clear before returning to user space */ +DEFINE_STATIC_KEY_FALSE(user_mds_clear_cpu_buffers); + void __init check_bugs(void) { identify_boot_cpu(); - /* * identify_boot_cpu() initialized SMT support information, let the * core code know.