Author: gonzo Date: Tue Mar 6 03:25:50 2012 New Revision: 232577 URL: http://svn.freebsd.org/changeset/base/232577
Log: Prepare for large TLS redo. Save pointer to the beginning of TLS area, and offset it only if requested by RDHWR handler. Otherwise things get overly complicated - we need to track whether address passsed in request for setting td_md.md_tls is already offseted or not. Added: head/sys/mips/include/tls.h (contents, props changed) Modified: head/sys/mips/mips/trap.c head/sys/mips/mips/vm_machdep.c Added: head/sys/mips/include/tls.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/include/tls.h Tue Mar 6 03:25:50 2012 (r232577) @@ -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__ */ Modified: head/sys/mips/mips/trap.c ============================================================================== --- head/sys/mips/mips/trap.c Tue Mar 6 02:23:15 2012 (r232576) +++ head/sys/mips/mips/trap.c Tue Mar 6 03:25:50 2012 (r232577) @@ -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; } Modified: head/sys/mips/mips/vm_machdep.c ============================================================================== --- head/sys/mips/mips/vm_machdep.c Tue Mar 6 02:23:15 2012 (r232576) +++ head/sys/mips/mips/vm_machdep.c Tue Mar 6 03:25:50 2012 (r232577) @@ -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 - */ - -#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; + td->td_md.md_tls = (char*)tls_base; + return (0); -#endif } #ifdef DDB _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"