From patchwork Thu Mar 16 08:20:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13177172 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 31B94C76196 for ; Thu, 16 Mar 2023 08:21:15 +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: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:In-Reply-To:References: List-Owner; bh=z4MI3zbxtOFcwhsGJF/r1aIhPiEYfQpMxS3yK1A0uv8=; b=Wv+bw9YTbHaIUT zgxv5FTJ7Ct1nKcd9vX7O9zDyCs92PeKxi7o6tY8Gg0BK/VC0tOHOE7PpvQ3AQVzZcA7844KnHn+U psY3AuTs6eXWb1TMFCZwP8/hFlk7/U4hIuOyPLWZXMmf5thk7LHuDodUdp9HyFHncXwUYOobg0U+s bcIucDzfxlPoYsN/CgQEAt+MidG2tiStMUGPdr+i/BE2NRyQ78kXfHzCNFl1N0QmBlkbVwC2+WTni 5hsc015XGc+N7rfEqSPDxDC7mAqgu2lR8Fur2PT/hgVdKKSVtTW/v1aM9R80A5kxo3eINABAzJxHq JoQ8ArjnOUPnCUYxsg1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pciqX-00Fdqm-19; Thu, 16 Mar 2023 08:20:25 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pciqT-00Fdoa-2Y for linux-arm-kernel@lists.infradead.org; Thu, 16 Mar 2023 08:20:23 +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 6F5D6B8203E; Thu, 16 Mar 2023 08:20:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87E8EC433D2; Thu, 16 Mar 2023 08:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1678954819; bh=vUTTqIm9mbOedDBAjZnNXQKHAQypYxkV6t0fkG/69p4=; h=From:To:Cc:Subject:Date:From; b=FI95uoCoKl/7SfYU8Cdh6mZk5NHZPLnb4gOkjiuZF8XB+rPsKE/502LZ5EQmDP3lG kmdtL9XOi19J3gx97Jl5PFPmY3MoybJr3Q3sCu37PyxW72cYa3mX3yG03LwtpGyU3l k6IySy+InAIzqygs5qEAkXDAVxNg70ZI+4cNUC5AzRiRrkTsox9wtgZJlc3NPcVVn+ dM/s6xfDHe0iR3UglOhl5+kna3tOK/Fye7rWQYtVnD8cFllNkj1guioo9hJ+9aSnCS c/iNx1Nld/+PvJlGSZ6DBoQZDIWPGICSEAn0Lc64EpJJbitya4wNZtBx40zelmCUUL urQoVpROlhKBg== 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 0/4] ARM: vfp: Switch to C API to en/disable softirqs Date: Thu, 16 Mar 2023 09:20:03 +0100 Message-Id: <20230316082007.652669-1-ardb@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2176; i=ardb@kernel.org; h=from:subject; bh=vUTTqIm9mbOedDBAjZnNXQKHAQypYxkV6t0fkG/69p4=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIUXook77xJiZydOf28acb3w0XfW40f3qkimdspGnvX/vv Hpq+tljHaUsDGIcDLJiiiwCs/++23l6olSt8yxZmDmsTCBDGLg4BWAi9y4y/HfSV7uy5yzD0eSo oPmemU/en9yRInrCUeb0l6gn059ZGkQwMmxbcGFOR5v2D7PtPX+cbia/eKyYdji5ZZ6GW2vN1G2 v17ICAA== 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_012022_109761_5D72E3DE X-CRM114-Status: GOOD ( 19.25 ) 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 As it turns out, enabling or disabling softirqs from asm code is more tricky than it looks. Simply bumping the associated bit in preempt_count does the trick for uninstrumented kernels, but with lockdep or preempt debug enabled, we really need to call the C versions, as replicating their behavior in asm fully is intractible. So let's rework the existing code a little bit so we can interpose a little C helper 'vfp_entry()' that disables softirqs before calling the existing vfpstate handling code in asm. Re-enabling softirqs from asm code is more straight-forward, as we can simply perform a tail call via a C routine that is guaranteed to be callable as a function. However, since calling these APIs from asm code is still not ideal, let's reimplement the whole thing in C (patch #4) Changes since v2: - add Rbs and Tbs from Linus and Guenter (thanks!) - correct reference to local_bh_enable() vs __local_bh_enable_ip() in commit log of patch #3 - add patch that reworks the asm VFP exception handling entirely so the bulk of it is implemented in C. This could be taken into v6.4, while the preceding patches are fixes for v6.3-rc Cc: Frederic Weisbecker Cc: Guenter Roeck Cc: Peter Zijlstra Cc: Linus Walleij Cc: Arnd Bergmann Link: https://lore.kernel.org/all/ZBBYCSZUJOWBg1s8@localhost.localdomain/ Ard Biesheuvel (4): ARM: vfp: Pass thread_info pointer to vfp_support_entry ARM: vfp: Pass successful return address via register R3 ARM: vfp: Fix broken softirq handling with instrumentation enabled ARM: vfp: Reimplement VFP exception entry in C code arch/arm/include/asm/assembler.h | 13 -- arch/arm/kernel/entry-armv.S | 12 ++ arch/arm/vfp/Makefile | 2 +- arch/arm/vfp/entry.S | 39 ---- arch/arm/vfp/vfp.h | 1 + arch/arm/vfp/vfphw.S | 198 ++------------------ arch/arm/vfp/vfpmodule.c | 125 +++++++++++- 7 files changed, 142 insertions(+), 248 deletions(-) delete mode 100644 arch/arm/vfp/entry.S