From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12839 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 00:20:04 +0200 Message-ID: References: <20180525145059.GG4418@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 1527286692 24365 195.159.176.226 (25 May 2018 22:18:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 25 May 2018 22:18:12 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12855-gllmg-musl=m.gmane.org@lists.openwall.com Sat May 26 00:18:08 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 1fML2G-0006Fr-5e for gllmg-musl@m.gmane.org; Sat, 26 May 2018 00:18:08 +0200 Original-Received: (qmail 5773 invoked by uid 550); 25 May 2018 22:20:17 -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 5755 invoked from network); 25 May 2018 22:20:16 -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=yzutuLD1139S114TePNPmaf2pb/I5/JQdJq/y3rrOeM=; b=Z0O+rkQvGRGKnk+/RqcLpE1L7+xfEeP/ekOpaCbW1Fv50BuBI4LCZjEbxKIRbzST3F TM8wNnh11gTWO7MChLffCyYR0jHitjVk9UvhR1+9JiN52RQbNJYTQhDfL92HD++7u2xt f6YG8CKqsuiSd+gcqjjKzulacNxtG7jI7HhaDimd9gaR4bcu71THtYmXfFOX5EKcki0K S4KA7z6/0xHWL4Qw5epE/S+4h1bFDy1dWlWCcDkEUrx+ADpVlg5BYTUufAsL/1r8AMzL r/4jj+OyBYFETi3DW5scMAlowZ+/TLFprc5ubRGH/smsZQB+A5S7RvDt3gMsfn8iMfFx 2rJA== 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=yzutuLD1139S114TePNPmaf2pb/I5/JQdJq/y3rrOeM=; b=uR4vwyCwP+sql4C0voylBOj/sbqv7jcN1wnItYpN55RscKYY8J6B6FrUdom+7VNzXm hUjG0tPo3NmtseROtoJqWiywLgspsiJZifLMQWQgbNstSGgVtD8O21JJ/96rprros39c UgP/dmGyILfzAhLF19BU3uVcm0enbwbWBP9rd2ck8kIzO/Kxxh8j2ZZdryz6RZv7mhya RQ6mS9honPhjJWREcty40/nM9jiHeKxthY4/JsXtPSJlb2EagkmXZ+fQDczmNP+x/+Xs huKbL4dxSg0k3xBm2yFDdM43ETqZ48uPCTTucSCNK8nn3F/+bO1cPHeHbrIL5IQ50vNF WC9w== X-Gm-Message-State: ALKqPwdBQ/Y+7SR3m2wwb8VKqGEuQGiKkmX3WY/EkDQUaRXHNVelVfAf LyRhADzq1pGBqdJBpWy8XDgEFA6OIypV4Woy1daRXGjU X-Google-Smtp-Source: ADUXVKITbBKq02p6pHXuC0oePHcnVfEdTybZ2laZjcWA9HoBLWm4KP+GpAEs5rU2TSX0+UB7R2A/xpWIZ8mMjQNRz3w= X-Received: by 2002:a19:4dc5:: with SMTP id a188-v6mr2417735lfb.99.1527286804856; Fri, 25 May 2018 15:20:04 -0700 (PDT) In-Reply-To: <20180525145059.GG4418@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:12839 Archived-At: 2018-05-25 16:50 GMT+02:00 Szabolcs Nagy : > i think the constraints for tp are: > > - tp must be aligned to 'tls_align' > > - tp must be at a small fixed offset from the end > of pthread struct (so asm code can access the dtv) > > - tp + off must be usable memory for tls for off >= 16 > (this is aarch64 specific) > Hmm.. but these constraints do not explain the extra offset of one alignment I'm seeing in the GCC output, do they? If I compile a program with a single TLS variable with __attribute__((aligned(n)) that does nothing but try to reference and print said variable, I get the following assembler code from GCC: For n = 0x1000: 400194: d53bd041 mrs x1, tpidr_el0 400198: b0000040 adrp x0, 409000 <__subtf3+0xd18> 40019c: 91400421 add x1, x1, #0x1, lsl #12 4001a0: 91000021 add x1, x1, #0x0 For n = 0x100: 400194: d53bd041 mrs x1, tpidr_el0 400198: b0000040 adrp x0, 409000 <__subtf3+0xd18> 40019c: 91400021 add x1, x1, #0x0, lsl #12 4001a0: 91040021 add x1, x1, #0x100 For n = 0x10: 400194: d53bd041 mrs x1, tpidr_el0 400198: b0000040 adrp x0, 409000 <__subtf3+0xd18> 40019c: 91400021 add x1, x1, #0x0, lsl #12 4001a0: 91004021 add x1, x1, #0x10 That's how I came up with the mem += libc.tls_align hack in the first place. - Phillip