From 64259ab494a5e119e0ce923a011c49da20021e8f Mon Sep 17 00:00:00 2001 From: Zou Cao Date: Fri, 6 Mar 2020 10:54:56 +0800 Subject: [PATCH 0788/2944] alinux: arm64: use __kernel_text_address to replace kthread_return_to_user We don't need to use kthread_return_to_user to tell unwind it is kernel thread, we can use __kernel_text_address, it is a normal way in other arch like x86/ppc. Signed-off-by: Zou Cao Acked-by: Caspar Zhang --- arch/arm64/kernel/entry.S | 6 ++---- arch/arm64/kernel/stacktrace.c | 17 ++++------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 23488ca..5f80038 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -1064,17 +1064,15 @@ ENTRY(cpu_switch_to) ENDPROC(cpu_switch_to) NOKPROBE(cpu_switch_to) - .global kthread_return_to_user /* * This is how we return from a fork. */ ENTRY(ret_from_fork) bl schedule_tail - cbz x19, kthread_return_to_user // not a kernel thread + cbz x19, 1f // not a kernel thread mov x0, x20 blr x19 -kthread_return_to_user: - get_thread_info tsk +1: get_thread_info tsk b ret_to_user ENDPROC(ret_from_fork) NOKPROBE(ret_from_fork) diff --git a/arch/arm64/kernel/stacktrace.c b/arch/arm64/kernel/stacktrace.c index 0174069..eb80c3d 100644 --- a/arch/arm64/kernel/stacktrace.c +++ b/arch/arm64/kernel/stacktrace.c @@ -42,9 +42,6 @@ * add sp, sp, #0x10 */ -/* The bottom of kernel thread stacks points there */ -extern void *kthread_return_to_user; - /* * unwind_frame -- unwind a single stack frame. * Returns 0 when there are more frames to go. @@ -86,19 +83,13 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame) #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ /* - * kthreads created via copy_thread() (called from kthread_create()) - * will have a zero BP and a return value into ret_from_fork. - */ - if (!frame->fp && frame->pc == (unsigned long)&kthread_return_to_user) - return 1; - - /* * 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. + * might have a valid FP even if PC is bogus, so terminate where + * both are NULL, check the kthread stack, it also has a zero BP */ - if (!frame->fp && !frame->pc) + if (!frame->fp && (!frame->pc || + __kernel_text_address(frame->pc))) return 1; return 0; -- 1.8.3.1