From owner-freebsd-ppc@freebsd.org Mon Jan 21 20:59:29 2019 Return-Path: Delivered-To: freebsd-ppc@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 3CD5F14B83C9 for ; Mon, 21 Jan 2019 20:59:29 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D302281F96 for ; Mon, 21 Jan 2019 20:59:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-3.local (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 66F3531DA for ; Mon, 21 Jan 2019 20:59:28 +0000 (UTC) (envelope-from jhb@FreeBSD.org) To: freebsd-ppc@FreeBSD.org From: John Baldwin Subject: GDB TLS testing Openpgp: preference=signencrypt Autocrypt: addr=jhb@FreeBSD.org; keydata= mQGiBETQ+XcRBADMFybiq69u+fJRy/0wzqTNS8jFfWaBTs5/OfcV7wWezVmf9sgwn8TW0Dk0 c9MBl0pz+H01dA2ZSGZ5fXlmFIsee1WEzqeJzpiwd/pejPgSzXB9ijbLHZ2/E0jhGBcVy5Yo /Tw5+U/+laeYKu2xb0XPvM0zMNls1ah5OnP9a6Ql6wCgupaoMySb7DXm2LHD1Z9jTsHcAQMD /1jzh2BoHriy/Q2s4KzzjVp/mQO5DSm2z14BvbQRcXU48oAosHA1u3Wrov6LfPY+0U1tG47X 1BGf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Q4QkF4OhUV9zPtf9tDSAZ3x7QSwoKbCoRCZ/xbyTUPyQ1VvNy/mYrBcYlzHodsaqUDjHuW+I SQQYEQIACQUCRND5ggIbDAAKCRBy3lIGd+N/BCO8AJ9j1dWVQWxw/YdTbEyrRKOY8YZNwwCf afMAg8QvmOWnHx3wl8WslCaXaE8= Message-ID: Date: Mon, 21 Jan 2019 12:58:41 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: D302281F96 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.996,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.987,0]; ASN(0.00)[asn:11403, ipnet:96.47.64.0/20, country:US] X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jan 2019 20:59:29 -0000 First, I tried to boot FreeBSD under QEMU (but not using an ISO image to boot, building a disk image via makefs so I could modify it, etc.) following these instructions: - make buildworld TARGET_ARCH=powerpc64 CROSS_TOOLCHAIN=powerpc64-gcc - make buildkernel TARGET_ARCH=powerpc64 CROSS_TOOLCHAIN=powerpc64-gcc KERNCONF=GENERIC64 - make installkernel TARGET_ARCH=powerpc64 CROSS_TOOLCHAIN=powerpc64-gcc KERNCONF=GENERIC64 DESTDIR=/qemu/ppc64/rootfs/ - make installworld TARGET_ARCH=powerpc64 CROSS_TOOLCHAIN=powerpc64-gcc DESTDIR=/qemu/ppc64/rootfs/ - make distribution TARGET_ARCH=powerpc64 CROSS_TOOLCHAIN=powerpc64-gcc DESTDIR=/qemu/ppc64/rootfs/ - etcupdate extract -B -D /qemu/ppc64/rootfs -s /home/john/work/freebsd/head -M "TARGET_ARCH=powerpc64 CROSS_TOOLCHAIN=powerpc64-gcc" - makefs -M 32g -f 200000 -o version=2 -B big /qemu/ppc64/fs.img /qemu/ppc64/rootfs - mkimg -s mbr -p prepboot:=/qemu/ppc64/rootfs/boot/boot1.elf -p freebsd:=/qemu/ppc64/fs.img -a 1 -o /qemu/ppc64/disk.img - qemu-system-ppc64 -drive file=/qemu/ppc64/disk.img,format=raw -nographic -vga none -nic tap,ifname=tap2 This did let me boot into QEMU, but I had some weird issues with keyboard input not always working correctly. The network interface (llan0) also did not work at all. When it tried to DHCP, I saw no traffic on the tap2 interface on the host. I also tried using '-nic user' and that wasn't able to DHCP either. It seems like it if_llan(4) isn't actually transmitting packets. Anyway, the thing I am trying to test is support for thread-local-storage (TLS) variables under GDB. Since networking wasn't working, I tried to just copy my test programs (cross-built) and a GDB binary (also cross-built) into the disk image and booting that. However, my test program that used threads core dumped just trying to create a 3rd thread (so second call to pthread_create()), and when I tried to use GDB either live or against a core, it would just spin in userland forever (probably because C++ exceptions aren't working). Fixing C++ probably means moving to LLVM's libunwind instead of the ancient libgcc from gcc4.2 (though I know Mark Millard has a patch for the ancient libgcc that helped in his testing). Would someone with a working ppc system be willing to help test the GDB bits for me? You can grab the 'fbsd_tls' branch from github/bsdjhb/gdb.git to build a GDB. For testing purposes, just generating a core from the test programs I'm using and looking at that core on a non-ppc host would also work fine. For example, in my case where I have the ppc system installed to /qemu/ppc64/rootfs, I would do 'set sysroot /qemu/ppc64/rootfs' at the GDB prompt to point GDB at the ppc64 libraries, etc. Note that modern GDB is written in C++11, so you can't build it with gcc4.2. The first test program I am using is below and should generate a core when run. To test the TLS functionality you would want to make sure 'p id' reports the proper value (PID from the program's output), and also that 'p &id' also reports an address matching the program's output: #include #include static __thread int id; int main(int ac, char **av) { printf("main: PID %d\n", getpid()); id = getpid(); printf("id = %d (%p)\n", id, &id); (void)getchar(); #if 1 #if defined(__powerpc__) *(char *)NULL = 1; #else __builtin_trap(); #endif #endif return (0); } -- John Baldwin