From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12882 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: TLS issue on aarch64 Date: Fri, 1 Jun 2018 11:38:11 +0200 Message-ID: <20180601093811.GN4418@port70.net> References: <20180525145059.GG4418@port70.net> <20180526005415.GI4418@port70.net> <20180527003430.GG1392@brightrain.aerifal.cx> <20180528204730.GJ4418@port70.net> <20180528221521.GI1392@brightrain.aerifal.cx> <20180529063316.GK4418@port70.net> <20180601001102.GL4418@port70.net> <20180601005200.GO1392@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1527845780 3636 195.159.176.226 (1 Jun 2018 09:36:20 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 1 Jun 2018 09:36:20 +0000 (UTC) User-Agent: Mutt/1.9.1 (2017-09-22) To: musl@lists.openwall.com Original-X-From: musl-return-12898-gllmg-musl=m.gmane.org@lists.openwall.com Fri Jun 01 11:36:16 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1fOgTn-0000sm-Td for gllmg-musl@m.gmane.org; Fri, 01 Jun 2018 11:36:15 +0200 Original-Received: (qmail 14056 invoked by uid 550); 1 Jun 2018 09:38:24 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 14011 invoked from network); 1 Jun 2018 09:38:23 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20180601005200.GO1392@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:12882 Archived-At: * Rich Felker [2018-05-31 20:52:00 -0400]: > On Fri, Jun 01, 2018 at 02:11:02AM +0200, Szabolcs Nagy wrote: > > aarch64: tp + alignup(16, align) must be aligned == tp must be aligned > > OK, I see two possible solutions here: > > 1. tp==self+sizeof(struct pthread). In this case we'll waste some > space (vs the current approach) when no extra alignment is needed, but > it's simple and clean because all the alignments match up naturally. > > 2. tp==self+sizeof(struct pthread)-16 (or rather -reserved in > general). This preserves the current memory usage, but requires > complex new alignment logic since self will no longer be aligned mod > tls_align when tls_align>reserved. > > I pretty strongly prefer option 1. > ok. > In either case, the main_tls.offset/app.tls.offset value needs to > correctly reflect the offset of the TLS from TP, so it either needs to > be alignup(reserved,tls_align) or alignup(reserved,tls_align)-reserved > depending on option 1 or 2. After that change is made, we need to make > sure the storage needs (libc.tls_size) are computed correctly and > account for the extra space due to the initial positive offset. > > No change is then needed in __copy_tls. > > Changes to TP_ADJ and __pthread_self are needed to get reserved out of > them, and the value of reserved needs to be provided somewhere else > for computing main_tls.offset. > ok. i'll try to prepare a patch. > > for initial-exec to work: > > tp + *got - add must be aligned (i.e. *got has to be set up to meet > > the alignment requirement of the module, this does not seem to require > > realignment of tp so even runtime loading of initial-exec tls should > > be possible assuming there is enough space etc...) > > There's never space so it's not even a question, but even if there > were, no, it can't be done because tp will not be aligned mod some > possibly-larger alignment than the alignment in effect at the time the > thread was created. > ah right because there are many threads with different tp so tp + *got can only be aligned if tp modulo alignment is the same in all of them.