diff options
-rw-r--r-- | sys/mips/include/tls.h | 48 | ||||
-rw-r--r-- | sys/mips/mips/trap.c | 2 | ||||
-rw-r--r-- | sys/mips/mips/vm_machdep.c | 21 |
3 files changed, 51 insertions, 20 deletions
diff --git a/sys/mips/include/tls.h b/sys/mips/include/tls.h new file mode 100644 index 0000000..514a8ac --- /dev/null +++ b/sys/mips/include/tls.h @@ -0,0 +1,48 @@ +/*- + * Copyright (c) 2012 Oleksandr Tymoshenko + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification, immediately at the beginning of the file. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + * + */ + +#ifndef __MIPS_TLS_H__ +#define __MIPS_TLS_H__ + +/* + * TLS parameters + */ + +#define TLS_TP_OFFSET 0x7000 +#define TLS_DTP_OFFSET 0x8000 + +#ifdef __mips_n64 +#define TLS_TCB_SIZE 16 +#else +#define TLS_TCB_SIZE 8 +#endif + +#endif /* __MIPS_TLS_H__ */ diff --git a/sys/mips/mips/trap.c b/sys/mips/mips/trap.c index 8035bf2..4e365a3 100644 --- a/sys/mips/mips/trap.c +++ b/sys/mips/mips/trap.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include <machine/mips_opcode.h> #include <machine/frame.h> #include <machine/regnum.h> +#include <machine/tls.h> #include <machine/asm.h> #ifdef DDB @@ -813,6 +814,7 @@ dofault: if (inst.RType.rd == 29) { frame_regs = &(trapframe->zero); frame_regs[inst.RType.rt] = (register_t)(intptr_t)td->td_md.md_tls; + frame_regs[inst.RType.rt] += TLS_TP_OFFSET + TLS_TCB_SIZE; trapframe->pc += sizeof(int); goto out; } diff --git a/sys/mips/mips/vm_machdep.c b/sys/mips/mips/vm_machdep.c index cbbe990..cee7e8d 100644 --- a/sys/mips/mips/vm_machdep.c +++ b/sys/mips/mips/vm_machdep.c @@ -608,28 +608,9 @@ int cpu_set_user_tls(struct thread *td, void *tls_base) { - /* - * tls_base passed to this function - * from thr_new call and points to actual TCB struct, - * so we should add TP_OFFSET + sizeof(struct tcb) - * to make it the same way TLS base is passed to - * MIPS_SET_TLS/MIPS_GET_TLS API - */ + td->td_md.md_tls = (char*)tls_base; -#ifdef __mips_n64 -#ifdef COMPAT_FREEBSD32 - if (!SV_PROC_FLAG(td->td_proc, SV_ILP32)) { -#endif - td->td_md.md_tls = (char*)tls_base + 0x7010; - return (0); -#ifdef COMPAT_FREEBSD32 - } -#endif -#endif -#if !defined(__mips_n64) || defined(COMPAT_FREEBSD32) - td->td_md.md_tls = (char*)tls_base + 0x7008; return (0); -#endif } #ifdef DDB |