From: Mark Brown <broonie@kernel.org>
To: Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
Mark Brown <broonie@kernel.org>, Miroslav Benes <mbenes@suse.cz>,
linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/3] arm64: remove EL0 exception frame record
Date: Mon, 12 Oct 2020 18:26:03 +0100 [thread overview]
Message-ID: <20201012172605.10715-2-broonie@kernel.org> (raw)
In-Reply-To: <20201012172605.10715-1-broonie@kernel.org>
From: Mark Rutland <mark.rutland@arm.com>
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 <broonie@kernel.org>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
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
next prev parent reply other threads:[~2020-10-12 17:32 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 17:26 [RFC PATCH 0/3] arm64: Implement reliable stack trace Mark Brown
2020-10-12 17:26 ` Mark Brown [this message]
2020-10-12 17:26 ` [RFC PATCH 2/3] arm64: stacktrace: Report when we reach the end of the stack Mark Brown
2020-10-13 11:07 ` Mark Rutland
2020-10-12 17:26 ` [RFC PATCH 3/3] arm64: stacktrace: Implement reliable stacktrace Mark Brown
2020-10-13 10:42 ` Mark Brown
2020-10-13 11:42 ` Mark Rutland
2020-10-13 16:12 ` Mark Brown
2020-10-15 13:33 ` Miroslav Benes
2020-10-15 15:57 ` Mark Brown
2020-10-16 10:13 ` Miroslav Benes
2020-10-16 12:30 ` Mark Brown
2020-10-15 13:39 ` [RFC PATCH 0/3] arm64: Implement reliable stack trace Miroslav Benes
2020-10-15 14:16 ` Mark Rutland
2020-10-15 15:49 ` Mark Brown
2020-10-15 21:29 ` Josh Poimboeuf
2020-10-15 21:29 ` Josh Poimboeuf
2020-10-16 11:14 ` Mark Rutland
2020-10-16 11:14 ` Mark Rutland
2020-10-20 10:03 ` Mark Rutland
2020-10-20 10:03 ` Mark Rutland
2020-10-20 15:58 ` Josh Poimboeuf
2020-10-20 15:58 ` Josh Poimboeuf
2020-10-16 12:15 ` Mark Brown
2020-10-16 12:15 ` Mark Brown
2020-10-19 23:41 ` Josh Poimboeuf
2020-10-19 23:41 ` Josh Poimboeuf
2020-10-20 15:39 ` Mark Brown
2020-10-20 15:39 ` Mark Brown
2020-10-20 16:28 ` Josh Poimboeuf
2020-10-20 16:28 ` Josh Poimboeuf
2021-01-27 14:02 ` Madhavan T. Venkataraman
2021-01-27 16:40 ` Mark Rutland
2021-01-27 17:11 ` Mark Brown
2021-01-27 17:24 ` Madhavan T. Venkataraman
2021-01-27 19:54 ` Madhavan T. Venkataraman
2021-01-28 14:22 ` Mark Brown
2021-01-28 15:26 ` Josh Poimboeuf
2021-01-29 21:39 ` Madhavan T. Venkataraman
2021-02-01 3:20 ` Madhavan T. Venkataraman
2021-02-01 14:39 ` Mark Brown
2021-01-30 4:38 ` Madhavan T. Venkataraman
2021-02-01 15:21 ` Madhavan T. Venkataraman
2021-02-01 15:46 ` Madhavan T. Venkataraman
2021-02-01 16:02 ` Mark Rutland
2021-02-01 16:22 ` Mark Brown
2021-02-01 21:40 ` Madhavan T. Venkataraman
2021-02-01 21:38 ` Madhavan T. Venkataraman
2021-02-01 23:00 ` Josh Poimboeuf
2021-02-02 2:29 ` Madhavan T. Venkataraman
2021-02-02 3:36 ` Josh Poimboeuf
2021-02-02 10:05 ` Mark Rutland
2021-02-02 13:33 ` Madhavan T. Venkataraman
2021-02-02 13:35 ` Madhavan T. Venkataraman
2021-02-02 23:32 ` Madhavan T. Venkataraman
2021-02-03 16:53 ` Mark Rutland
2021-02-03 19:03 ` Madhavan T. Venkataraman
2021-02-05 2:36 ` Madhavan T. Venkataraman
2021-02-01 21:59 ` Madhavan T. Venkataraman
2021-02-02 13:36 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201012172605.10715-2-broonie@kernel.org \
--to=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=mbenes@suse.cz \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.