From owner-svn-src-all@freebsd.org Tue Mar 28 21:11:13 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A9432D232D3; Tue, 28 Mar 2017 21:11:13 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [96.47.65.170]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 67813CAD; Tue, 28 Mar 2017 21:11:12 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from ralph.baldwin.cx (c-73-231-226-104.hsd1.ca.comcast.net [73.231.226.104]) by mail.baldwin.cx (Postfix) with ESMTPSA id 4D20310A7B9; Tue, 28 Mar 2017 17:11:05 -0400 (EDT) From: John Baldwin To: mmel@freebsd.org Cc: Warner Losh , src-committers , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Subject: Re: svn commit: r315974 - in head: lib/libthread_db/arch/arm sys/arm/arm sys/arm/include Date: Tue, 28 Mar 2017 11:26:43 -0700 Message-ID: <22618548.zXcKfQPOV0@ralph.baldwin.cx> User-Agent: KMail/4.14.10 (FreeBSD/11.0-STABLE; KDE/4.14.10; amd64; ; ) In-Reply-To: <74bb4fb0-b5d5-4be4-bcfe-4be343c2aee7@freebsd.org> References: <201703260836.v2Q8auoU069005@repo.freebsd.org> <74bb4fb0-b5d5-4be4-bcfe-4be343c2aee7@freebsd.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Tue, 28 Mar 2017 17:11:05 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Mar 2017 21:11:13 -0000 On Tuesday, March 28, 2017 12:20:04 PM Michal Meloun wrote: > > On 27.03.2017 19:40, Warner Losh wrote: > > On Mon, Mar 27, 2017 at 11:07 AM, John Baldwin wrote: > >> On Sunday, March 26, 2017 08:36:56 AM Michal Meloun wrote: > >>> Author: mmel > >>> Date: Sun Mar 26 08:36:56 2017 > >>> New Revision: 315974 > >>> URL: https://svnweb.freebsd.org/changeset/base/315974 > >>> > >>> Log: > >>> Preserve VFP state across signal delivery. > >>> > >>> We don't have enouch space to store full VFP context within mcontext > >>> stucture. Due to this: > >>> - follow i386/amd64 way and store VFP state outside of the mcontext_t > >>> but point to it. Use the size of VFP state structure as an 'magic' > >>> indicator of the saved VFP state presence. > >>> - teach set_mcontext() about this external storage. > >>> - for signal delivery, store VFP state to expanded 'struct sigframe'. > >>> > >>> Submited by: Andrew Gierth (initial version) > >>> PR: 217611 > >>> MFC after: 2 weeks > >>> > >>> Modified: > >>> head/lib/libthread_db/arch/arm/libpthread_md.c > >>> head/sys/arm/arm/machdep.c > >>> head/sys/arm/include/frame.h > >>> head/sys/arm/include/ucontext.h > >>> > >>> Modified: head/lib/libthread_db/arch/arm/libpthread_md.c > >>> ============================================================================== > >>> --- head/lib/libthread_db/arch/arm/libpthread_md.c Sun Mar 26 08:36:20 2017 (r315973) > >>> +++ head/lib/libthread_db/arch/arm/libpthread_md.c Sun Mar 26 08:36:56 2017 (r315974) > >>> @@ -90,7 +90,9 @@ pt_fpreg_to_ucontext(const struct fpreg > >>> mcontext_t *mc = &uc->uc_mcontext; > >>> > >>> /* XXX */ > >>> - memset(&mc->mc_spare, 0, sizeof(mc->mc_spare)); > >>> + mc->mc_vfp_size = 0; > >>> + mc->mc_vfp_ptr = NULL; > >>> + memset(mc->mc_spare, 0, sizeof(mc->mc_spare)); > >>> } > >> I suspect you don't need this bit? Has FreeBSD/arm ever supported VFP on a release > >> that also shipped libkse? (i.e. not libthr but the other thread library) > > No. And even if we had, we blew up binary compat when we went from OABI to EABI. > > > > Warner > I just wanted to maintain the status quo, nothing more. > > All I know is that none of threading libraries maintains VFP state, > 'struct fpreg' is badly defined (is to short for fill VFP context), and > pre r315974 kernel doesn't initialize _vfp (renamed to mc_spare) part > of mcontext_t. > > So I'm seeking a way how to fix all this. But I'm not familiar with > kse -> pthread transition history, so I'm not sure which parts are > actively used. The libpthread_md.c files are for the KSE-based libpthread and generally don't need changing at this point as they are only there to allow old gdb binaries to debug old binaries using libpthread. In particular, with the KSE thread library, a "paused" user thread that wasn't associated with a kernel thread ("LWP") needed it's userland register state saved somewhere until it resumed execution. The libpthread bits are for extracting that saved register state so a debugger can examine a non-running user thread. Modern gdb in ports doesn't use libthread_db at all, and I think lldb might not use it either. (Both just assume that every pthread has an associated LWP and use ptrace() to query information about LWPs directly). Note that on x86 we haven't updated any of the libthread_db stuff to handle newer vector register extensions like AVX. That only works via direct ptrace() for example. It will be good to include VFP info in cores via new core notes (if not done already) and to provide a way to fetch the register banks from a running thread via ptrace, but you can generally ignore libthread_db. At some point gdb in ports might use some small bits of libthread_db to determine the pthread_t associated with a kernel-enumerated LWP, but that's about all it would ever be used for at this point. -- John Baldwin