From patchwork Mon Mar 20 13:18:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13181220 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 B7515C7618A for ; Mon, 20 Mar 2023 13:19:50 +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=52yOLWUgMgU+hxBJXxra3F0+QW8QXZbWq7Nifjd4HOg=; b=dBimfzsSujxZpk Cdq6ou4l4Dt7hu42k2XiDFJQJpCwD3ByEi61KD6TwSP5NqGpmdnqWCD9EdYImMJrqVx5UUHG5Krl+ v0ojMr0x5VgGfirSv3wWtG6V9cybfecOibHNWb7xbSipNpJmJNj1ZBhhOPjOBPrSPqGBxF9esO/TL sNbdLeP6hOWRBUWCKeqIyWiJ797nOFP0Sc3beDf2KWyWxA+22MG5h0IiypjHsRo0wkYhBAgzQcN/k tzt/1u0f3W6dB4Rq0yaLNi3Q7uEFhKPvxPp8EhmkY7SAo8fpb+dfQD4C43PzWjQf9vYAPCFT+HIjj IHpd/1a6Lo9F143PoGuw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1peFPe-0095o4-1u; Mon, 20 Mar 2023 13:18:58 +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 1peFPb-0095kx-1l for linux-arm-kernel@lists.infradead.org; Mon, 20 Mar 2023 13:18:57 +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 E9513B80E60; Mon, 20 Mar 2023 13:18:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16DB1C433EF; Mon, 20 Mar 2023 13:18:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679318332; bh=0UcA3yHiXxZd7Bei4lFOUDki4+wZ/6c8COcUsg3SF+E=; h=From:To:Cc:Subject:Date:From; b=p2hRb5Xa6t88Dx+Ee6TxNJwVJ7gIvxFLpU34Rkk6/HY4kTFk1qeL3RhI47Ceami+R v6xNZoBo9jWif0Bt/1CCexkgQPvFIpKWSQIDP4YubnvgvX9CIXjOwF1iQGah2NnLsR wjtNC/SSC+MVAjuhNZ3RycII2Ot2LVUMA4R2HdxvY5l4VY5FIfViGQB5Fko5ljTWjE RfL5G8y5+oI6fDiaF3rqDJg0gq1qFNtfexLtuCkQ2xI8bGZSXdwYs+6749Cgbr9orY MlVcmwGDBlYX6+b+2FIzBBQbuVC/BTaYfD46T3VZvzl+gOa/0sRacT7pyrfxEqB1hd u+t/pF1ULKIUw== 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 v4 00/12] ARM: vfp: Switch to C API to en/disable softirqs Date: Mon, 20 Mar 2023 14:18:33 +0100 Message-Id: <20230320131845.3138015-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=4236; i=ardb@kernel.org; h=from:subject; bh=0UcA3yHiXxZd7Bei4lFOUDki4+wZ/6c8COcUsg3SF+E=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIUUiVvlW5p0b+y5ai/tIfbNqz9icsi5F0yHA1L7q3sWWn YJe61Q6SlkYxDgYZMUUWQRm/3238/REqVrnWbIwc1iZQIYwcHEKwESuqTD8D4g9zh1wZ/Wm9G2b pRfM8V6s8LLwQE7AmRjr7bnOflHMlxn+2cVfPXfhzcY8D4vPc//sn8zb/3629y+vVcoeHyMOqFg Y8wIA 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-20230320_061855_863731_27066750 X-CRM114-Status: GOOD ( 27.45 ) 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 v3: I got a bit carried away, as I noticed that the NEON opcode matching implemented in asm in entry-armv.S basically duplicates how undef hooks work, and so I have added a patch that drops the associated asm code and moves it into C code, reusing the existing VFP undef hook we have for kernel mode exceptions. (patch #9) With that removed, no Thumb mode undef exceptions remain that are dispatched by the coprocessor undef handling, so that can be simplified as well (patch #10) iWMMXT undef exceptions can be handled using an undef hook as well, (patch #11), which allows us to compile out the coprocessor dispatch entirely unless we have FPE enabled, which is only the case on OABI or OABI compat. This removes the non-standard calling convention which returns via register R9 on success, which can only be implemented in asm. (patch #12) Patch #4 is a fix for an issue that I spotted while working on this, patch #5 is an enhancement that makes it easier to keep track of how many VFP traps were taken for emulation purposes. The first four patches are fixes, the remaining ones might go into v6.4. This also fixes the !CONFIG_VFP build error spotted by Guenter. 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 (12): 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: entry: Fix iWMMXT TIF flag handling 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/assembler.h | 13 -- arch/arm/include/asm/thread_info.h | 17 +- arch/arm/kernel/asm-offsets.c | 1 - arch/arm/kernel/entry-armv.S | 138 +++----------- arch/arm/kernel/iwmmxt.S | 9 + 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/vfp/Makefile | 2 +- arch/arm/vfp/entry.S | 39 ---- arch/arm/vfp/vfp.h | 1 + arch/arm/vfp/vfphw.S | 200 ++------------------ arch/arm/vfp/vfpmodule.c | 195 ++++++++++++++----- 15 files changed, 219 insertions(+), 405 deletions(-) delete mode 100644 arch/arm/vfp/entry.S