From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12841 Path: news.gmane.org!.POSTED!not-for-mail From: Phillip Berndt Newsgroups: gmane.linux.lib.musl.general Subject: Re: TLS issue on aarch64 Date: Sat, 26 May 2018 10:24:43 +0200 Message-ID: References: <20180525145059.GG4418@port70.net> <20180526005415.GI4418@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1527322974 24288 195.159.176.226 (26 May 2018 08:22:54 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 26 May 2018 08:22:54 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12857-gllmg-musl=m.gmane.org@lists.openwall.com Sat May 26 10:22:50 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 1fMUTR-0006Fr-Ea for gllmg-musl@m.gmane.org; Sat, 26 May 2018 10:22:49 +0200 Original-Received: (qmail 7995 invoked by uid 550); 26 May 2018 08:24:56 -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 7974 invoked from network); 26 May 2018 08:24:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=1ot0VtOQEM0mvC8Fx5luviLO7a+f10tDVh9haowjCr0=; b=smYF8WrceI8EntDmUCEWJxM6K7B/5rz0ieSb51NdBAW5NKBKIcqc7W8qNveORJ2xJl sYX/DM/N8xbVi8dlkOqDrt1Avk3YjSZ1geqRoHEBLu9583oD2HZLeYo8Xw50nLzUi9Eu F1EnD6cp0UOpRcYmvwwG/TzTL+xJI8QAusY0cYJUv/9qXf2LpojqRhn76qB4Lh3Xo8s8 eFu4XHgDvLPNVQDU2k9DOwt5GOqVzxpQin7Q5dsUJ01fJDYoEI/1om/VdI3/uUoW3D5Q kaMRAvaXMNs6wb66GEvzL9/8VovlIds7RKNVwbYCT5PXGsMkQNfcSPn04ZQ+rvGPaoOp 2Etw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=1ot0VtOQEM0mvC8Fx5luviLO7a+f10tDVh9haowjCr0=; b=gXI6Fr9sTWGojwqHOhTYrw4CFA2sRbbzurfg1WTo79KBszdbKVZs+YLHgQOUHZv3em am7r4rCGx+oyJ/jdVyRVWiCLCF0jHl890wSRDotNCxxC9PrAkhKeH/8twiyfBibVn/1b yRq1dIztF5FabQZ0yFpecu0wsSyl/i5cGspwXzFV7LtFom3wFa4kjkHUFcTVwLXqFTZm ecpuiawynSoU9VX/4kMe5gGKGWczfTkfBtMZfCmQ9+Za2D5o3MQBZmChFGUCncqgQuJy 5OVmhIGptlZlIMRz8sOA0EqRgFExnl1VYyFoY5riNOoP4jBb30Xd9sgJ7hlcVRsNpoR9 N1AA== X-Gm-Message-State: ALKqPwer/5cidYsLwMHkhPHPiWu4iPDS/nX5W3SqK0MQAx4JuVi1NhLp G4lYFJQcEOrNdw7LyIieRORbUOPCUX4HwX3a8pcHVhff X-Google-Smtp-Source: AB8JxZp+LsNacp0xfIHh0Btc8q44Q+y+RV3lRlxMRHXN4W6aw8g0WrNyVmMnUu+sS4I0k9qOlL3CL3k9W5g2TWVGLqU= X-Received: by 2002:a2e:9a06:: with SMTP id o6-v6mr3692019lji.17.1527323083982; Sat, 26 May 2018 01:24:43 -0700 (PDT) In-Reply-To: <20180526005415.GI4418@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:12841 Archived-At: 2018-05-26 2:54 GMT+02:00 Szabolcs Nagy : > indeed you need another alignment there, i came up with the > following fix: > > (on mips/ppc i expect it not to change anything: tp is > at a page aligned offset from the end of struct pthread, > so one alignment is enough there, but on aarch64/arm/sh4 > this makes a difference, and seems to pass my simple tests) > > diff --git a/src/env/__init_tls.c b/src/env/__init_tls.c > index 1c5d98a0..8e70024d 100644 > --- a/src/env/__init_tls.c > +++ b/src/env/__init_tls.c > @@ -41,9 +41,12 @@ void *__copy_tls(unsigned char *mem) > #ifdef TLS_ABOVE_TP > dtv = (void **)(mem + libc.tls_size) - (libc.tls_cnt + 1); > > - mem += -((uintptr_t)mem + sizeof(struct pthread)) & (libc.tls_align-1); > + /* Ensure TP is aligned. */ > + mem += -(uintptr_t)TP_ADJ(mem) & (libc.tls_align-1); > td = (pthread_t)mem; > mem += sizeof(struct pthread); > + /* Ensure TLS is aligned after struct pthread. */ > + mem += -(uintptr_t)mem & (libc.tls_align-1); > > for (i=1, p=libc.tls_head; p; i++, p=p->next) { > dtv[i] = mem + p->offset; I took the demo from my first mail and tested your patch with all alignments up to the page size: They all seem to work fine. Awesome :) - Phillip