From mboxrd@z Thu Jan 1 00:00:00 1970 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 6D31CC433EF for ; Thu, 10 Mar 2022 16:26:08 +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=KFSYb5JH6uUMbOHvlTGcmHsJ0o7s/Le5zngWCnyOnjw=; b=K4JjjirTFQZs7K BB793m/IvnSWdoxVIo7Mp1JbbuYkRxv//Rz+S5HA+NeLeooH084BFf58WcoouJOwho/7AJDdenyBw XCxzV6fSo3xJlnNQ+zVtkRALvrkcCd+dvRZhdezaMTUPe8yRo7x8dKdOfKjfajwGVJmAy0/PHwTJ6 3ZvtQCVGSN77mP8mRb+9gYXA1N/ZwUHMR3qEMtiUa54yMGEqPy6If4ystAu5L/hbO+8tCNYk8e4QO 1YezhJW9cEm52qkFZuVCbejEgAC0Q20hCo8h1k8aN2ZEn7coGpfNCM4LlV8ofcFnAYOv6wZ9A0IPo 70RsprLK0FCzw094ding==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSLb3-00DVWB-BU; Thu, 10 Mar 2022 16:25:01 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSLay-00DVV1-FE for linux-arm-kernel@lists.infradead.org; Thu, 10 Mar 2022 16:24:59 +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 0EA99B82567; Thu, 10 Mar 2022 16:24:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB85AC340E8; Thu, 10 Mar 2022 16:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646929493; bh=iHdK5k8GeVpwNZ4wniaKIbpakvRMbMzLRoFlF5nCNcc=; h=From:To:Cc:Subject:Date:From; b=kw9V4ydHN7vCT/Y/nbpY7OtiHphVKeeWizNT1zZIqlLkWCjAtYAQ2pePD3Ws50o8y J22lDgOsIfXvETnBAJ3kD/4EbdkhVwzpATZntCXfQR4EOk3JhJOWNkHcOsN9Ro64va ZDCY+wsPa485i8B1VbXDHJ6I99wCfeIpMzlQ7g+NXj8Ts1OvPgc1twyJa8zLW63Bpq NVWrSoOpexE71Kxo4zyP+y2QE82wLpSPjK9mtZ5zPNSna47qeoLHrqrsToZKmhGk5d NJ8rRiyHIdn6EUMSgmu0mzFFT1BS+p3W91rH1Nh5cL71WvkadQ/BtnfgojKXpJcTDK NJpeML8tKqgdA== From: Ard Biesheuvel To: linux@armlinux.org.uk Cc: naresh.kamboju@linaro.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel Subject: [PATCH] ARM: entry: fix unwinder problems caused by IRQ stacks Date: Thu, 10 Mar 2022 17:24:45 +0100 Message-Id: <20220310162445.3080983-1-ardb@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3672; h=from:subject; bh=iHdK5k8GeVpwNZ4wniaKIbpakvRMbMzLRoFlF5nCNcc=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBiKiZM79RAHJbmNXnOUr7YxMhgdnAq466e0H0UxNrL iI0rVy6JAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYiomTAAKCRDDTyI5ktmPJFfYC/ 9DxiXOmp42eIuxYP53Dh8CBS0RysJ6OMFdiorwKCiR+e+rKXimNZme0j8aUO3F5qOcEcEHheFt95Aj 5P5Gn3yTlawHhkOVeux15r4Uq9gHlTQkjfdB2aQkQ4JZmR5iYZ51CckBXjNqFXfTYglnhpDsV9XbjJ LSIAaD4T2HldSFZLDeW6YHt2OaQ/aep+lUd+13EEyJWCd4TGp6hqILj/VYnXL9JwCS+6qVtD+l1NUT nUL/UcT67u5LPQOLXDyMemjoq+nKbAhl1tc9Lg7++j6KGgXTAvYrenU51+erYCgckFMQTe7/DNYEEp mcHa04DHLva+4nrujp1OtSn2qHPgaFKmdOdzq1p4sLdZnyU4sv2rGjoWISBKr75ase/bztsLVCn3nu S78GhXyI1aAc6iku/raINVPnn0HEcyCp2b6uLvMwACYpYd9LT8beTcjhdG8+G2cEAayprKWhoX9R44 KukxGmfTPu74ZqyaRZ/uLqJ2jZsLOYyp9NKDqdrgSJQOA= 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-20220310_082456_836685_9A85EF7C X-CRM114-Status: GOOD ( 16.92 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The IRQ stacks series made some changes to the unwinder, to permit unwinding across different stacks. This is needed because otherwise, the call stack would terminate at the point where the stack switch between the task stack and the IRQ stack occurs, which would defeat any diagnostics that rely on timer interrupts, such as RCU stall detection. Unfortunately, getting the unwind annotations correct turns out to be difficult, given that this now involves a frame pointer which needs to point into the right location in the task stack when unwinding from the IRQ stack. Getting this wrong for an exception handling routine results in the stack pointer to be unwound from the wrong location, causing any subsequent unwind attempts to cause all kinds of issues, as reported by Naresh here [0]. So let's simplify this, by deferring the stack switch to call_with_stack(), which already has the correct unwind annotations, and removing all the complicated handling of the stack frame from the IRQ exception entrypoint itself. [0] https://lore.kernel.org/all/CA+G9fYtpy8VgK+ag6OsA9TDrwi5YGU4hu7GM8xwpO7v6LrCD4Q@mail.gmail.com/ Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/entry-armv.S | 57 +++++++++--------------------------- 1 file changed, 14 insertions(+), 43 deletions(-) diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 5609ca8ae46a..0ce9035e3ead 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -33,58 +33,29 @@ * Interrupt handling. */ .macro irq_handler, from_user:req - mov r0, sp -#ifdef CONFIG_IRQSTACKS -#ifdef CONFIG_UNWINDER_ARM - mov fpreg, sp @ Preserve original SP -#else - mov r7, fp @ Preserve original FP - mov r8, sp @ Preserve original SP -#endif - ldr_this_cpu sp, irq_stack_ptr, r2, r3 + mov r1, sp + ldr_this_cpu r2, irq_stack_ptr, r2, r3 .if \from_user == 0 -UNWIND( .setfp fpreg, sp ) @ @ If we took the interrupt while running in the kernel, we may already @ be using the IRQ stack, so revert to the original value in that case. @ - subs r2, sp, r0 @ SP above bottom of IRQ stack? - rsbscs r2, r2, #THREAD_SIZE @ ... and below the top? + subs r3, r2, r1 @ SP above bottom of IRQ stack? + rsbscs r3, r3, #THREAD_SIZE @ ... and below the top? #ifdef CONFIG_VMAP_STACK - ldr_va r2, high_memory, cc @ End of the linear region - cmpcc r2, r0 @ Stack pointer was below it? + ldr_va r3, high_memory, cc @ End of the linear region + cmpcc r3, r1 @ Stack pointer was below it? #endif - movcs sp, r0 @ If so, revert to incoming SP - -#ifndef CONFIG_UNWINDER_ARM - @ - @ Inform the frame pointer unwinder where the next frame lives - @ - movcc lr, pc @ Make LR point into .entry.text so - @ that we will get a dump of the - @ exception stack for this frame. -#ifdef CONFIG_CC_IS_GCC - movcc ip, r0 @ Store the old SP in the frame record. - stmdbcc sp!, {fp, ip, lr, pc} @ Push frame record - addcc fp, sp, #12 -#else - stmdbcc sp!, {fp, lr} @ Push frame record - movcc fp, sp -#endif // CONFIG_CC_IS_GCC -#endif // CONFIG_UNWINDER_ARM - .endif -#endif // CONFIG_IRQSTACKS - + bcc 0f @ If not, switch to the IRQ stack + mov r0, r1 bl generic_handle_arch_irq + b 1f +0: + .endif -#ifdef CONFIG_IRQSTACKS -#ifdef CONFIG_UNWINDER_ARM - mov sp, fpreg @ Restore original SP -#else - mov fp, r7 @ Restore original FP - mov sp, r8 @ Restore original SP -#endif // CONFIG_UNWINDER_ARM -#endif // CONFIG_IRQSTACKS + mov_l r0, generic_handle_arch_irq + bl call_with_stack +1: .endm .macro pabt_helper -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel