From owner-svn-src-head@freebsd.org Mon Feb 5 18:10:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DB39CEE2ECF; Mon, 5 Feb 2018 18:10:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 889C080BD0; Mon, 5 Feb 2018 18:10:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7E0964565; Mon, 5 Feb 2018 18:10:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w15IASlr083555; Mon, 5 Feb 2018 18:10:28 GMT (envelope-from jhb@FreeBSD.org) Received: (from jhb@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w15IASQX083554; Mon, 5 Feb 2018 18:10:28 GMT (envelope-from jhb@FreeBSD.org) Message-Id: <201802051810.w15IASQX083554@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jhb set sender to jhb@FreeBSD.org using -f From: John Baldwin Date: Mon, 5 Feb 2018 18:10:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328893 - head/lib/libc/mips/gen X-SVN-Group: head X-SVN-Commit-Author: jhb X-SVN-Commit-Paths: head/lib/libc/mips/gen X-SVN-Commit-Revision: 328893 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Feb 2018 18:10:29 -0000 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