andi t0, t0, _TIF_SYSCALL_WORK
        bnez t0, handle_syscall_trace_exit
 
-ret_from_exception:
+SYM_CODE_START_NOALIGN(ret_from_exception)
        REG_L s0, PT_STATUS(sp)
        csrc CSR_STATUS, SR_IE
 #ifdef CONFIG_TRACE_IRQFLAGS
        andi s0, s0, SR_SPP
 #endif
        bnez s0, resume_kernel
+SYM_CODE_END(ret_from_exception)
 
 resume_userspace:
        /* Interrupts must be disabled here so flags are checked atomically */
 
 
 #ifdef CONFIG_FRAME_POINTER
 
+extern asmlinkage void ret_from_exception(void);
+
 void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
                             bool (*fn)(void *, unsigned long), void *arg)
 {
                        fp = frame->fp;
                        pc = ftrace_graph_ret_addr(current, NULL, frame->ra,
                                                   &frame->ra);
+                       if (pc == (unsigned long)ret_from_exception) {
+                               if (unlikely(!__kernel_text_address(pc) || !fn(arg, pc)))
+                                       break;
+
+                               pc = ((struct pt_regs *)sp)->epc;
+                               fp = ((struct pt_regs *)sp)->s0;
+                       }
                }
 
        }