Received: by 10.223.176.46 with SMTP id f43csp1669882wra; Sun, 21 Jan 2018 01:52:39 -0800 (PST) X-Google-Smtp-Source: AH8x226qL6DvsBOFQzVidA/IVKdTEvQGQSjSc5twviqnWvrz5VRysTlf4Xp5td5jdbRnDL5jybta X-Received: by 2002:a17:902:d90a:: with SMTP id c10-v6mr1892899plz.200.1516528359762; Sun, 21 Jan 2018 01:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516528359; cv=none; d=google.com; s=arc-20160816; b=TKwmUTbwZ4XCiDTmzEab5b+MS/EOtXj0KTYPblTZQiAhpTJoo4QkjJOYHZ21/eOinm elN1jdq0uce2YdNSG07CvrhEdgfpwbmLMM+r6Cg14ym3kd4JOQwkKrO+CUuldtZuaXsp chRByqNEIw0XuSDhOg/9Tjl0be1GUHv5ogYKN9fb57qzpE2o2wc3SVBwQAWtb1adGQiF ycEuQO4bZKsAOFh2xAxxH9eluBveYBMQy2yXl8FkeDsNfMQ6mBmvaJx6qkJn6+QedPhf 0hA930l7tezx3aRmgJlQyMSZCzSWamzGuO1OuxP9rmfgzwmLT4uiA8Dhrhw3+CGx2CSY JJrw== 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:to:from:dkim-signature:arc-authentication-results; bh=1GTayTy8nk5BwNQrcIcRPKQ1G24jirQNjNDNfrtuUDA=; b=xMnlbSCeJNlmk56Qbh0+MjH3KYje8Rm5Ac+VJiGMFVLJXshtoaLRThCGxk0GuUPIlY ORJbOFOn9MssWHKqb4FCiy2Dc9QBdJ4eppKMND2ZECz4BznNHqg7//BetGpHfrOXYUl+ C6C7GNd0/zaiHMFWhIq72JmIk2DbCdWAKIQ92sd/tq4x2wWC8hyK/neiTAdTizv6Jb4r MiQcFdvGKofkspE7bD5IN5DiK8L+cer/WQEqrNc/662MFPS/wttKmImkeVHUnH/EbiRo VfxgX1i6XRyqgrRhyRqKADjbLEil1Imst1WFqEeKjhGp49lGUBHQpdDoERPhpvy/0IJr 1Qjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.co.uk header.s=amazon201209 header.b=LtpVXQqj; 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.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y128si12123515pgb.55.2018.01.21.01.52.25; Sun, 21 Jan 2018 01:52:39 -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.co.uk header.s=amazon201209 header.b=LtpVXQqj; 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.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751379AbeAUJvI (ORCPT + 99 others); Sun, 21 Jan 2018 04:51:08 -0500 Received: from smtp-fw-9101.amazon.com ([207.171.184.25]:57009 "EHLO smtp-fw-9101.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751355AbeAUJvG (ORCPT ); Sun, 21 Jan 2018 04:51:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.uk; i=@amazon.co.uk; q=dns/txt; s=amazon201209; t=1516528266; x=1548064266; h=from:to:subject:date:message-id:in-reply-to:references; bh=1GTayTy8nk5BwNQrcIcRPKQ1G24jirQNjNDNfrtuUDA=; b=LtpVXQqjOjwCQDg1K+16uXCSZoLlwx2apSRnR72vwLFRxfN7Udp0g+UR u8UD8rBWoWA3SPrWDS6XydUUR/Ie2FaztVI2qOd3wibFpOz0mJGAsO16v j1bcdyDRFLUzLFu8VCMj7KNqpa+mTFzRT7ZiGjGIdO7lIaBzbM8uq/2xU Y=; X-IronPort-AV: E=Sophos;i="5.46,390,1511827200"; d="scan'208";a="720512084" Received: from sea3-co-svc-lb6-vlan3.sea.amazon.com (HELO email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com) ([10.47.22.38]) by smtp-border-fw-out-9101.sea19.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 21 Jan 2018 09:49:40 +0000 Received: from uc8d3ff76b9bc5848a9cc.ant.amazon.com (pdx2-ws-svc-lb17-vlan3.amazon.com [10.247.140.70]) by email-inbound-relay-2b-c7131dcf.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w0L9nRtX101164 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 21 Jan 2018 09:49:29 GMT Received: from uc8d3ff76b9bc5848a9cc.ant.amazon.com (localhost [127.0.0.1]) by uc8d3ff76b9bc5848a9cc.ant.amazon.com (8.15.2/8.15.2/Debian-3) with ESMTP id w0L9nQ2O010317; Sun, 21 Jan 2018 09:49:26 GMT Received: (from dwmw@localhost) by uc8d3ff76b9bc5848a9cc.ant.amazon.com (8.15.2/8.15.2/Submit) id w0L9nQSO010315; Sun, 21 Jan 2018 09:49:26 GMT From: David Woodhouse To: arjan@linux.intel.com, tglx@linutronix.de, karahmed@amazon.de, x86@kernel.org, linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com, bp@alien8.de, peterz@infradead.org, pbonzini@redhat.com, ak@linux.intel.com, torvalds@linux-foundation.org, gregkh@linux-foundation.org Subject: [PATCH v2 7/8] x86/speculation: Use Indirect Branch Prediction Barrier in context switch Date: Sun, 21 Jan 2018 09:49:08 +0000 Message-Id: <1516528149-9370-8-git-send-email-dwmw@amazon.co.uk> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516528149-9370-1-git-send-email-dwmw@amazon.co.uk> References: <1516528149-9370-1-git-send-email-dwmw@amazon.co.uk> 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