From b9bd4045fb34f060d6cf37fc7da7ab13b91462de Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Fri, 5 Apr 2019 13:35:00 -0500 Subject: [PATCH] ppc32/64: fix back chain pointer The ABI states that sp[0] should point to the previous stack frame, or be zero if there is no previous stack frame. makecontext previously set this slot to point to the __start_context function, rather than to a valid stack frame. --- arch/ppc/makecontext.c | 2 +- arch/ppc64/makecontext.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ppc/makecontext.c b/arch/ppc/makecontext.c index 1b9efdf..729f465 100644 --- a/arch/ppc/makecontext.c +++ b/arch/ppc/makecontext.c @@ -44,7 +44,7 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) ucp->uc_mcontext.gregs[REG_R31] = (uintptr_t) ucp->uc_link; ucp->uc_mcontext.gregs[REG_SP] = (uintptr_t) sp; - sp[0] = (uintptr_t) &__start_context; + sp[0] = 0; sp[uc_link] = (uintptr_t) ucp->uc_link; argp = &sp[2]; diff --git a/arch/ppc64/makecontext.c b/arch/ppc64/makecontext.c index 9d6b998..91fb579 100644 --- a/arch/ppc64/makecontext.c +++ b/arch/ppc64/makecontext.c @@ -45,7 +45,7 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) ucp->uc_mcontext.gp_regs[REG_ENTRY] = (uintptr_t) func; ucp->uc_mcontext.gp_regs[REG_R31] = (uintptr_t) ucp->uc_link; - sp[0] = (uintptr_t) &__start_context; + sp[0] = 0; sp[uc_link] = (uintptr_t) ucp->uc_link; argp = &sp[2];