From patchwork Wed Jul 11 13:56:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 141750 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp321710ljj; Wed, 11 Jul 2018 06:57:51 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcIIHg5oXHhjg+vk7Ixtqp8pz46ZxEGGP4bdldcCHTo33pk5thr+ZJfox20N4XUFGpWEW55 X-Received: by 2002:a63:f:: with SMTP id 15-v6mr20642015pga.430.1531317471144; Wed, 11 Jul 2018 06:57:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531317471; cv=none; d=google.com; s=arc-20160816; b=WO2CYukU5Fkn0iF/ITc0xO92x/kKMTu4CkOV7rEOJ6xkmrjplMpDXF37sGI/eBqfdH vsF1cO/LKCWeLYcVLNU31JAWMwfBS71QLtvrIotykJExYPDgEAOqPEz5jqgbdO3/JegC zhSut3AT/OCeek00rDTIGE1LN00cNEB/1Xk5x/S/SGsy/bT60xfeueVI3ptGtmEoH4Tb tleLiCIVGtaHmc+29zUyh7/RbjGVnceHDbapZBWcXaVrwZ1Ox9g44kGjmZ8iaph52cF+ f8cLQ94xyjO4cNLSrPtMW0zl6d7SIfmhEktLaR+yWKutkrjMvjLgZidBfCIugKOw34ym HRYQ== 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=fP45ynOLSmMbZmSqYsXJEGfZGarwNPjFIW5eM4+kWVA=; b=i5YhVrikYx14Byiwu3SPX8dXiRqxOEePyWX1SHaE9NYnzXpHMORwfgUpBT05xP5tjV zHYPFLBhFDGA6uoPYTa/PYtwD0Or71/X5aLD6aIH0+9DukOPa9CpJcw7u/uhTsGoN7KZ ddfZP/aeDo/OxrX57huJ08O6lWkWGJWQPUTVnbOpsNwIFckeVjiPCAa4B5X829Vk66P2 q2yxXWpXtfbO92Z0sOOjBxvlAeIblWc6mIx2ysk6KD8FvSP0EAnOdjmoR4pJS3IsFnIr oO/Ri2mIoZDDCEYfXWYuSav2x3AEaEnD1IWk/y4w+0zipFtR2WznsWKKHuOq9OmApsZh aeSA== 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 92-v6si18680531pli.518.2018.07.11.06.57.50; Wed, 11 Jul 2018 06:57:51 -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 S2388521AbeGKOCQ (ORCPT + 23 others); Wed, 11 Jul 2018 10:02:16 -0400 Received: from foss.arm.com ([217.140.101.70]:36418 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388274AbeGKOCQ (ORCPT ); Wed, 11 Jul 2018 10:02:16 -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 2740C1BF7; Wed, 11 Jul 2018 06:57:48 -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 16E0C3F5B1; Wed, 11 Jul 2018 06:57:45 -0700 (PDT) From: Mark Rutland To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, will.deacon@arm.com Cc: 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: [PATCHv5 12/21] arm64: don't reload GPRs after apply_ssbd Date: Wed, 11 Jul 2018 14:56:47 +0100 Message-Id: <20180711135656.20670-13-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180711135656.20670-1-mark.rutland@arm.com> References: <20180711135656.20670-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..22b240da949b 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 .L__asm_ssbd_skip\@ alternative_cb_end ldr_this_cpu \tmp2, arm64_ssbd_callback_required, \tmp1 - cbz \tmp2, \targ + cbz \tmp2, .L__asm_ssbd_skip\@ ldr \tmp2, [tsk, #TSK_TI_FLAGS] - tbnz \tmp2, #TIF_SSBD, \targ + tbnz \tmp2, #TIF_SSBD, .L__asm_ssbd_skip\@ 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 +.L__asm_ssbd_skip\@: #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