From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46022 invoked by alias); 20 Mar 2018 04:57:55 -0000 Mailing-List: contact libc-help-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: libc-help-owner@sourceware.org Received: (qmail 46004 invoked by uid 89); 20 Mar 2018 04:57:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_SHORT,UNPARSEABLE_RELAY autolearn=ham version=3.3.2 spammy= X-HELO: smtp2200-217.mail.aliyun.com Received: from smtp2200-217.mail.aliyun.com (HELO smtp2200-217.mail.aliyun.com) (121.197.200.217) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Mar 2018 04:57:52 +0000 X-Alimail-AntiSpam:AC=CONTINUE;BC=0.07444201|-1;CH=green;FP=0|0|0|0|0|-1|-1|-1;HT=e02c03302;MF=han_mao@c-sky.com;NM=1;PH=DS;RN=4;RT=4;SR=0;TI=SMTPD_---.BNDe.vX_1521521866; Received: from localhost(mailfrom:han_mao@c-sky.com fp:223.93.147.148) by smtp.aliyun-inc.com(10.147.42.241); Tue, 20 Mar 2018 12:57:46 +0800 Date: Tue, 20 Mar 2018 04:57:00 -0000 From: Mao Han To: Carlos O'Donell Cc: c-sky_gcc_upstream@c-sky.com, gnu-csky@mentor.com, libc-help@sourceware.org Subject: Re: [RFC PATCH 02/10] C-SKY: TLS support Message-ID: <20180320045745.GB15959@vmh-VirtualBox> References: <2572ebe9-e0d8-8ed0-38ed-c65d98022db9@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2572ebe9-e0d8-8ed0-38ed-c65d98022db9@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes X-SW-Source: 2018-03/txt/msg00018.txt.bz2 On Fri, Mar 16, 2018 at 08:09:10AM -0600, Carlos O'Donell wrote: > On 03/16/2018 03:58 AM, Mao Han wrote: > > This patch implements TLS support for C-SKY. We support all four > > standard TLS addressing modes (LE, IE, LD, and GD) when running on > > Linux via NPTL. > > > > *sysdeps/csky/dl-tls.h: New file > > *sysdeps/csky/libc-tls.c: New file > > *sysdeps/csky/nptl/tcb-offsets.sym: New file > > *sysdeps/csky/nptl/tls.h: New file > > *sysdeps/csky/stackinfo.h: New file > > > > OK, fairly clean, was curious about stack guard and pointer guard support. > > Others may have more to comment on this in libc-alpha. > > > Signed-off-by: Mao Han > > --- > > sysdeps/csky/dl-tls.h | 26 ++++++ > > sysdeps/csky/libc-tls.c | 32 ++++++++ > > sysdeps/csky/nptl/tcb-offsets.sym | 10 +++ > > sysdeps/csky/nptl/tls.h | 169 ++++++++++++++++++++++++++++++++++++++ > > sysdeps/csky/stackinfo.h | 32 ++++++++ > > 5 files changed, 269 insertions(+) > > create mode 100644 sysdeps/csky/dl-tls.h > > create mode 100644 sysdeps/csky/libc-tls.c > > create mode 100644 sysdeps/csky/nptl/tcb-offsets.sym > > create mode 100644 sysdeps/csky/nptl/tls.h > > create mode 100644 sysdeps/csky/stackinfo.h > > index 0000000..69fadad > > --- /dev/null > > +++ b/sysdeps/csky/nptl/tls.h > > @@ -0,0 +1,169 @@ > > +/* Definitions for thread-local data handling. NPTL/csky version. > > + Copyright (C) 2018 Free Software Foundation, Inc. > > + This file is part of the GNU C Library. > > + > > + The GNU C Library is free software; you can redistribute it and/or > > + modify it under the terms of the GNU Lesser General Public > > + License as published by the Free Software Foundation; either > > + version 2.1 of the License, or (at your option) any later version. > > + > > + The GNU C Library is distributed in the hope that it will be useful, > > + but WITHOUT ANY WARRANTY; without even the implied warranty of > > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + Lesser General Public License for more details. > > + > > + You should have received a copy of the GNU Lesser General Public > > + License along with the GNU C Library. If not, see > > + . */ > > + > > +#ifndef _TLS_H > > +#define _TLS_H 1 > > + > > +#ifndef __ASSEMBLER__ > > + > > +#include > > +#include > > +#include > > +#include > > + > > +#ifdef __CSKYABIV2__ > > +/* define r31 as thread pointer register. */ > > +#define READ_THREAD_POINTER() \ > > + ({ void *__result; \ > > + __asm__ __volatile__ ("mov %0, r31" \ > > + : "=r" (__result)); \ > > + __result; }) > > +#else > > +#define READ_THREAD_POINTER() \ > > + ({ register unsigned int __result __asm__("a0"); \ > > + __asm__ __volatile__ ("trap 3;" \ > > + : "=r" (__result) : : ); \ > > + __result; }) > > +#endif > > + > > +#else /* __ASSEMBLER__ */ > > +#include > > +#ifdef __CSKYABIV2__ > > +/* define r31 as thread pointer register. */ > > +#define READ_THREAD_POINTER() \ > > + mov r0, r31; > > +#else > > +#define READ_THREAD_POINTER() \ > > + trap 3; > > +#endif > > +#endif /* __ASSEMBLER__ */ > > + > > +#ifndef __ASSEMBLER__ > > + > > +/* Get system call information. */ > > +#include > > + > > +/* The TP points to the start of the thread blocks. */ > > +#define TLS_DTV_AT_TP 1 > > +#define TLS_TCB_AT_TP 0 > > + > > +/* Get the thread descriptor definition. */ > > +#include > > + > > +typedef struct > > +{ > > + dtv_t *dtv; > > + void *private; > > Stack guard or pointer guard support? We have global stack protect support using __stack_chk_guard, but SSP_TLS is not supported in our gcc. So there is no stack_guard here. Pointer guard is not support at present. PTR_DEMANGLE and PTR_MANGLE are defined empty. I think I'll add support for that later. > > > +} tcbhead_t; > > +