From owner-svn-src-head@freebsd.org Thu Sep 27 23:13:12 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 45C1710BD568; Thu, 27 Sep 2018 23:13:12 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C479E7CA9E; Thu, 27 Sep 2018 23:13:11 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id w8RNCuMh050428 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 28 Sep 2018 02:12:59 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua w8RNCuMh050428 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id w8RNCuSl050427; Fri, 28 Sep 2018 02:12:56 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 28 Sep 2018 02:12:56 +0300 From: Konstantin Belousov To: Andreas Tobler Cc: Michael Tuexen , src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r338930 - head/libexec/rtld-elf/powerpc Message-ID: <20180927231256.GB5335@kib.kiev.ua> References: <201809251929.w8PJTZl9021331@repo.freebsd.org> <828EF35C-7216-4847-A73D-464111006E52@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Sep 2018 23:13:12 -0000 On Thu, Sep 27, 2018 at 09:37:31PM +0200, Andreas Tobler wrote: > On 27.09.18 20:48, Michael Tuexen wrote: > >> On 25. Sep 2018, at 21:29, Andreas Tobler wrote: > >> > >> Author: andreast > >> Date: Tue Sep 25 19:29:35 2018 > >> New Revision: 338930 > >> URL: https://svnweb.freebsd.org/changeset/base/338930 > >> > >> Log: > >> Bring the 32-bit powerpc (PowerMac) back to live. The commit 338486 reworked > >> some TLS bits. This broke operation on the PowerMac. Namely one could not login. > >> At login the screen/shell was giving back lots of backslashes and the login > >> shell dumped core. > >> > >> The fix to this issue is to revert the powerpc commit from 338486 and to > >> increase the TLS_TCB_SIZE to 16. > >> Reverting only did not help, login was possible but userland applications > >> aborted with strange messages. > >> > >> I tested this patch with world/kernel builds and with port upgrades. > >> Additionally a full gcc8 bootstrap was successfully completed. > >> > >> Reviewed by: jhibbits@ > >> Approved by: re (Glen) > >> > >> Modified: > >> head/libexec/rtld-elf/powerpc/rtld_machdep.h > >> > >> Modified: head/libexec/rtld-elf/powerpc/rtld_machdep.h > >> ============================================================================== > >> --- head/libexec/rtld-elf/powerpc/rtld_machdep.h Tue Sep 25 18:54:18 2018 (r338929) > >> +++ head/libexec/rtld-elf/powerpc/rtld_machdep.h Tue Sep 25 19:29:35 2018 (r338930) > >> @@ -69,12 +69,12 @@ void _rtld_powerpc_pltcall(void); > >> > >> #define TLS_TP_OFFSET 0x7000 > >> #define TLS_DTV_OFFSET 0x8000 > >> -#define TLS_TCB_SIZE 8 > >> +#define TLS_TCB_SIZE 16 > >> > >> #define round(size, align) \ > >> (((size) + (align) - 1) & ~((align) - 1)) > >> #define calculate_first_tls_offset(size, align) \ > >> - TLS_TCB_SIZE > >> + round(8, align) > >> #define calculate_tls_offset(prev_offset, prev_size, size, align) \ > >> round(prev_offset + prev_size, align) > >> #define calculate_tls_end(off, size) ((off) + (size)) > >> > > After performing a buildworld/buildkernel and running r338956 on a 32-bit powerpc machine (G4 Mac Mini), > > the following program: > > > > #include > > #include > > #include > > > > void * > > f(void * arg) > > { > > return (arg); > > } > > > > int > > main(void) > > { > > void *res; > > pthread_t tid; > > int err; > > > > if ((err = pthread_create(&tid, NULL, f, NULL)) != 0) { > > fprintf(stderr, "pthread_create: %s\n", strerror(err)); > > } > > if ((err = pthread_join(tid, &res)) != 0) { > > fprintf(stderr, "pthread_join: %s\n", strerror(err)); > > } > > return (0); > > } > > > > is killed: > > > > tuexen@bsd5:~ % ./test > > ld-elf.so.1: assert failed: /usr/home/tuexen/head/libexec/rtld-elf/rtld.c:4753 > > Abort (core dumped) > > > > gdb shows: > > > > tuexen@bsd5:~ % gdb -c test.core test > > GNU gdb (GDB) 8.1 [GDB v8.1 for FreeBSD] > > Copyright (C) 2018 Free Software Foundation, Inc. > > License GPLv3+: GNU GPL version 3 or later > > This is free software: you are free to change and redistribute it. > > There is NO WARRANTY, to the extent permitted by law. Type "show copying" > > and "show warranty" for details. > > This GDB was configured as "powerpc-portbld-freebsd12.0". > > Type "show configuration" for configuration details. > > For bug reporting instructions, please see: > > . > > Find the GDB manual and other documentation resources online at: > > . > > For help, type "help". > > Type "apropos word" to search for commands related to "word"... > > Reading symbols from test...done. > > [New LWP 100112] > > Core was generated by `./test'. > > Program terminated with signal SIGABRT, Aborted. > > #0 0x41829a58 in thr_kill () at thr_kill.S:3 > > 3 RSYSCALL(thr_kill) > > (gdb) bt > > #0 0x41829a58 in thr_kill () at thr_kill.S:3 > > #1 0x41829378 in __raise (s=6) > > at /usr/home/tuexen/head/lib/libc/gen/raise.c:52 > > #2 0x41823b84 in abort () at /usr/home/tuexen/head/lib/libc/stdlib/abort.c:67 > > #3 0x41813f58 in allocate_tls (objs=0x41843000, oldtcb=, > > tcbsize=8, tcbalign=) > > at /usr/home/tuexen/head/libexec/rtld-elf/rtld.c:4753 > > #4 0x41813fc0 in _rtld_allocate_tls (oldtls=0x0, tcbsize=8, tcbalign=16) > > at /usr/home/tuexen/head/libexec/rtld-elf/rtld.c:5030 > > #5 0x41877438 in _tcb_ctor (thread=0x41a8d300, initial=) > > at /usr/home/tuexen/head/lib/libthr/thread/thr_ctrdtr.c:45 > > #6 0x41876ebc in _thr_alloc (curthread=0x41a8d000) > > at /usr/home/tuexen/head/lib/libthr/thread/thr_list.c:172 > > #7 0x41867118 in _pthread_create (thread=0xffffdc10, attr=0x0, > > start_routine=0x180073c , arg=0x0) > > at /usr/home/tuexen/head/lib/libthr/thread/thr_create.c:81 > > #8 0x01800798 in main () > > (gdb) quit > > > > Any idea what is wrong? > > TLS is broken on powerpc ;) > > I see the same. > > Would you mind reverting my commit and see if it is better/different and > how different? > > For me the commit was an improvement, but I agree this is not enough. > > I try to analyze what is going on. Any help is appreciated. The cause is quite clear, sizeof(struct tcb) is 8 on power 32bit, see lib/libthread/arch/powerpc/include/pthread_md.h. I do not think that you can change this because it is part of the ABI assumed by the compilers.