Received: by 10.223.185.116 with SMTP id b49csp2244545wrg; Thu, 15 Feb 2018 08:39:53 -0800 (PST) X-Google-Smtp-Source: AH8x227rwFtFoDsjXHIKRpazg7zFmiimp2ZoW/OKiOXVMEHM+zOY8TcffuWOrdByxPOCThBBKckq X-Received: by 2002:a17:902:3064:: with SMTP id u91-v6mr3043090plb.421.1518712793348; Thu, 15 Feb 2018 08:39:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518712793; cv=none; d=google.com; s=arc-20160816; b=IXW4q3yUyXjeZ92IprDe8ceq7EeTD2ImNWoyowVqeKfpbArpy3hdQF4dovWFql8v13 1PXOAAUl/dbXy1Mhl7cYbjbap0gM4Uly9F1nG4ZUoBJZng7yGi1E92TtbXXmcjKsbrAg 6MBNdEMpBwUiD2WCdmxwJA9amhhBNbjXY3gFIF/YO0Qs7ZncsxIGFjVzQh7Ud3cHeC1O MFQnaXHXXZnJ85WuoWhN7Q32uaEVTtuM86PSLnupc8iNn869pHUfZHrUXYPDlmbyXOXf vQpviQz+GR2KJL/CcFjnNahVCKHgvREAYORko9y3ncHYnNzOf015TCfQhMFLW/+ueQ1c JwMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=RUPGn9dJTKuY0WdlLNGthuB2Bml3Y4vmmdZFj5V0hiM=; b=dG3pUijC8M/ZYzwe0ZQtkCxA569MLldsQhDvQj/YzPnODUxvlVL+s8Cp26UQ9ATJ19 y0Z0LdH4GB53wgzDOKiWrNeYGzSTMfjkUlqNXyEL3leqXhkHIfhIaadi+NvQGkIjvetM YElG+/8paA1CFvIOUmRA60wDTnBohqeVxwtY1x0LaFybodyFfvvm7qcUjvB5Ku/UMSxZ NWJ78EmY4qgj333LfinQ3LAXyFsGijnQCKSb+AHIcJip/vpl7E4s8wFTBw5VLPDiZBf6 smcPOTuXQq/gn6jS+uuqfzJYq+Gs8nn1GcDey4+4NIbFvs6npFMIQ0mKvDsGXMdEKrSL LdsA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u20si2331800pfk.416.2018.02.15.08.39.38; Thu, 15 Feb 2018 08:39:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423940AbeBOPl2 (ORCPT + 99 others); Thu, 15 Feb 2018 10:41:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:60590 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423903AbeBOPlY (ORCPT ); Thu, 15 Feb 2018 10:41:24 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3613BA59; Thu, 15 Feb 2018 15:41:24 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Marc Zyngier , Catalin Marinas Subject: [PATCH 4.15 064/202] [Variant 2/Spectre-v2] arm64: Move BP hardening to check_and_switch_context Date: Thu, 15 Feb 2018 16:16:04 +0100 Message-Id: <20180215151716.771905035@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marc Zyngier Commit a8e4c0a919ae upstream. We call arm64_apply_bp_hardening() from post_ttbr_update_workaround, which has the unexpected consequence of being triggered on every exception return to userspace when ARM64_SW_TTBR0_PAN is selected, even if no context switch actually occured. This is a bit suboptimal, and it would be more logical to only invalidate the branch predictor when we actually switch to a different mm. In order to solve this, move the call to arm64_apply_bp_hardening() into check_and_switch_context(), where we're guaranteed to pick a different mm context. Acked-by: Will Deacon Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/context.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c @@ -231,6 +231,9 @@ void check_and_switch_context(struct mm_ raw_spin_unlock_irqrestore(&cpu_asid_lock, flags); switch_mm_fastpath: + + arm64_apply_bp_hardening(); + /* * Defer TTBR0_EL1 setting for user threads to uaccess_enable() when * emulating PAN. @@ -246,8 +249,6 @@ asmlinkage void post_ttbr_update_workaro "ic iallu; dsb nsh; isb", ARM64_WORKAROUND_CAVIUM_27456, CONFIG_CAVIUM_ERRATUM_27456)); - - arm64_apply_bp_hardening(); } static int asids_init(void)