Date: Sat, 16 Nov 2019 20:33:46 +0000 (UTC) From: Brandon Bergren <bdragon@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r354780 - head/lib/libc/powerpc64/gen Message-ID: <201911162033.xAGKXkte018805@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bdragon Date: Sat Nov 16 20:33:46 2019 New Revision: 354780 URL: https://svnweb.freebsd.org/changeset/base/354780 Log: [PowerPC] Fix *context on ELFv2 Due to ELFv1 specific code in _ctx_start.S and makecontext.c, userspace context switching was completely broken on ELFv2. With this change, we now pass the libthr test suite. Approved by: jhibbits (mentor) Differential Revision: https://reviews.freebsd.org/D22421 Modified: head/lib/libc/powerpc64/gen/_ctx_start.S head/lib/libc/powerpc64/gen/makecontext.c Modified: head/lib/libc/powerpc64/gen/_ctx_start.S ============================================================================== --- head/lib/libc/powerpc64/gen/_ctx_start.S Sat Nov 16 19:12:17 2019 (r354779) +++ head/lib/libc/powerpc64/gen/_ctx_start.S Sat Nov 16 20:33:46 2019 (r354780) @@ -32,8 +32,14 @@ .globl CNAME(abort) ENTRY(_ctx_start) +#if !defined(_CALL_ELF) || _CALL_ELF == 1 + /* Load values from function descriptor */ ld %r2,8(%r14) ld %r14,0(%r14) +#else + /* Load global entry point */ + mr %r12,%r14 +#endif mtlr %r14 blrl /* branch to start function */ mr %r3,%r15 /* pass pointer to ucontext as argument */ Modified: head/lib/libc/powerpc64/gen/makecontext.c ============================================================================== --- head/lib/libc/powerpc64/gen/makecontext.c Sat Nov 16 19:12:17 2019 (r354779) +++ head/lib/libc/powerpc64/gen/makecontext.c Sat Nov 16 20:33:46 2019 (r354780) @@ -113,7 +113,12 @@ __makecontext(ucontext_t *ucp, void (*start)(void), in * Use caller-saved regs 14/15 to hold params that _ctx_start * will use to invoke the user-supplied func */ +#if !defined(_CALL_ELF) || _CALL_ELF == 1 + /* Cast to ensure this is treated as a function descriptor. */ mc->mc_srr0 = *(uintptr_t *)_ctx_start; +#else + mc->mc_srr0 = (uintptr_t) _ctx_start; +#endif mc->mc_gpr[1] = (uintptr_t) sp; /* new stack pointer */ mc->mc_gpr[14] = (uintptr_t) start; /* r14 <- start */ mc->mc_gpr[15] = (uintptr_t) ucp; /* r15 <- ucp */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201911162033.xAGKXkte018805>