From patchwork Mon May 22 08:03:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13249976 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 0D6A9C77B73 for ; Mon, 22 May 2023 08:03:57 +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=Bbv1wOs5O+b97KKqU8WBuqJLb7uOpXXkDDRnLnCmrl8=; b=UD2D24PohBcu1s UgyfLIe4hnO7EOLBhHwkbv6WtXUA1rx8hhWjBrMv6CYEHksg/ZKkM7SrYYF8ZXzBLpQruTxOhOsTd 41klfdL77+ptN/2OIGNNwCnl7j9+9m1erVDiLfUZkz+uGJHlYauHSiHIJhdExitup2vn40TyAB+za 5ZpLcWuVkTpidju9d1v3ke6WyzPZBpYWthZReNTwKrCHf/zfxWwLZHgrRgtgFeH0ZGzIgy3Sx3MnW QbukNIcMG87BQCo4lTFEW//rPq/dDucrefjO5HgcD1rKRJuly50p3h09tvCAECAWg8NXnp2lUKmyD j46f2mpdzW8muy4ck0lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q10Vt-005hsH-1M; Mon, 22 May 2023 08:03:29 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q10Vp-005hrC-0C for linux-arm-kernel@lists.infradead.org; Mon, 22 May 2023 08:03:27 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 5B9A6612CE; Mon, 22 May 2023 08:03:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 036FCC433D2; Mon, 22 May 2023 08:03:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684742602; bh=w48g4N7BDUWucyOYNWPs3Fk0EvRk+RJEzDnfoPXIPVs=; h=From:To:Cc:Subject:Date:From; b=TJRkL97jnw+XInWPZcnPA2euReA876hBJhpICLSVGMDmYrPohvKdIUKM52XwqnEcL BIfGbavfoMfey39dbVPn8AdLNvvaGFiDwcV3KzrWPTmHfNrvtj2DpXf2A8XsTBAn+2 QllFr19CWJE3iaTBu88YQVgVxJNfcVjA/E92T0kCKmCDRnYZCrvpuiaSvx0Ozt57ZQ 3ZJgspc+WoSm4kHQmjyC7G+Exg+0jHrUSFUF/byeVW6GJacycTmUGuOf2MjW5fmrjw GFgeR5YnJ1pNpnOr9RSbHtJQ3hN6Bhphg4PpHy+728sDxVxcbUeVqinb9j6mZzV2I/ f3w3Rol6817gA== From: Ard Biesheuvel To: linux+pull@armlinux.org.uk Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Linus Walleij , Arnd Bergmann , Sebastian Andrzej Siewior Subject: [GIT PULL] ARM: convert VFP exception handling to C code Date: Mon, 22 May 2023 10:03:10 +0200 Message-Id: <20230522080310.502250-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=4134; i=ardb@kernel.org; h=from:subject; bh=w48g4N7BDUWucyOYNWPs3Fk0EvRk+RJEzDnfoPXIPVs=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JISVbcV/6zxdHU1qWv7y2c0O0kFRwQozts2kBIp3q4rs5z DZ8rk3oKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABMpvsLwV/KG3tm1p2e+k4uY Eqlnqf8ptFRpw5xZLo/PZy/0P28bOYHhf9b5esdQrw0eBfpcW84zp9x59ig+QcBMSrs4K2oRZ0w NBwA= 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-20230522_010325_574784_246956CB X-CRM114-Status: GOOD ( 19.91 ) 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 Hello Russell, This pull request covers the outstanding changes related to VFP exception handling that I implemented on top of the VFP-in-softirq policy change and subsequent fixes. The code changes are identical to the v2 series [0]. With these changes applied, only FPE related undef exceptions are dispatched in the old way. Everything else is handled using undef hooks, with all logic implemented in C. I have tested this on a variety of platforms, including Cortex-A8 (using kernel mode NEON) and the original Raspberry Pi (which relies on VFP bouncing), as well as a host of platforms used in KernelCI [1]. All encountered issues have been fixed. One notable configuration that I have not been able to test is FPE, as it implies a OABI user space, which I don't have access to. Please pull. The following changes since commit f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6: Linux 6.4-rc2 (2023-05-14 12:51:40 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git tags/arm-vfp-refactor-for-rmk for you to fetch changes up to 47ba5f39eab3c2a9a1ba878159a6050f2bbfc0e2: ARM: entry: Make asm coproc dispatch code NWFPE only (2023-05-17 15:08:22 +0200) [0] https://lore.kernel.org/all/20230517212808.3895190-1-ardb@kernel.org/ [1] https://linux.kernelci.org/test/job/ardb/branch/for-kernelci/kernel/arm-vfp-refactor-for-rmk/ Cc: Linus Walleij Cc: Arnd Bergmann Cc: Sebastian Andrzej Siewior ---------------------------------------------------------------- Refactor VFP support code and reimplement in C The VFP related changes to permit kernel mode NEON in softirq context resulted in some issues regarding en/disabling of sofirqs from asm code, and this made it clear that it would be better to handle more of it from C code. Given that we already have infrastructure that associates undefined instruction exceptions with handler code based on value/mask pairs, we can easily move the dispatch of VFP and NEON instructions to C code once we reimplement the actual VFP support routine (which reasons about how to deal with the exception and whether any emulation is needed) in C code first. With those out of the way, we can drop the partial decoding logic in asm that reasons about which ISA is being used by user space, as the remaining cases are all 32-bit ARM only. This leaves a FPE specific routine with some iWMMXT logic that is easily duplicated in C as well, allowing us to move the FPE asm code into the FPE asm source file, and out of the shared entry code. ---------------------------------------------------------------- Ard Biesheuvel (8): ARM: vfp: Record VFP bounces as perf emulation faults ARM: vfp: Remove workaround for Feroceon CPUs ARM: vfp: Reimplement VFP exception entry in C code ARM: kernel: Get rid of thread_info::used_cp[] array ARM: vfp: Use undef hook for handling VFP exceptions ARM: entry: Disregard Thumb undef exception in coproc dispatch ARM: iwmmxt: Use undef hook to enable coprocessor for task ARM: entry: Make asm coproc dispatch code NWFPE only arch/arm/include/asm/thread_info.h | 17 ++- arch/arm/kernel/asm-offsets.c | 1 - arch/arm/kernel/entry-armv.S | 254 ++----------------------------------- arch/arm/kernel/iwmmxt.S | 18 ++- arch/arm/kernel/pj4-cp0.c | 1 + arch/arm/kernel/process.c | 1 - arch/arm/kernel/ptrace.c | 2 - arch/arm/kernel/xscale-cp0.c | 1 + arch/arm/mm/proc-feroceon.S | 4 + arch/arm/nwfpe/entry.S | 77 +++++++++++ arch/arm/vfp/Makefile | 2 +- arch/arm/vfp/entry.S | 31 ----- arch/arm/vfp/vfp.h | 1 + arch/arm/vfp/vfphw.S | 208 ++---------------------------- arch/arm/vfp/vfpmodule.c | 208 +++++++++++++++++++++--------- 15 files changed, 286 insertions(+), 540 deletions(-) delete mode 100644 arch/arm/vfp/entry.S