Received: by 10.192.165.156 with SMTP id m28csp248548imm; Tue, 17 Apr 2018 09:29:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+LqQKsp8Iz2AR/UNSh2TPYJNXjsG6C61zc0r6l/iJzwwyt0q78WznUu7I+5Hwzo1kMEW6Y X-Received: by 10.99.116.8 with SMTP id p8mr2296767pgc.327.1523982549348; Tue, 17 Apr 2018 09:29:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523982549; cv=none; d=google.com; s=arc-20160816; b=fY9fPXMi1mrJTcmIzjDnkw2+AGqwfMeIIh/pIYntfjutCr/zU2cebz/3NEju7xbHRC 24R6Gqd7zcvTPamj8l5t4hBx/Oxk172VSdw9/tfiJFjIjf73URjgtZ1Kb2p016WWokMx w9Zn7fHVXc2pWDr/M7VQpZinKepBvjBFIp1GS3fJ0JatFS85pXGSvVb9T7d2WJAkThQY E9N3MIhj9C4VYJsSoFOE3Yyy8hELajr2L+lY+TBisfyDhVZ9HUU3u/ROXwQXac87bxMy kW0RnV9fNjQvsFflC7ylwNgAoL+UbPeTBdbI0G3e6Y3mVKp8lbmcJXsckm+a5rRctUQO hLLQ== 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=vR/YClZjJYDgvLGiUXJfQ//dhNb9ZeEszSq4h+zIsU8=; b=oRZoI81XL0GD45KQ/Wf9bU6zt3l1jaILKYpoygR24jTGJaNFh0nahmNouNzIFrolZM QjnjmnZc9uyiPowdr5vpCTMNTH/azX/GUyqqHNvxgL402NBf7zb4PdVTCokBT7HaQ9ix L6dJEcUnoXRWVXMaOVQ/RxkFb181hCz1ZMdC0OZ0etO8dq5dvPfXDZH5kBPIcZSCtZwk N9peOoHZQNksvqdagkqLIwzq5lcUWDshDSrKGSSKayTzwqugVmREgWnCmcDM3WGvz/fI MmuYVU1e3fz1Zc9+8rOyXOtylue/OLdpLviTkzOOr5eegSN+q0NwIK47lqk7MCrpNfOw v4Gg== 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 j21si12000487pga.34.2018.04.17.09.28.54; Tue, 17 Apr 2018 09:29:09 -0700 (PDT) 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 S1755541AbeDQQI5 (ORCPT + 99 others); Tue, 17 Apr 2018 12:08:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35606 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755514AbeDQQIw (ORCPT ); Tue, 17 Apr 2018 12:08:52 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 159EAC98; Tue, 17 Apr 2018 16:08:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Will Deacon , Marc Zyngier , Catalin Marinas , Greg Hackmann , Mark Rutland Subject: [PATCH 4.9 26/66] arm64: Move BP hardening to check_and_switch_context Date: Tue, 17 Apr 2018 17:58:59 +0200 Message-Id: <20180417155647.000585170@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland From: Marc Zyngier commit a8e4c0a919ae310944ed2c9ace11cf3ccd8a609b 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: Mark Rutland [v4.9 backport] Tested-by: Greg Hackmann 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 @@ -230,6 +230,9 @@ void check_and_switch_context(struct mm_ raw_spin_unlock_irqrestore(&cpu_asid_lock, flags); switch_mm_fastpath: + + arm64_apply_bp_hardening(); + cpu_switch_mm(mm->pgd, mm); } @@ -240,8 +243,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)