From owner-freebsd-mips@FreeBSD.ORG Mon Jan 10 06:18:36 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE1A21065672 for ; Mon, 10 Jan 2011 06:18:36 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 4ADBC8FC08 for ; Mon, 10 Jan 2011 06:18:35 +0000 (UTC) Received: by wyf19 with SMTP id 19so19470711wyf.13 for ; Sun, 09 Jan 2011 22:18:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=6JoDllc+smzxzN5apLYnT+HkJDcI8XO7fUdb39jY+Pc=; b=wRfRl3UFz6cBMOWIwg0Lh9zRkGyyzFA7Gtjhhxcrz8mpurOtwjo3m9RqyjFgkdm9F8 ddRU2hHZQufHzivp4yJYFML3rLFOJKMeAcCzR6U0GIzRbTR4JqnTn5/tyJLuitYraTUF WMyIjI3MEL9SiovRN7lSz+g98q3lVix+jtdvM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=d7CT9sRcTMyBiBtictrwisSUemRk890U7/UPNPbVfudGz7+D8MWQA1hZ7PO5lpVch3 4NZInFHZK7PpIjXIXy3g2Lg3XqLS/XRRVuqQNLpb8JvLfsKhwdpuKx0dXKuADjIemUsn L0MqsdlA2xMh1AfVrhMOIm/m5S2jOCWQRWf1Y= MIME-Version: 1.0 Received: by 10.227.144.12 with SMTP id x12mr18099734wbu.102.1294640315098; Sun, 09 Jan 2011 22:18:35 -0800 (PST) Received: by 10.227.156.3 with HTTP; Sun, 9 Jan 2011 22:18:34 -0800 (PST) In-Reply-To: References: <4D1A1B83.5070602@bsdimp.com> <4D1A5142.5090205@bsdimp.com> Date: Mon, 10 Jan 2011 11:48:34 +0530 Message-ID: From: "Jayachandran C." To: Robert Millan Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-mips@freebsd.org Subject: Re: [PATCH] Retrieval of TLS pointer via RDHWR X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 10 Jan 2011 06:18:36 -0000 On Sun, Jan 2, 2011 at 1:09 PM, Jayachandran C. wrote: > On Fri, Dec 31, 2010 at 8:36 PM, Robert Millan wrote: >> 2010/12/28 Warner Losh : >>> I reviewed the patch, and I liked it. =A0Couldn't find anything wrong w= ith it >>> when I first looked at it. =A0Would be nice if things were more flexibl= e, but >>> since generalizing from a sample size of one can be hard, I totally agr= ee. >> >> Great. =A0So will someone commit this? :-) > > I will look at committing this. > > BTW, The netlogic(RMI) contributed code had a different implementation > for this. The User Reserved Instruction exception had a fast path for > RDHWR which used k0/k1 and returned the value without taking the full > trap. =A0 I hadn't looked at adding that either (mostly because I did > not see an immediate requirement). > > Another emulation missing in the kernel is for floating point... Finally got some time to test and commit this patch. Looking thru the patch again, I have a couple of comments: | case T_RES_INST + T_USER: |- log_illegal_instruction("RES_INST", trapframe); |- i =3D SIGILL; |- addr =3D trapframe->pc; |+ { |+ register_t inst =3D *((register_t *) trapframe->pc); fuword32() should be used here, since it is fetching the value from userspa= ce. |+ switch (MIPS_INST_OPCODE(inst)) { |+ case OP_SPECIAL3: |+ switch (MIPS_INST_FUNC(inst)) { |+ case OP_RDHWR: |+ /* Register 29 used for TLS */ |+ if (MIPS_INST_RD(inst) =3D=3D 29) { |+ ((register_t *) trapframe)[MIPS_INST_RT(inst)] =3D td->td_md.md_tls= ; |+ trapframe->pc +=3D sizeof(int); This will mis-behave if the rdhwr is in a branch delay slot. You should either signal 'SIGILL' in this case or do an emulate branch (if the rdhwr is can be used in a branch delay slot). |+ goto out; |+ } |+ break; |+ } |+ break; |+ } |+ log_illegal_instruction("RES_INST", trapframe); |+ i =3D SIGILL; |+ addr =3D trapframe->pc; |+ } Sorry for the delay, JC.