Received: by 10.223.176.46 with SMTP id f43csp1125653wra; Sat, 20 Jan 2018 11:25:54 -0800 (PST) X-Google-Smtp-Source: AH8x224+kNgRkk8y98JYxrI2H/YCAXXL5/2k0DPqIFQbS1nV/aJ1P3b2GDquB8NTEm5fH1lwi4LW X-Received: by 10.98.46.2 with SMTP id u2mr3288658pfu.30.1516476354863; Sat, 20 Jan 2018 11:25:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516476354; cv=none; d=google.com; s=arc-20160816; b=flkMPn2rTzzjmlis7lhNRLopCNcXF9vJWdp5dSbTX0JeLDgEXRYM3lzCS0jOEXut0g n4uVpg9nrVA3WYT1xcxjsmLfdSDV0WOmwVQ+LgQw5TYeryazZcfLgKS8xz8vR9C4hftn hqr64MDhmjr0xKIgtzjrqi9RhoEyWIChEDS/7L/yoQVsuC3z7YUc/BaKKvRxypcwyHG7 bli9s52NVhf/7xJJ/e7vx3Ev6nwyQiB5ncokeMQaYPiRZqQsuBljDtfFGa0Lzuo8hpSO BX1XnqVEbiS9I+JycH7/wTL00sXgf/ZfVm184a4xnbsajvwkOMkhhHtJobe+a/H/lSw1 f8RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=1GTayTy8nk5BwNQrcIcRPKQ1G24jirQNjNDNfrtuUDA=; b=DZrI94iIihxvrBbnKz0R49p+2O/D1qxYdEcmIJ7noRl9OIT6VuGPJU87ZLzOfNFhck 65KbIvQI5MDRbeR4qjANeH/CiUw7fh4tKedLvGZHlQNmXOchBs5dzwWiYEaLVnjmwDCJ loXk61d6DeV0Mj9e8aK6vwE//2voVLR1+CsJ4pkaYFY2Zt/krE4CncxxD9l3K/kU1WrQ ZEwC5ockljKdsgRWWCRQojki3GI8xZLkfCAXLtNrqLyZkC+wbohJjskH2vq4wNZUVs80 pgEfuzVAVmwtm1qpIQOw8bRhInvhNlxsxsypx8XWlCwe/4mOIbHzR+YkfFdhhrtgSEOT R5mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=d62zcGcb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s76si10558276pgc.80.2018.01.20.11.25.41; Sat, 20 Jan 2018 11:25:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=d62zcGcb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932855AbeATTY3 (ORCPT + 99 others); Sat, 20 Jan 2018 14:24:29 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:49196 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932562AbeATTXs (ORCPT ); Sat, 20 Jan 2018 14:23:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1516476227; x=1548012227; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1GTayTy8nk5BwNQrcIcRPKQ1G24jirQNjNDNfrtuUDA=; b=d62zcGcb0V0G61tud+yd1WRe5A/IGyJVJkDdOPnOCeXPl9QG7ubW5cOw 5WV7EMDYwG4h3nt22zLWaWfoa2Tfcko1MINIMBFLiFi4L0d0W8DDEMPn2 37Agjw7MW2DzqBQiivV0r3/YkNPevp62ISME6RfGOLx3zBdCyVvz8J64k Q=; X-IronPort-AV: E=Sophos;i="5.46,387,1511827200"; d="scan'208";a="716423176" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 20 Jan 2018 19:23:42 +0000 Received: from u54e1ad5160425a4b64ea.ant.amazon.com (iad1-ws-svc-lb91-vlan3.amazon.com [10.0.103.150]) by email-inbound-relay-1e-303d0b0e.us-east-1.amazon.com (8.14.7/8.14.7) with ESMTP id w0KJNRhn129147 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 20 Jan 2018 19:23:29 GMT Received: from u54e1ad5160425a4b64ea.ant.amazon.com (localhost [127.0.0.1]) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id w0KJNPJ3005256; Sat, 20 Jan 2018 20:23:25 +0100 Received: (from karahmed@localhost) by u54e1ad5160425a4b64ea.ant.amazon.com (8.15.2/8.15.2/Submit) id w0KJNNRr005255; Sat, 20 Jan 2018 20:23:23 +0100 From: KarimAllah Ahmed To: linux-kernel@vger.kernel.org Cc: KarimAllah Ahmed , Andi Kleen , Andrea Arcangeli , Andy Lutomirski , Arjan van de Ven , Ashok Raj , Asit Mallick , Borislav Petkov , Dan Williams , Dave Hansen , David Woodhouse , Greg Kroah-Hartman , "H . Peter Anvin" , Ingo Molnar , Janakarajan Natarajan , Joerg Roedel , Jun Nakajima , Laura Abbott , Linus Torvalds , Masami Hiramatsu , Paolo Bonzini , Peter Zijlstra , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Thomas Gleixner , Tim Chen , Tom Lendacky , kvm@vger.kernel.org, x86@kernel.org Subject: [RFC 03/10] x86/speculation: Use Indirect Branch Prediction Barrier in context switch Date: Sat, 20 Jan 2018 20:22:54 +0100 Message-Id: <1516476182-5153-4-git-send-email-karahmed@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516476182-5153-1-git-send-email-karahmed@amazon.de> References: <1516476182-5153-1-git-send-email-karahmed@amazon.de> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [peterz: comment] Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: David Woodhouse --- arch/x86/mm/tlb.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c index a156195..304de7d 100644 --- a/arch/x86/mm/tlb.c +++ b/arch/x86/mm/tlb.c @@ -6,13 +6,14 @@ #include #include #include +#include #include #include +#include #include #include #include -#include /* * TLB flushing, formerly SMP-only @@ -220,6 +221,13 @@ void switch_mm_irqs_off(struct mm_struct *prev, struct mm_struct *next, u16 new_asid; bool need_flush; + /* + * Avoid user/user BTB poisoning by flushing the branch predictor + * when switching between processes. This stops one process from + * doing Spectre-v2 attacks on another. + */ + indirect_branch_prediction_barrier(); + if (IS_ENABLED(CONFIG_VMAP_STACK)) { /* * If our current stack is in vmalloc space and isn't -- 2.7.4