From 5f6135c0f95d15b1c777491a369c01d2ade837e7 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Sun, 6 Dec 2020 01:37:12 -0600 Subject: [PATCH] m68k: fixups for makecontext --- arch/m68k/makecontext.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/m68k/makecontext.c b/arch/m68k/makecontext.c index 39cae2c..716a3e5 100644 --- a/arch/m68k/makecontext.c +++ b/arch/m68k/makecontext.c @@ -32,12 +32,14 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) /* set up and align the stack. */ sp = (greg_t *) ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - sp -= (argc + 1); + sp -= (argc + 2); sp = (greg_t *) (((uintptr_t) sp & ~0x3)); /* set up the ucontext structure */ ucp->uc_mcontext.gregs[REG_SP] = (greg_t) sp; ucp->uc_mcontext.gregs[REG_A6] = 0; + ucp->uc_mcontext.gregs[REG_D7] = argc; + ucp->uc_mcontext.gregs[REG_PC] = (greg_t) func; /* return address */ *sp++ = (greg_t) __start_context; @@ -49,6 +51,9 @@ __makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) *sp++ = va_arg (va, greg_t); va_end(va); + + /* link pointer */ + *sp++ = (greg_t) ucp->uc_link; }