From a00a05ce2950ca3b306f8ccc3e817ea8cd675015 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Fri, 5 Apr 2019 14:03:47 -0500 Subject: [PATCH] ppc64: fix incorrect position of parameters within stack frame On PPC64, there are 4 register-sized stack slots below the parameter save area, which is different from the 2 stack slots on PPC32. --- arch/ppc64/makecontext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/ppc64/makecontext.c b/arch/ppc64/makecontext.c index ea980e9..a4c1bf9 100644 --- a/arch/ppc64/makecontext.c +++ b/arch/ppc64/makecontext.c @@ -35,7 +35,7 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) stack_args = argc > 8 ? argc : 0; sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - sp -= stack_args + 2; + sp -= stack_args + 4; sp = (greg_t *) (((uintptr_t) sp & -16L)); ucp->uc_mcontext.gp_regs[REG_NIP] = (uintptr_t) func; @@ -52,7 +52,7 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) if (i < 8) ucp->uc_mcontext.gp_regs[i + 3] = va_arg (va, greg_t); else - sp[i + 2] = va_arg (va, greg_t); + sp[i + 4] = va_arg (va, greg_t); } va_end(va);