Skip to content

Commit 6895dfc

Browse files
npigginmpe
authored andcommitted
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: Nicholas Piggin <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6f291a0 commit 6895dfc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

arch/powerpc/kernel/process.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1757,12 +1757,13 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
17571757

17581758
/* Create initial stack frame. */
17591759
sp -= STACK_USER_INT_FRAME_SIZE;
1760-
((unsigned long *)sp)[0] = 0;
1760+
*(unsigned long *)(sp + STACK_INT_FRAME_MARKER) = STACK_FRAME_REGS_MARKER;
17611761

17621762
/* Copy registers */
17631763
childregs = (struct pt_regs *)(sp + STACK_INT_FRAME_REGS);
17641764
if (unlikely(args->fn)) {
17651765
/* kernel thread */
1766+
((unsigned long *)sp)[0] = 0;
17661767
memset(childregs, 0, sizeof(struct pt_regs));
17671768
childregs->gpr[1] = sp + STACK_USER_INT_FRAME_SIZE;
17681769
/* function */
@@ -1782,6 +1783,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
17821783
*childregs = *regs;
17831784
if (usp)
17841785
childregs->gpr[1] = usp;
1786+
((unsigned long *)sp)[0] = childregs->gpr[1];
17851787
p->thread.regs = childregs;
17861788
/* 64s sets this in ret_from_fork */
17871789
if (!IS_ENABLED(CONFIG_PPC_BOOK3S_64))

0 commit comments

Comments
 (0)