Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Feb 2012 22:33:25 +0000
From:      "Bjoern A. Zeeb" <bzeeb-lists@lists.zabbadoz.net>
To:        Oleksandr Tymoshenko <gonzo@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r231312 - in head/sys/mips: include mips
Message-ID:  <A74B52C1-36AD-4B7D-BA48-7787D1FF8699@lists.zabbadoz.net>
In-Reply-To: <201202092217.q19MHEuU039370@svn.freebsd.org>
References:  <201202092217.q19MHEuU039370@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On 9. Feb 2012, at 22:17 , Oleksandr Tymoshenko wrote:

> Author: gonzo
> Date: Thu Feb  9 22:17:13 2012
> New Revision: 231312
> URL: http://svn.freebsd.org/changeset/base/231312
>=20
> Log:
>  - Emulate RDHWR instruction for TLS support
>=20
>  Reading register $29 with RDHWR is becoming the de-facto standard to
>  implement TLS.  According to linux-mips wiki, MIPS Technologies has
>  reserved hardware register $29 for ABI use.  Furthermore current GCC
>  makes the following assumptions:
>  - RDHWR is natively available or otherwise emulated by the kernel
>  - Register $29 holds the TLS pointer
>=20
>  Submitted by:	Robert Millan <rmh@debian.org>

mips XLPN32 kernel failed, check _.mips.XLPN32 for details
mips XLRN32 kernel failed, check _.mips.XLRN32 for details

/scratch/tmp/bz/head.svn/sys/mips/mips/trap.c: In function 'trap':
/scratch/tmp/bz/head.svn/sys/mips/mips/trap.c:768: warning: cast to =
pointer from integer of different size [-Wint-to-pointer-cast]
/scratch/tmp/bz/head.svn/sys/mips/mips/trap.c:776: warning: cast from =
pointer to integer of different size [-Wpointer-to-int-cast]

>=20
> Modified:
>  head/sys/mips/include/mips_opcode.h
>  head/sys/mips/mips/trap.c
>=20
> Modified: head/sys/mips/include/mips_opcode.h
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- head/sys/mips/include/mips_opcode.h	Thu Feb  9 22:13:20 2012	=
(r231311)
> +++ head/sys/mips/include/mips_opcode.h	Thu Feb  9 22:17:13 2012	=
(r231312)
> @@ -176,6 +176,11 @@ typedef union {
> #define	OP_LDL		032
> #define	OP_LDR		033
>=20
> +#define OP_SPECIAL2	034
> +#define OP_JALX		035
> +
> +#define OP_SPECIAL3	037
> +
> #define	OP_LB		040
> #define	OP_LH		041
> #define	OP_LWL		042
> @@ -389,6 +394,11 @@ typedef union {
> #define	OP_R_BGEZALL	OP_BGEZALL
>=20
> /*
> + * Values for the 'func' field when 'op' =3D=3D OP_SPECIAL3.
> + */
> +#define	OP_RDHWR	073
> +
> +/*
>  * Values for the 'rs' field when 'op' =3D=3D OP_COPz.
>  */
> #define	OP_MF		000
>=20
> Modified: head/sys/mips/mips/trap.c
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- head/sys/mips/mips/trap.c	Thu Feb  9 22:13:20 2012	=
(r231311)
> +++ head/sys/mips/mips/trap.c	Thu Feb  9 22:17:13 2012	=
(r231312)
> @@ -414,6 +414,7 @@ trap(struct trapframe *trapframe)
> 	intptr_t addr =3D 0;
> 	register_t pc;
> 	int cop;
> +	register_t *frame_regs;
>=20
> 	trapdebug_enter(trapframe, 0);
> =09
> @@ -762,9 +763,29 @@ dofault:
> 		}
>=20
> 	case T_RES_INST + T_USER:
> -		log_illegal_instruction("RES_INST", trapframe);
> -		i =3D SIGILL;
> -		addr =3D trapframe->pc;
> +		{
> +			InstFmt inst;
> +			inst =3D *(InstFmt *)trapframe->pc;
> +			switch (inst.RType.op) {
> +			case OP_SPECIAL3:
> +				switch (inst.RType.func) {
> +				case OP_RDHWR:
> +					/* Register 29 used for TLS */
> +					if (inst.RType.rd =3D=3D 29) {
> +						frame_regs =3D =
&(trapframe->zero);
> +						=
frame_regs[inst.RType.rt] =3D (register_t)td->td_md.md_tls;
> +						trapframe->pc +=3D =
sizeof(int);
> +						goto out;
> +					}
> +				break;
> +				}
> +			break;
> +			}
> +
> +			log_illegal_instruction("RES_INST", trapframe);
> +			i =3D SIGILL;
> +			addr =3D trapframe->pc;
> +		}
> 		break;
> 	case T_C2E:
> 	case T_C2E + T_USER:

--=20
Bjoern A. Zeeb                                 You have to have visions!
   It does not matter how good you are. It matters what good you do!




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?A74B52C1-36AD-4B7D-BA48-7787D1FF8699>