提交 6895dfc0 编写于 作者: N Nicholas Piggin 提交者: Michael Ellerman

powerpc: copy_thread fill in interrupt frame marker and back chain

Backtraces will not recognise the fork system call interrupt without
the regs marker. And regular interrupt entry from userspace creates
the back chain to the user stack, so do this for the initial fork
frame too, to be consistent.
Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20221127124942.1665522-13-npiggin@gmail.com
上级 6f291a03
...@@ -1757,12 +1757,13 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) ...@@ -1757,12 +1757,13 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
/* Create initial stack frame. */ /* Create initial stack frame. */
sp -= STACK_USER_INT_FRAME_SIZE; sp -= STACK_USER_INT_FRAME_SIZE;
((unsigned long *)sp)[0] = 0; *(unsigned long *)(sp + STACK_INT_FRAME_MARKER) = STACK_FRAME_REGS_MARKER;
/* Copy registers */ /* Copy registers */
childregs = (struct pt_regs *)(sp + STACK_INT_FRAME_REGS); childregs = (struct pt_regs *)(sp + STACK_INT_FRAME_REGS);
if (unlikely(args->fn)) { if (unlikely(args->fn)) {
/* kernel thread */ /* kernel thread */
((unsigned long *)sp)[0] = 0;
memset(childregs, 0, sizeof(struct pt_regs)); memset(childregs, 0, sizeof(struct pt_regs));
childregs->gpr[1] = sp + STACK_USER_INT_FRAME_SIZE; childregs->gpr[1] = sp + STACK_USER_INT_FRAME_SIZE;
/* function */ /* function */
...@@ -1782,6 +1783,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) ...@@ -1782,6 +1783,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
*childregs = *regs; *childregs = *regs;
if (usp) if (usp)
childregs->gpr[1] = usp; childregs->gpr[1] = usp;
((unsigned long *)sp)[0] = childregs->gpr[1];
p->thread.regs = childregs; p->thread.regs = childregs;
/* 64s sets this in ret_from_fork */ /* 64s sets this in ret_from_fork */
if (!IS_ENABLED(CONFIG_PPC_BOOK3S_64)) if (!IS_ENABLED(CONFIG_PPC_BOOK3S_64))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册