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 X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 49367C4363A for ; Mon, 12 Oct 2020 17:32:52 +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 EF8A72087D for ; Mon, 12 Oct 2020 17:32:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MJX0IMwF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="DzVna1Vi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF8A72087D 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:References:In-Reply-To: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:List-Owner; bh=R02pyLrZivQ3fwJOs4Cd5U4cuUqHaYthHXKCfcXQlkg=; b=MJX0IMwFR5VpHJtmzCw81NCHS eM30wIZ3ySH34sPG3cvHZV99zKnLJUy+DocW6qlJSGE/nRljJDlwiA5ACzoz4csRekGyOoVgdEBeR cFVaPUGkbwVMYkjlqhprelokU/8Tl7EW7flAN0keD6vFYPKB9JWpwpqvm1z5AuLlclp9v/HW0P8s7 s7EBFNDOOK7jZqVTfDb0qo2v8fyM6BAV3CACxyS1d9qxu3piyWV76RIbxVwVhQBH8I+UYW6FpYh7y BnFd6BhJOikOdPNonq+7m1+UHmwrExBfkVenIhdQB4KhkLdnMCqubIbVIffddibzKv06jL5dYbUeF 0kXdVJwlw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kS1fN-0006pd-Vc; Mon, 12 Oct 2020 17:31:22 +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 1kS1fK-0006ot-Ng for linux-arm-kernel@lists.infradead.org; Mon, 12 Oct 2020 17:31:19 +0000 Received: from localhost (fw-tnat.cambridge.arm.com [217.140.96.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A472220797; Mon, 12 Oct 2020 17:31:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602523878; bh=NvO760fCqKp/YsTZF4JF/KO5MadTfKCGTUdXkqb2E+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DzVna1Vi64Jxis4If0jSE8EiqRWIG1koZ6bnj8bPRC2fN2uNq0ehtlw7BOfku6Am2 FMHvXZ/vrNjfRb4AIhptKusGRZHaCdQh7V4AKs9n5xiVrNQF3qBOE1xlSF/3AAF2Rm iVc5Dcv/r5d32i/Hku9/vpA3NXXjzMNpOD90UMmk= From: Mark Brown To: Catalin Marinas , Will Deacon Subject: [RFC PATCH 1/3] arm64: remove EL0 exception frame record Date: Mon, 12 Oct 2020 18:26:03 +0100 Message-Id: <20201012172605.10715-2-broonie@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201012172605.10715-1-broonie@kernel.org> References: <20201012172605.10715-1-broonie@kernel.org> MIME-Version: 1.0 X-Patch-Hashes: v=1; h=sha256; g=5ea5931dcd2d869a2c202aa906e96d56ad600e4a; i=9RyHxczcN/Q2BzFPoIC4X5kkKAQ4aP4RN1g/1OnLHSo=; m=22ST2oJw8Ep9pdPG5pycTXu5SeBMboZPrk8GhxkU/tg=; p=yeHPL8AXfzSUHcNK9ndsLKY8jiroxZYJuVL8+8GrsAY= X-Patch-Sig: m=pgp; i=mark.rutland@arm.com; s=0xC3F436CA30F5D8EB; b=iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAl+EkSgACgkQJNaLcl1Uh9DpbAf7BTw ksrtiWuaRus3gMvYOt8I0HCbzdSlist68HRr39JYV78d/i7/9g0P64e8v+WNJAPjc+rr+dg+I8Z2Z 65HSpiXbFk1+RWtQ99nuusnyVYjBYuhjs9rP3AQ+BgdU2rUw2CQmyYQdD5q98pCRSJy14BMPGqKFb BnM6HdNt8mgJ2/Wx9FOlO5G3QZk+52JFtw1LIOQFs/fCO22e1ImRfkvBJ0qMQKMZUylhKAIMrYjWx tACm+Y2K8jlrfFtSUQVHwW29ER0SjXtWyOyRBW4kY2KXdyLbDXO4OT+WWLb8MHlz/hpM4I51ov/8O zcCg3HWj73B2/k9NZ6aMQAF8FGXQTKw== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201012_133118_921201_6A4B5D1F X-CRM114-Status: GOOD ( 22.29 ) 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 , Miroslav Benes , 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 --- 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 55af8b504b65..f7220e9c8520 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -202,16 +202,16 @@ alternative_cb_end 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