Date: Mon, 10 Jan 2011 11:48:34 +0530 From: "Jayachandran C." <c.jayachandran@gmail.com> To: Robert Millan <rmh@debian.org> Cc: freebsd-mips@freebsd.org Subject: Re: [PATCH] Retrieval of TLS pointer via RDHWR Message-ID: <AANLkTi=n3zdHbDAypFqBtqSd_sr-mReXMjDzwQ9s5e3D@mail.gmail.com> In-Reply-To: <AANLkTinF4QWRWfZi_B3b=6RriD1k90j0qTiPcD9cvO6H@mail.gmail.com> References: <AANLkTimg3CUk0p8YPyepiumEHvKo2F6jdVA0=1CefYrQ@mail.gmail.com> <AANLkTikxHUj%2BGe3YyJOWMQne31D=uY_712Qveq=Dmh2A@mail.gmail.com> <AANLkTimyqAWFo5Ddd8_UAL654iGquCMnEjFETUnsFdxO@mail.gmail.com> <AANLkTi=nyXw3Tw-BnhAMwob4yP0-TSxeh5f_wEjtEfQ9@mail.gmail.com> <4D1A1B83.5070602@bsdimp.com> <AANLkTim1eqsA9xzPM9H48-3%2B1DKdDpUxrEE=YQ%2Bv-Vdh@mail.gmail.com> <AANLkTi=zjYMG-9P-EoxJjCz=ibUiXESbqLAq_D=e-X%2BN@mail.gmail.com> <4D1A5142.5090205@bsdimp.com> <AANLkTi=vNvPHw_gaKYkKRwTAvkNrLDbx%2BDC_3y9pUH-U@mail.gmail.com> <AANLkTinF4QWRWfZi_B3b=6RriD1k90j0qTiPcD9cvO6H@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Jan 2, 2011 at 1:09 PM, Jayachandran C.
<c.jayachandran@gmail.com> wrote:
> On Fri, Dec 31, 2010 at 8:36 PM, Robert Millan <rmh@debian.org> wrote:
>> 2010/12/28 Warner Losh <imp@bsdimp.com>:
>>> 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTi=n3zdHbDAypFqBtqSd_sr-mReXMjDzwQ9s5e3D>
