From patchwork Thu Mar 16 08:20:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13177171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 26A13C6FD19 for ; Thu, 16 Mar 2023 08:21:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UbcArv01dMNyziROop+WehQtsSnBXE9bPU5JcBdoE/k=; b=w8Q3rXdVOu4f8X Kz0GMpdj6BWYv5S4/KkHBU3Xx/pIVOsVlrOnrPbszT+gabZnfut1d6Z1zITVb90sWkMc5G6+u6Yz8 +sqIjd+KXHS4t8WdCYZbSGMpvbXLxwyNHOh3RUwVKFo5wRivcWb2CN1YoUfnVYZlfWX1rJIbRoMCd ux9E+2VEIjFjMtBSheUkMosQ/pZ2mv9F6rYkxu0c7QUFgG9J+XgQyA2oxmQC5DtVgdiQSLp/gxwoE uLjw+O3oTJGX3z8xESYM/b6iazSnqzpFNE0zDRjMGR4fZeSwf5KPZcEmHNej4aL3vaFc5JZ3RJx/z jG8aocB+olIapDH4x66A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pciqd-00Fdu9-0h; Thu, 16 Mar 2023 08:20:31 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pciqV-00FdpK-33 for linux-arm-kernel@lists.infradead.org; Thu, 16 Mar 2023 08:20:25 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 96FD6B82042; Thu, 16 Mar 2023 08:20:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E40FC433A0; Thu, 16 Mar 2023 08:20:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678954821; bh=ApwpSuQ/0LynuxzoaJbNQOuNWmQBjXXMoHzayRWE/TI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=opCHFJVO4EZqeomRSDS24Tk4pwQVg8s9HMZZsqx+ilxQjk6eN2EQWRw56Px5SVpDm zYn8V3RcO0FqWt6a8BpVK9Iowds/y4FrfJ4abCtp9MXa7zMueOJuz09N5IyUsQNr1j fwePeJGOvQtb0m5Ugi3QmWdftnm0fbdnEvnw7sD4L3QbJWYgK2+uaG7VmGWRHQrWA5 FNfF/F2MT42cuOCCGXJx4FW7Wy883q3rwsqpAjEihueZ11OkOstF7f/v5g8GWwE6nI gGFIbz1sPTOlVAr2qMopyBVlp7NYKju84155tEzn47quYAOfdCr3pceO8rK4yUyRdY aH1cdhzqOtodw== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk Cc: Ard Biesheuvel , Frederic Weisbecker , Guenter Roeck , Peter Zijlstra , Linus Walleij , Arnd Bergmann Subject: [PATCH v3 1/4] ARM: vfp: Pass thread_info pointer to vfp_support_entry Date: Thu, 16 Mar 2023 09:20:04 +0100 Message-Id: <20230316082007.652669-2-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230316082007.652669-1-ardb@kernel.org> References: <20230316082007.652669-1-ardb@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2469; i=ardb@kernel.org; h=from:subject; bh=ApwpSuQ/0LynuxzoaJbNQOuNWmQBjXXMoHzayRWE/TI=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIUXoou7bJWKK6zP0VUKy1vNZSBpPiWC4I2Vr4WZtsjj4Y //222IdpSwMYhwMsmKKLAKz/77beXqiVK3zLFmYOaxMIEMYuDgFYCKvLzEyfOQxN3uSfuDen7nv i79a311Qejd6vdjDvrD1sr9LhCRbYxgZFnP+Oh1XfKT2T9ee811SaxzDfxu7P/lZt3+NhpR+yL8 TTAA= X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230316_012024_280875_C50F264C X-CRM114-Status: GOOD ( 15.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Instead of dereferencing thread_info in do_vfp, pass the thread_info pointer to vfp_support_entry via R1. That way, we only use a single caller save register, which makes it easier to convert do_vfp to C code in a subsequent patch. Note that, unlike the CPU number, which can change due to preemption, passing the thread_info pointer can safely be done with preemption enabled. Signed-off-by: Ard Biesheuvel Reviewed-by: Linus Walleij Tested-by: Guenter Roeck --- arch/arm/vfp/entry.S | 5 +---- arch/arm/vfp/vfphw.S | 10 +++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S index 9a89264cdcc0b46e..cfedc2a3dbd68f1c 100644 --- a/arch/arm/vfp/entry.S +++ b/arch/arm/vfp/entry.S @@ -22,15 +22,12 @@ @ IRQs enabled. @ ENTRY(do_vfp) - local_bh_disable r10, r4 + mov r1, r10 ldr r4, .LCvfp - ldr r11, [r10, #TI_CPU] @ CPU number - add r10, r10, #TI_VFPSTATE @ r10 = workspace ldr pc, [r4] @ call VFP entry point ENDPROC(do_vfp) ENTRY(vfp_null_entry) - local_bh_enable_ti r10, r4 ret lr ENDPROC(vfp_null_entry) diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S index 26c4f61ecfa39638..6d056d810e4868c2 100644 --- a/arch/arm/vfp/vfphw.S +++ b/arch/arm/vfp/vfphw.S @@ -6,9 +6,9 @@ * Written by Deep Blue Solutions Limited. * * This code is called from the kernel's undefined instruction trap. + * r1 holds the thread_info pointer * r9 holds the return address for successful handling. * lr holds the return address for unrecognised instructions. - * r10 points at the start of the private FP workspace in the thread structure * sp points to a struct pt_regs (as defined in include/asm/proc/ptrace.h) */ #include @@ -69,13 +69,17 @@ @ VFP hardware support entry point. @ @ r0 = instruction opcode (32-bit ARM or two 16-bit Thumb) +@ r1 = thread_info pointer @ r2 = PC value to resume execution after successful emulation @ r9 = normal "successful" return address -@ r10 = vfp_state union -@ r11 = CPU number @ lr = unrecognised instruction return address @ IRQs enabled. ENTRY(vfp_support_entry) + local_bh_disable r1, r4 + + ldr r11, [r1, #TI_CPU] @ CPU number + add r10, r1, #TI_VFPSTATE @ r10 = workspace + DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10 .fpu vfpv2