From owner-freebsd-mips@FreeBSD.ORG Thu Dec 9 11:16:10 2010 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 511FA1065670 for ; Thu, 9 Dec 2010 11:16:10 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id D803D8FC0A for ; Thu, 9 Dec 2010 11:16:09 +0000 (UTC) Received: by wwf26 with SMTP id 26so2177374wwf.31 for ; Thu, 09 Dec 2010 03:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=kneTlAVMnVZHNAXDnYu9ubVQjybNMJi0w5pi/4ihPwE=; b=SnPFd6/bFtWKeBsVcfJKi0Rm6yAsX4G6uaAocUMc5pnzcvuvQbsb7FU9S0OU4O6+g3 ooWA6n04jPhxJ4Fzp90w7rtLrzUGs2eiTOOdINYWakRGcv2cAkY6c3LAqYC2X8j84LQt yQmNpWXktXIirZAufL65lqC/QX5fHCet0nbCQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=j4x+1wjRjpc7tVljgOQHnpgdtelxGeAgSuZJ1xIdpkRhNPQd4N7F2jUsgzHEZeVnqS 01+OZupKpcq9IxglsfOKYDzMR7FO5g9YuaA7qtjNrJkHpqPDNPNxXfboq5JBPJGO1eJt 6HIjUfyQGSB69zxKb22m5eqJ/DpciXtrrydpw= MIME-Version: 1.0 Received: by 10.227.144.12 with SMTP id x12mr10189490wbu.218.1291893368472; Thu, 09 Dec 2010 03:16:08 -0800 (PST) Sender: c.jayachandran@gmail.com Received: by 10.227.135.84 with HTTP; Thu, 9 Dec 2010 03:16:08 -0800 (PST) In-Reply-To: References: Date: Thu, 9 Dec 2010 16:46:08 +0530 X-Google-Sender-Auth: TloKCiY_l5YGAuZ4HgthHpbIhZQ Message-ID: From: "Jayachandran C." To: Robert Millan Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-mips@freebsd.org Subject: Re: [PATCH] Retrieval of TLS pointer via RDHWR X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Dec 2010 11:16:10 -0000 On Wed, Dec 8, 2010 at 10:04 PM, Robert Millan wrote: > This patch implements support for retrieving the TLS pointer via RDHWR > instruction. > > It is implemented through emulation for platforms that don't provide > this instruction natively (such as gxemul/malta). =A0Platforms that do > provide it would need a separate patch. > > Reading register $29 with RDHWR is becoming the de-facto standard to > implement TLS. =A0According to linux-mips wiki, MIPS Technologies has > reserved hardware register $29 for ABI use. =A0Furthermore current GCC [1= ] > makes the following assumptions: > - RDHWR is natively available or otherwise emulated by the kernel > - Register $29 holds the TLS pointer > > [1] gcc-4.4.4/gcc/config/mips/mips.md reads: > > ;; The TLS base pointer is accessed via "rdhwr $3, $29". =A0No current > ;; MIPS architecture defines this register, and no current > ;; implementation provides it; instead, any OS which supports TLS is > ;; expected to trap and emulate this instruction. =A0rdhwr is part of the > ;; MIPS 32r2 specification, but we use it on any architecture because > ;; we expect it to be emulated. I'm not sure that the freebsd mips toolchain supports the __thread directive yet. Were you able to test this from C? Regards, JC