Date: Mon, 5 Feb 2018 18:10:28 +0000 (UTC) From: John Baldwin <jhb@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328893 - head/lib/libc/mips/gen Message-ID: <201802051810.w15IASQX083554@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jhb Date: Mon Feb 5 18:10:28 2018 New Revision: 328893 URL: https://svnweb.freebsd.org/changeset/base/328893 Log: Fix makecontext() on MIPS O32. The GP register can be clobbered by the callback, so save it in S1 while invoking the callback function. While here, add a comment expounding on the treatment of GP for the various ABIs and the assumptions made. Reviewed by: jmallett (earlier version) Sponsored by: DARPA / AFRL Differential Revision: https://reviews.freebsd.org/D14179 Modified: head/lib/libc/mips/gen/_ctx_start.S Modified: head/lib/libc/mips/gen/_ctx_start.S ============================================================================== --- head/lib/libc/mips/gen/_ctx_start.S Mon Feb 5 18:06:54 2018 (r328892) +++ head/lib/libc/mips/gen/_ctx_start.S Mon Feb 5 18:10:28 2018 (r328893) @@ -28,11 +28,25 @@ __FBSDID("$FreeBSD$"); /* - * XXX gp? + * This requires makecontext() to setup a valid GP for locating + * _ctx_done rather than deriving GP from T9 on entry. Currently this + * uses the GP inherited from getcontext() assuming that getcontext() + * is in the same shared object as _ctx_done(). For N32 and N64, GP + * is caller-save so will be preserved across the call to the callback + * function. For O32, GP is callee-save, so save it in a different + * caller-save register (S1) while invoking the callback. This is + * done instead of the usual SETUP_GP/SAVE_GP to avoid disturbing the + * stack frame setup by makecontext() for the callback function. */ ENTRY(_ctx_start) +#ifdef __mips_o32 + move s1, gp +#endif jalr t9 +#ifdef __mips_o32 + move gp, s1 +#endif move a0, s0 PTR_LA t9, _ctx_done jalr t9
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802051810.w15IASQX083554>