From patchwork Mon Jul 2 11:04:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 140737 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3857220ljj; Mon, 2 Jul 2018 04:07:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIXqKDeTlRUgvrekEQt56YgD0MQtY0bRLOMFuxSTMsDS0FgSGBpFOQX04kGzgG0tU4EvmJI X-Received: by 2002:a63:27c1:: with SMTP id n184-v6mr20685613pgn.29.1530529647119; Mon, 02 Jul 2018 04:07:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530529647; cv=none; d=google.com; s=arc-20160816; b=hIfmfcHw6Vw2NHMhaWBVdvl6ECFmwGsT4EZowRZCe9VVOhL/48jbuA6OCA8LxWwIte hwjB5SB9NgN4ye1xNIs2SaRH8oUeNQrHgga/9I7+u8aPTVaceL4+kmhqiHqfBE8adnBN D1gB5pSYbPq5aXVfL59J0xXn3iEc95wgFvBPYyf/1Ckg/pE+YP5K0WDN4lyIPbn36TYG YH2DQf1sHwpSHgBFxKMiPeiZ43FmOgeod8iGduNRsvvQEkA2xycmF2oyCNvgALlgqNBf OtHi1Dr6spuPmcyA1e7jd4HhwTRbq5MelV1xwDrCvmA0O3XAZAEpslx2MiFFBdNb2P2n 8Jzg== 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:arc-authentication-results; bh=TWrS2x9BEGelaAuf0VWaOjgvkGy/0PjLgtSFucQDHjY=; b=P/MmeuVj7/WgTK66JrZuOZD8GKuHDbm9fFzcZjGjWKmvoPcCkYogepEsn03WqXKnS1 8mZ99v9KAycE6Pv1m+ti5e/6TWKxf4EjEJuRVn5X/R2p3Y847A+1jx9abBZhwMdD6hnm JP1dP0Y++zu+XsxqsVvJhxkdaTI5WYmgaAgLjW17oznh1y0DCWVabp+puMPJhj8EUf+m bR3/MhrrK2w8iHPkK775b542cyeHtT7diyz4xmvlotspsJclgORVOdZlW3eLQcZ29Jkl WI+Gj+5WMzS2TbRJwutvnwc5JxqV7OeWzE9fjMUgnNNjI20vDpIhWnjYCwM82iYP89Fg 9KxA== 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 b3-v6si16683530pfa.333.2018.07.02.04.07.26; Mon, 02 Jul 2018 04:07:27 -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 S1030415AbeGBLFB (ORCPT + 31 others); Mon, 2 Jul 2018 07:05:01 -0400 Received: from foss.arm.com ([217.140.101.70]:57566 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030372AbeGBLEx (ORCPT ); Mon, 2 Jul 2018 07:04:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D6F581650; Mon, 2 Jul 2018 04:04:52 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C65983F5BA; Mon, 2 Jul 2018 04:04:50 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, will.deacon@arm.com Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, dave.martin@arm.com, hch@infradead.org, james.morse@arm.com, linux@dominikbrodowski.net, linux-fsdevel@vger.kernel.org, marc.zyngier@arm.com, mark.rutland@arm.com, viro@zeniv.linux.org.uk Subject: [PATCHv4 11/19] arm64: don't reload GPRs after apply_ssbd Date: Mon, 2 Jul 2018 12:04:07 +0100 Message-Id: <20180702110415.10465-12-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180702110415.10465-1-mark.rutland@arm.com> References: <20180702110415.10465-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that all of the syscall logic works on the saved pt_regs, apply_ssbd can safely corrupt x0-x3 in the entry paths, and we no longer need to restore them. So let's remove the logic doing so. With that logic gone, we can fold the branch target into the macro, so that callers need not deal with this. GAS provides \@, which provides a unique value per macro invocation, which we can use to create a unique label. Signed-off-by: Mark Rutland Acked-by: Marc Zyngier Acked-by: Catalin Marinas Cc: Will Deacon --- arch/arm64/kernel/entry.S | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) -- 2.11.0 diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index c41b84d06644..728bc7cc5bbb 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -130,20 +130,21 @@ alternative_else_nop_endif // This macro corrupts x0-x3. It is the caller's duty // to save/restore them if required. - .macro apply_ssbd, state, targ, tmp1, tmp2 + .macro apply_ssbd, state, tmp1, tmp2 #ifdef CONFIG_ARM64_SSBD alternative_cb arm64_enable_wa2_handling - b \targ + b skip_apply_ssbd\@ alternative_cb_end ldr_this_cpu \tmp2, arm64_ssbd_callback_required, \tmp1 - cbz \tmp2, \targ + cbz \tmp2, skip_apply_ssbd\@ ldr \tmp2, [tsk, #TSK_TI_FLAGS] - tbnz \tmp2, #TIF_SSBD, \targ + tbnz \tmp2, #TIF_SSBD, skip_apply_ssbd\@ mov w0, #ARM_SMCCC_ARCH_WORKAROUND_2 mov w1, #\state alternative_cb arm64_update_smccc_conduit nop // Patched to SMC/HVC #0 alternative_cb_end +skip_apply_ssbd\@: #endif .endm @@ -173,13 +174,7 @@ alternative_cb_end ldr x19, [tsk, #TSK_TI_FLAGS] // since we can unmask debug disable_step_tsk x19, x20 // exceptions when scheduling. - apply_ssbd 1, 1f, x22, x23 - -#ifdef CONFIG_ARM64_SSBD - ldp x0, x1, [sp, #16 * 0] - ldp x2, x3, [sp, #16 * 1] -#endif -1: + apply_ssbd 1, x22, x23 mov x29, xzr // fp pointed to user-space .else @@ -321,8 +316,7 @@ alternative_if ARM64_WORKAROUND_845719 alternative_else_nop_endif #endif 3: - apply_ssbd 0, 5f, x0, x1 -5: + apply_ssbd 0, x0, x1 .endif msr elr_el1, x21 // set up the return data