From owner-svn-src-head@freebsd.org Mon Jan 18 21:41:12 2016 Return-Path: Delivered-To: svn-src-head@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 22EB2A87521; Mon, 18 Jan 2016 21:41:12 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from d.mail.sonic.net (d.mail.sonic.net [64.142.111.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0DAD11C03; Mon, 18 Jan 2016 21:41:11 +0000 (UTC) (envelope-from nwhitehorn@freebsd.org) Received: from comporellon.tachypleus.net (75-101-50-44.static.sonic.net [75.101.50.44]) (authenticated bits=0) by d.mail.sonic.net (8.15.1/8.15.1) with ESMTPSA id u0ILUVfM006523 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Mon, 18 Jan 2016 13:30:33 -0800 Subject: Re: svn commit: r279189 - in head/sys/powerpc: aim fpu include powerpc To: John Baldwin References: <201502222140.t1MLeSFg075690@svn.freebsd.org> <11668266.h2pHzfGYxF@ralph.baldwin.cx> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Nathan Whitehorn Message-ID: <569D5977.8050402@freebsd.org> Date: Mon, 18 Jan 2016 13:30:31 -0800 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <11668266.h2pHzfGYxF@ralph.baldwin.cx> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Sonic-CAuth: UmFuZG9tSVaVUmeQGsBeDro9MExB0U+HwZEEBT3EbmbKiCMUp/vo6vQJl2w/aiycxC5RPY2o5WWrwhhd9wfUkR9y/3oTCT0N3oMq3GoiM28= X-Sonic-ID: C;LAidsyq+5RGPYtlnAoajKQ== M;ajdhtCq+5RGPYtlnAoajKQ== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 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: Mon, 18 Jan 2016 21:41:12 -0000 On 01/18/16 12:49, John Baldwin wrote: > On Sunday, February 22, 2015 09:40:28 PM Nathan Whitehorn wrote: >> Author: nwhitehorn >> Date: Sun Feb 22 21:40:27 2015 >> New Revision: 279189 >> URL: https://svnweb.freebsd.org/changeset/base/279189 >> >> Log: >> Kernel support for the Vector-Scalar eXtension (VSX) found on the POWER7 >> and POWER8. This instruction set unifies the 32 64-bit scalar floating >> point registers with the 32 128-bit vector registers into a single bank >> of 64 128-bit registers. Kernel support mostly amounts to saving and >> restoring the wider version of the floating point registers and making >> sure that both scalar FP and vector registers are enabled once a VSX >> instruction is executed. get_mcontext() and friends currently cannot >> see the high bits, which will require a little more work. >> >> As the system compiler (GCC 4.2) does not support VSX, making use of this >> from userland requires either newer GCC or clang. >> >> Relnotes: yes >> Sponsored by: FreeBSD Foundation >> >> Modified: >> head/sys/powerpc/aim/trap.c >> head/sys/powerpc/aim/trap_subr64.S >> head/sys/powerpc/fpu/fpu_emu.c >> head/sys/powerpc/fpu/fpu_explode.c >> head/sys/powerpc/include/cpu.h >> head/sys/powerpc/include/pcb.h >> head/sys/powerpc/include/psl.h >> head/sys/powerpc/include/reg.h >> head/sys/powerpc/include/trap.h >> head/sys/powerpc/powerpc/cpu.c >> head/sys/powerpc/powerpc/db_trace.c >> head/sys/powerpc/powerpc/exec_machdep.c >> head/sys/powerpc/powerpc/fpu.c >> >> Modified: head/sys/powerpc/include/reg.h >> ============================================================================== >> --- head/sys/powerpc/include/reg.h Sun Feb 22 21:32:57 2015 (r279188) >> +++ head/sys/powerpc/include/reg.h Sun Feb 22 21:40:27 2015 (r279189) >> @@ -20,7 +20,10 @@ struct reg { >> >> /* Must match pcb.pcb_fpu */ >> struct fpreg { >> - double fpreg[32]; >> + union { >> + double fpr; >> + uint64_t vsr[2]; >> + } fpreg[32]; >> double fpscr; >> }; > This breaks the ABI of struct fpreg which changes the format of coredumps. > It also breaks the ABI of older versions of programs (such as debuggers) that > use ptrace(PT_GETFPREGS) (the kernel will now overflow the user-allocated > buffer if a debugger built on 10.x is run under an 11.0 kernel, and > PT_SETFPREGS is going to also buffer overflow and store random garbage in the > FP regs). Did you mean to alter the structure's layout? > > I can maybe fix upstream gdb to cope with either size, but it's a bit of a > PITA. In particular, gdb assumes that all the floating point registers in > struct fpreg are in a packed array (so it can use starting_offset + 8 * n to > extract register 'n' and only the initial offset is something that different > platform targets have to configure), so fixing this means having to add a lot > of special cases and duplicate code that is otherwise shared across > platforms. > > Hmm, I see that you preserved the ABI of mcontext by just copying the > doubles. I think you should do the same for 'struct fpreg' restoring its > ABI and we can use MD ptrace requests to fetch the VSX state. This is what > Linux effectively does. > Drat. I hadn't appreciated that fpreg was part of the public API when I wrote this code! It would be easy enough to follow what mcontext does, and that seems like the right solution, but I won't have time for a couple of weeks at least. If you do have time, I would be happy to review and/or polish patches before that. Thanks for catching this! -Nathan