Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77253C433E0 for ; Wed, 13 Jan 2021 17:37:12 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 F3CE62313E for ; Wed, 13 Jan 2021 17:37:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F3CE62313E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject: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=vNTRdPD4ClgMxgIFgxPT8IvCql0ZT+e7wVg1SDQx58o=; b=D1kLQeJtdbdk9aHhtL/rA4w4Fv BLzKOw8qlOXidJil+COEs4jNW+CJ+lbgd9dAgWh2rK3S3LyZgAmLX5vlyBW8GV4RtBvhh4MC2WRT3 3L3Ca/BVbE9B5c8isr0Con97zMK5MGhPopdJ0j1jQGZk5V/sP5F2/0djCCCxn+Nz0OZZlqFHiWO2Q rDCX2FILjM3mFBqp04JxIo9JmR+Q0n76v3TMVRBylNwGQB2a950r9I3WTvjCKkD7P+eESNeVLWq0b v0X/g8kINTrvAkyWJ2ugDoNa/pYj+WuPhADElXnATn2BLF2A4ZyyiZ1edF+Ux3EUg/whFGLyHNOf0 hRhpIMvw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzk33-0003HJ-Tf; Wed, 13 Jan 2021 17:35:09 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kzk30-0003Gv-To for linux-arm-kernel@lists.infradead.org; Wed, 13 Jan 2021 17:35:08 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 47B092313C; Wed, 13 Jan 2021 17:35:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610559304; bh=G6sZphrudE6aWX8iB6HeIixZZEQ1NXywlbfyy1Yv1mQ=; h=From:To:Cc:Subject:Date:From; b=OBw28nV68Ti9tzeDc2velbMmB3AxWzJQy8CDDA0hL3OGe355BOYj/XCpNUXCWvWDv qxBgbLjaCpTpWPUdqdbHZio/j/HALJ5TyrVQdLHBKlteqshsHQKNUMKGdsOdNXwefW bAW7IsyZEfOUY377wY9LezVw6C2CgLCafd2uv4oDSIIBIZl7vpdOyAthGPgUWm25Cz q1KUwK1SSOFQVif7T0+GektFDurzbzOsU+wHd9tjhxkgiLPN57ApF9kqTKcyj0IBol 7CFGZ3VFiM7Plb/6tuWRB72i1pcV6x99Us6R+bdK4pSErITLqqQWexcQ4ps4Dgb9Bk sKq7Qv55UbxTQ== From: Mark Brown To: Catalin Marinas , Will Deacon Subject: [PATCH RESEND] arm64: remove EL0 exception frame record Date: Wed, 13 Jan 2021 17:31:55 +0000 Message-Id: <20210113173155.43063-1-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; i=9RyHxczcN/Q2BzFPoIC4X5kkKAQ4aP4RN1g/1OnLHSo=; m=22ST2oJw8Ep9pdPG5pycTXu5SeBMboZPrk8GhxkU/tg=; p=VDfag7Zev2nDbFzLe82640IGBsg10sGRT6KhLwIBZaw=; g=5ea5931dcd2d869a2c202aa906e96d56ad600e4a X-Patch-Sig: m=pgp; i=broonie@kernel.org; s=0xC3F436CA30F5D8EB; b=iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl//LdYACgkQJNaLcl1Uh9Chagf/W9R CUTQ7YsbZHrX1aVMFzAwqq9FgVS1IQvYm46rvIDXXkPe6YTDA5FOTf+i09S1S022iaOWRGHbAPRXU vv82MM4h4ufvhCqDLiGssps7jC75F6DawWCV0MyI8jClYHRIGSGIvkkmHNdAz4a1KZ6Q55vhimAzu 8NI8q+3pm9X75BRmsoH2k/Hcekk6+Sve6ioV8f504VqOomkU15IO/Lwbd7Kzaro123Qh9N6Sn5J8F IM6GTbBJI6ySPMtB+99yOqDhf7PbphPd5UpTUByZ5oNEI8H6LOTqKKsCUqUE2N8xBHbJU9HmO+Lhv AwGzIvH0jIT1x1kA36ZGIWkEva750Bg== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210113_123507_131032_5F1AF569 X-CRM114-Status: GOOD ( 19.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Mark Brown , linux-arm-kernel@lists.infradead.org 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 From: Mark Rutland When entering an exception from EL0, the entry code creates a synthetic frame record with a NULL PC. This was used by the code introduced in commit: 7326749801396105 ("arm64: unwind: reference pt_regs via embedded stack frame") ... to discover exception entries on the stack and dump the associated pt_regs. Since the NULL PC was undesirable for the stacktrace, we added a special case to unwind_frame() to prevent the NULL PC from being logged. Since commit: a25ffd3a6302a678 ("arm64: traps: Don't print stack or raw PC/LR values in backtraces") ... we no longer try to dump the pt_regs as part of a stacktrace, and hence no longer need the synthetic exception record. This patch removes the synthetic exception record and the associated special case in unwind_frame(). Instead, EL0 exceptions set the FP to NULL, as is the case for other terminal records (e.g. when a kernel thread starts). The synthetic record for exceptions from EL1 is retrained as this has useful unwind information for the interrupted context. To make the terminal case a bit clearer, an explicit check is added to the start of unwind_frame(). This would otherwise be caught implicitly by the on_accessible_stack() checks. Reported-by: Mark Brown Signed-off-by: Mark Rutland Signed-off-by: Mark Brown --- This was previously sent as part of a bigger series that I'm currently working on revising but seems to make sense from a documentation and clarity point independently. arch/arm64/kernel/entry.S | 10 +++++----- arch/arm64/kernel/stacktrace.c | 13 ++++--------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index a8c3e7aaca74..2db9804a9035 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -261,16 +261,16 @@ alternative_else_nop_endif stp lr, x21, [sp, #S_LR] /* - * In order to be able to dump the contents of struct pt_regs at the - * time the exception was taken (in case we attempt to walk the call - * stack later), chain it together with the stack frames. + * For exceptions from EL0, terminate the callchain here. + * For exceptions from EL1, create a synthetic frame record so the + * interrupted code shows up in the backtrace. */ .if \el == 0 - stp xzr, xzr, [sp, #S_STACKFRAME] + mov x29, xzr .else stp x29, x22, [sp, #S_STACKFRAME] - .endif add x29, sp, #S_STACKFRAME + .endif #ifdef CONFIG_ARM64_SW_TTBR0_PAN alternative_if_not ARM64_HAS_PAN diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index fa56af1a59c3..0fb42129b469 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -44,6 +44,10 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) unsigned long fp = frame->fp; struct stack_info info; + /* Terminal record; nothing to unwind */ + if (!fp) + return -EINVAL; + if (fp & 0xf) return -EINVAL; @@ -104,15 +108,6 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) frame->pc = ptrauth_strip_insn_pac(frame->pc); - /* - * Frames created upon entry from EL0 have NULL FP and PC values, so - * don't bother reporting these. Frames created by __noreturn functions - * might have a valid FP even if PC is bogus, so only terminate where - * both are NULL. - */ - if (!frame->fp && !frame->pc) - return -EINVAL; - return 0; } NOKPROBE_SYMBOL(unwind_frame); -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel