Skip to content

Commit d23fa87

Browse files
committed
Merge branch 'for-next/stacktrace' into for-next/core
Remove synthetic frame record from exception stack when entering from userspace. * for-next/stacktrace: arm64: remove EL0 exception frame record
2 parents 82a1c2b + 6106e11 commit d23fa87

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

‎arch/arm64/kernel/entry.S‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,16 @@ alternative_else_nop_endif
261261
stp lr, x21, [sp, #S_LR]
262262

263263
/*
264-
* In order to be able to dump the contents of struct pt_regs at the
265-
* time the exception was taken (in case we attempt to walk the call
266-
* stack later), chain it together with the stack frames.
264+
* For exceptions from EL0, terminate the callchain here.
265+
* For exceptions from EL1, create a synthetic frame record so the
266+
* interrupted code shows up in the backtrace.
267267
*/
268268
.if \el == 0
269-
stp xzr, xzr, [sp, #S_STACKFRAME]
269+
mov x29, xzr
270270
.else
271271
stp x29, x22, [sp, #S_STACKFRAME]
272-
.endif
273272
add x29, sp, #S_STACKFRAME
273+
.endif
274274

275275
#ifdef CONFIG_ARM64_SW_TTBR0_PAN
276276
alternative_if_not ARM64_HAS_PAN

‎arch/arm64/kernel/stacktrace.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
4444
unsigned long fp = frame->fp;
4545
struct stack_info info;
4646

47+
/* Terminal record; nothing to unwind */
48+
if (!fp)
49+
return -EINVAL;
50+
4751
if (fp & 0xf)
4852
return -EINVAL;
4953

@@ -104,15 +108,6 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
104108

105109
frame->pc = ptrauth_strip_insn_pac(frame->pc);
106110

107-
/*
108-
* Frames created upon entry from EL0 have NULL FP and PC values, so
109-
* don't bother reporting these. Frames created by __noreturn functions
110-
* might have a valid FP even if PC is bogus, so only terminate where
111-
* both are NULL.
112-
*/
113-
if (!frame->fp && !frame->pc)
114-
return -EINVAL;
115-
116111
return 0;
117112
}
118113
NOKPROBE_SYMBOL(unwind_frame);

0 commit comments

Comments
 (0)