From b500b054c7cf412a6042496afa08b4302f7ed929 Mon Sep 17 00:00:00 2001 From: Bobby Bingham Date: Fri, 5 Apr 2019 13:38:36 -0500 Subject: [PATCH] ppc32/64: don't store uc_link on the stack This was previously stored either in the CR (ppc64) or LR (ppc32) save area of the stack, or to one of the parameter save slots. In either case, the saved value was unused. This value is also passed to __start_context via r31, so there's no need to pass it on the stack. --- arch/ppc/makecontext.c | 6 ++---- arch/ppc64/makecontext.c | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/arch/ppc/makecontext.c b/arch/ppc/makecontext.c index 729f465..2b7ea67 100644 --- a/arch/ppc/makecontext.c +++ b/arch/ppc/makecontext.c @@ -30,13 +30,12 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) greg_t *sp, *argp; va_list va; int i; - unsigned int uc_link, stack_args; + unsigned int stack_args; stack_args = argc > 8 ? argc - 8 : 0; - uc_link = stack_args + 1; sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - sp -= (uc_link + 1); + sp -= stack_args + 2; sp = (greg_t *) ((uintptr_t) sp & -16L); ucp->uc_mcontext.gregs[REG_NIP] = (uintptr_t) func; @@ -45,7 +44,6 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) ucp->uc_mcontext.gregs[REG_SP] = (uintptr_t) sp; sp[0] = 0; - sp[uc_link] = (uintptr_t) ucp->uc_link; argp = &sp[2]; va_start(va, argc); diff --git a/arch/ppc64/makecontext.c b/arch/ppc64/makecontext.c index 91fb579..b060371 100644 --- a/arch/ppc64/makecontext.c +++ b/arch/ppc64/makecontext.c @@ -30,13 +30,12 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) greg_t *sp, *argp; va_list va; int i; - unsigned int uc_link, stack_args; + unsigned int stack_args; stack_args = argc > 8 ? argc - 8 : 0; - uc_link = stack_args + 1; sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - sp -= (uc_link + 1); + sp -= stack_args + 2; sp = (greg_t *) (((uintptr_t) sp & -16L)); ucp->uc_mcontext.gp_regs[REG_NIP] = (uintptr_t) func; @@ -46,7 +45,6 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) ucp->uc_mcontext.gp_regs[REG_R31] = (uintptr_t) ucp->uc_link; sp[0] = 0; - sp[uc_link] = (uintptr_t) ucp->uc_link; argp = &sp[2]; va_start(va, argc);