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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3DF43C433F5 for ; Mon, 15 Nov 2021 08:48:59 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0EBD963213 for ; Mon, 15 Nov 2021 08:48:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0EBD963213 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=cm6ZLldXorDIaphhphdPykie5rBEYUrWDaKOcCF7ga0=; b=jFsqYJaBW7H/e3 bNWP8IC47QOdys6nOBOPqFHdxfF4vw07usjmflxvnGKIqOHZBOo+sfUHacCyy60ZUwgiJGCWQM3l4 BUUEvQBH9TvaWhO5c2L8SxNw8+MKgAj3bkgsQLZhejrfI+n27dkjqL2PnXm0B0aY5UgcvI2pajWmP PR+fmbBreofL2ZaKZFhJuavOF93cFRGyLu67jZleyxy7H/9cZz8/960/Lh/EUcqZDJq7gO8fE5/li MLFiX8ufRYot/jQp6Uhl9OHonKKiP/0J+M11FaMqAMFX5J5NMS8gElIv966Pn+u6XPQRYT78+91tb 7ZSrDv+iIbZYI6P/XoBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmXeS-00Ej5O-24; Mon, 15 Nov 2021 08:47:44 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mmXeO-00Ej4k-7I for linux-arm-kernel@lists.infradead.org; Mon, 15 Nov 2021 08:47:41 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E012760273; Mon, 15 Nov 2021 08:47:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636966059; bh=ojuwtiUSNp0TyYwgwvhQKEnFNOW/ejEcDu7CxazSLwc=; h=From:To:Cc:Subject:Date:From; b=CroMvZu5/EWb1GV164J6jUHTEc08sajxPYwhQDm5E7p7xYZv9vu/THuXVVbQV5X6J x2m/+owHp8mJN1zrLjGA4xzv/uF/Jx+qLCGDDycWmdK0Q8r1Ik7pzHtMMWRvt/W3hL U0tbOwfuK9xqOx5x3TJA0R9X/wluNvyJ8MK56Em8Y3s7YuXXf7+kuf/JAOwgIZKiJy HWrU9ygbbruGZKffON5aYlWK66jujwj0uzhzth1cWxxtmb+wua1sIxec6tRKi8YBxk oOkUJwDz6JbBD2hM8tJhHXsmP0VJnybzxU765+Uu8ugIkdWNm+Wy+NA3bVlBWnYMXr k0tq5/ohlUYvQ== From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: Ard Biesheuvel , Russell King , Arnd Bergmann , Kees Cook , Keith Packard , Linus Walleij , Nick Desaulniers , Nicolas Pitre Subject: [PATCH v4 0/9] ARM: add support for IRQ stacks Date: Mon, 15 Nov 2021 09:47:23 +0100 Message-Id: <20211115084732.3704393-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=4831; h=from:subject; bh=ojuwtiUSNp0TyYwgwvhQKEnFNOW/ejEcDu7CxazSLwc=; b=owEB7QES/pANAwAKAcNPIjmS2Y8kAcsmYgBhkh6SAMZdAiNb08Z5cPl66hky26ndIegLkK8/8Gei NspsM6yJAbMEAAEKAB0WIQT72WJ8QGnJQhU3VynDTyI5ktmPJAUCYZIekgAKCRDDTyI5ktmPJKtpC/ 9YwxgchL1gGrrGnvJdZ62HVFUXCtt4ax4WKoycic25PSwylCfWZOMEl9ue1zJ3SaSB9PPiS9bgX2aW mySiL8DGIZ0tkW8T5qCR8amM2CPVZrqOdZrSmZTjwv3C9GocY0d8e7V6BuHpeXfVW9K4pC6WcYMqUy YQqd+q75slZwgVFfzwGo8hJV3dUFi2JBg+MsDyXYnULT9GFrynoUZIUmPpaLhXAeAyd8VgNciaIByH q5OKkAon3EzWbwfrSC0fP5amiz1abWjrN2NBPm8FY7EAz/HOu0K6vpA8jCc8agrE47ctzIYxO2EyKx GJVpAjMCk4NuKZsXXSkwAH7wjrFkP2T3gap2J1qGBGlAGMxivRoiuBrYLekSB/3T/QElVZmljFPnbF M2kiYxMcf/QEztol/7KqqmPGTrlp9wz7FTImYQmpkXfQj9c2eXFrgOI+6vrmWKFRZJRiU+HJ4+VfVN BIK6NzYPH4VhWQVze4zMem31LgxgIln8iI4Xnu85xvk38= 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-20211115_004740_323250_720E1DA9 X-CRM114-Status: GOOD ( 22.84 ) 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 Compared to user space, the kernel's task stacks are tiny and inflexible, as we don't grow them dynamically using demand paging. This is the reason we tend to obsess about functions with disproportionately large stack frames, given that it is hard to predict statically how calls to those functions may combine at runtime, and exhaust the stack and crash the kernel. This becomes even less predictable when taking interrupt handling into account, as their handlers are normally executed on the stack of the task that was interrupted, regardless of how deep its call stack was at the time of the interruption. To decouple these, and reduce the risk of hitting a pathological worst case where IRQ handling and the task below it happen to exhaust the available stack space when combined, we can switch to a different stack when taking interrupts, similar to how this is done already on some other architectures. This series implements this approach for ARM. Note that a good chunk of the changes below are related to supporting non-contiguous call stacks, which is also relevant in the context of vmap'ed stacks, which use a separate overflow stack to handle stack overflows. The changes preserve all functionality related to walking the call stack and dumping exception stacks and register contents. Changes since v3: - rebase onto v5.16-rc1 - dropped patch abstracting the call to (*handle_arch_irq)() from entry.S, which is no longer needed due to cross-arch rework that landed during the merge window - add some acks from Nick Changes since v2: - improve Clang support, by emitting code that is compatible with its frame pointer unwinder if that is the unwinder being used; - add acks from Arnd and Linus (thanks!) Changes since v1: - drop the first bugfix patch, which has been queued as a fix in the meantime; - preserve/restore FP in the irq_handler entry code; - add missing include to arch/arm/kernel/irq.c to silence warnings about missing prototypes. Patch #1 removes some code that I spotted that is no longer used. Patch #2 introduces a macro that will be used later in the series to emit the optimal indirect call sequence for older and newer cores. Patch #3 updates the unwind info based unwinder so it can deal with call stacks that are non-contiguous. Patch #4 exports dump_mem() to other compilation units so the ARM unwinder can call it directly. This is needed by the next patch. Patch #5 refactors the ARM unwinder to dump the exception stack from a context where it is able to figure out if it lives on the current stack or on the task stack. Patch #6 fixes an issue in the Clang frame pointer unwinder, which may get into an endless recursive fault if any of the stack frames have a bogus value for the link register. Patch #7 implements the actual IRQ stacks support, by allocating one for each CPU, and adding the code to switch to it in the IRQ entry path. It also contains some related changes to allow the frame pointer based unwinder to deal with the new situation. Patch #8 modifies call_with_stack() so both the frame pointer unwinder as well as the ARM unwinder know how to deal with it. Patch #9 adds the IRQ stack switching for softIRQ handling initiated from task context. Cc: Russell King Cc: Arnd Bergmann Cc: Kees Cook Cc: Keith Packard Cc: Linus Walleij Cc: Nick Desaulniers Cc: Nicolas Pitre Ard Biesheuvel (9): ARM: remove some dead code ARM: assembler: introduce bl_r macro ARM: unwind: support unwinding across multiple stacks ARM: export dump_mem() to other objects ARM: unwind: dump exception stack from calling frame ARM: backtrace-clang: avoid crash on bogus frame pointer ARM: implement IRQ stacks ARM: call_with_stack: add unwind support ARM: run softirqs on the per-CPU IRQ stack arch/arm/Kconfig | 6 +++ arch/arm/include/asm/assembler.h | 19 +++++++ arch/arm/include/asm/entry-macro-multi.S | 24 --------- arch/arm/include/asm/smp.h | 5 -- arch/arm/include/asm/stacktrace.h | 12 +++++ arch/arm/kernel/entry-armv.S | 54 ++++++++++++++++++-- arch/arm/kernel/irq.c | 37 ++++++++++++++ arch/arm/kernel/smp.c | 5 -- arch/arm/kernel/traps.c | 25 ++++++--- arch/arm/kernel/unwind.c | 33 ++++++++---- arch/arm/lib/backtrace-clang.S | 14 +++-- arch/arm/lib/backtrace.S | 8 +++ arch/arm/lib/call_with_stack.S | 33 +++++++++--- 13 files changed, 211 insertions(+), 64 deletions(-) -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel