From owner-freebsd-arch@FreeBSD.ORG Thu Apr 5 20:58:24 2012 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2EE8106566C for ; Thu, 5 Apr 2012 20:58:24 +0000 (UTC) (envelope-from kp@sigsegv.be) Received: from mercury.codepro.be (mercury.codepro.be [IPv6:2001:4b98:dc0:51:216:3eff:feb7:3147]) by mx1.freebsd.org (Postfix) with ESMTP id 5F2368FC08 for ; Thu, 5 Apr 2012 20:58:24 +0000 (UTC) Received: from adrastea.jupiter.sigsegv.be (adrastea.jupiter.sigsegv.be [IPv6:2001:6f8:1498:1::3]) by mercury.codepro.be (Postfix) with ESMTP id 74A5039B; Thu, 5 Apr 2012 22:58:23 +0200 (CEST) Received: from thebe.jupiter.sigsegv.be (thebe.jupiter.sigsegv.be [172.16.1.5]) by adrastea.jupiter.sigsegv.be (Postfix) with ESMTP id EB18916FC; Thu, 5 Apr 2012 22:58:22 +0200 (CEST) Received: by thebe.jupiter.sigsegv.be (Postfix, from userid 1000) id AA2B31C281; Thu, 5 Apr 2012 22:58:22 +0200 (CEST) Date: Thu, 5 Apr 2012 22:58:22 +0200 From: Kristof Provost To: Jason Evans Message-ID: <20120405205822.GR9275@thebe.jupiter.sigsegv.be> References: <2FF97057-905D-4F02-9138-75680ABC6202@canonware.com> <4F79F020.9070504@freebsd.org> <3C11DB18-1C43-446E-A0BC-FC15C6126819@canonware.com> <4F7A170E.8020209@bluezbox.com> <4F7B98C0.6090209@bluezbox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-PGP-Fingerprint: E114 D9EA 909E D469 8F57 17A5 7D15 91C6 9EFA F286 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Oleksandr Tymoshenko , freebsd-arch@freebsd.org Subject: Re: TLS on ARM and MIPS X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Apr 2012 20:58:24 -0000 On 2012-04-04 22:00:57 (-0700), Jason Evans wrote: > On Apr 3, 2012, at 5:41 PM, Oleksandr Tymoshenko wrote: > > I tested it for MIPS - works fine. Unfortunately I don't have > > ARM hardware that works with HEAD so can't test ARM part of the change. > > Thanks for testing MIPS. I'm going to just assume that TLS works everywhere. > If it doesn't, we'll find out soon enough. =) > It appears to be rather broken on ARM, at least in combination with shared libraries. I'm trying to run on an OpenRD board (Kirkwood ARM core) and I see alignment faults whenever TLS is used. Considering that malloc appears to use it that'd be pretty much everywhere. A minimal test case is to have a shared library expose a __thread variable and then to write to it from outside the library. The assembly looks like this: int main(int argc, char **argv) { 8774: e52de004 push {lr} ; (str lr, [sp, #-4]!) kp_int = 4; 8778: e59f3014 ldr r3, [pc, #20] ; 8794 877c: e79f3003 ldr r3, [pc, r3] 8780: ebffff4c bl 84b8 <_init+0x58> 8784: e3a02004 mov r2, #4 ; 0x4 8788: e7802003 str r2, [r0, r3] return 0; } The faulting instruction is 0x8788. At that point r0 is 0x20036000, r3 is 0xffff1fff. Let me know if you need to know anything else. In the mean time I'll keep trying to figure out how it's supposed to be working in the first place :) Regards. Kristof