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 ; 24 Feb 2019 15:11:17 -0000 Received: from mga03.intel.com ([134.134.136.65]) by Galois.linutronix.de with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1gxvNq-0001Qs-Fb for speck@linutronix.de; Sun, 24 Feb 2019 16:08:03 +0100 From: Andi Kleen Subject: [MODERATED] [PATCH v6 13/43] MDSv6 Date: Sun, 24 Feb 2019 07:07:19 -0800 Message-Id: In-Reply-To: References: In-Reply-To: References: To: speck@linutronix.de Cc: Andi Kleen List-ID: From: Andi Kleen Subject: x86/speculation/mds: Check lazy clear in kernel exit Add support for only clearing on kernel exit when the per cpu clear flag is set. This will be the base of lazy clearing. Right now this is a nop because mds=full is still default. Signed-off-by: Andi Kleen --- arch/x86/entry/common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index ffcc24620ec9..cd6e044d6599 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -212,8 +212,12 @@ __visible inline void prepare_exit_to_usermode(struct pt_regs *regs) ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED); #endif - if (static_key_enabled(&force_cpu_clear)) + if (static_cpu_has(X86_BUG_MDS) && + (static_key_enabled(&force_cpu_clear) || + __this_cpu_read(clear_cpu_flag))) { clear_cpu(); + __this_cpu_write(clear_cpu_flag, false); + } user_enter_irqoff(); } -- 2.17.2