From owner-svn-src-head@freebsd.org Thu Aug 2 17:52:49 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 8119E106E05E; Thu, 2 Aug 2018 17:52:49 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from mail.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (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 2AEC773994; Thu, 2 Aug 2018 17:52:49 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from John-Baldwins-MacBook-Pro-2.local (ralph.baldwin.cx [66.234.199.215]) by mail.baldwin.cx (Postfix) with ESMTPSA id D6DB310B429; Thu, 2 Aug 2018 13:52:47 -0400 (EDT) Subject: Re: svn commit: r337127 - head/sys/riscv/riscv To: Konstantin Belousov References: <201808021213.w72CDqQV065424@repo.freebsd.org> <7842b7e4-d14e-805f-719e-b393fc80b74c@FreeBSD.org> <20180802155030.GA40119@kib.kiev.ua> Cc: Ruslan Bukin , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org From: John Baldwin Message-ID: <22f6c1e0-11c2-8421-2a27-6ba59ef7b6dc@FreeBSD.org> Date: Thu, 2 Aug 2018 10:52:46 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180802155030.GA40119@kib.kiev.ua> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mail.baldwin.cx); Thu, 02 Aug 2018 13:52:48 -0400 (EDT) X-Virus-Scanned: clamav-milter 0.99.2 at mail.baldwin.cx X-Virus-Status: Clean 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, 02 Aug 2018 17:52:49 -0000 On 8/2/18 8:50 AM, Konstantin Belousov wrote: > On Thu, Aug 02, 2018 at 08:16:59AM -0700, John Baldwin wrote: >> On 8/2/18 5:13 AM, Ruslan Bukin wrote: >>> Author: br >>> Date: Thu Aug 2 12:13:52 2018 >>> New Revision: 337127 >>> URL: https://svnweb.freebsd.org/changeset/base/337127 >>> >>> Log: >>> Don't overwrite tp in set_mcontext(). >>> >>> This makes libthr/swapcontext_test:swapcontext1 happy. >>> >>> Sponsored by: DARPA, AFRL >> >> This seems a bit odd. Is get_mcontext() not setting gp_tp correctly, or is >> makecontext() not preserving it perhaps? >> >> In general I feel like we should be saving/restoring 'tp' in the trapframe >> on kernel entry/exit like other GPRs instead of in the pcb and then >> including it in 'struct reg'. This makes it possible for debuggers to >> handle TLS variables more sanely (and in general we need to fix the various >> struct reg in FreeBSD architectures to include TLS registers when possible, >> such as adding fs_base and gs_base on x86). It would be nice if RISC-V >> started off on the correct foot here. > > I wanted to do this on x86, but I gave up due to the ABI issues. > When FSGSBASE instructions are supported on amd64, we save base > on context switch and restore on return to usermode. For struct reg Linux has done the equivalent of adding fs_base/gs_base if that is the ABI issues. Cores are pretty easy as debuggers can use the note size to determine if fs_base/gs_base are present and old debuggers will just ignore the larger notes. However, PT_GETREGS and PT_SETREGS is more of a pain. Probably we should define a "register set" API for ptrace() which I've been kicking around in my head that includes a way to communicate the size of the register block. I think Linux uses 'data' for it's register set ptrace ops to specify the register size. I think I'd like to be able to use 'data' for the userland size and instead borrow N upper bits in the ptrace op as the register set identifier. Either that or the 'addr' would need to start pointing to an indirect structure when working with a register set. -- John Baldwin