From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [IPv6:2610:1c1:1:606c::19:2]) by sourceware.org (Postfix) with ESMTPS id E27323857805 for ; Wed, 18 May 2022 21:53:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E27323857805 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id BAD5E99206; Wed, 18 May 2022 21:53:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4L3RYn4RGXz4fWS; Wed, 18 May 2022 21:53:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652910781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YGYpxZ4eMucNvPsO5o/C8m/5UFPjoLCUGsCtzjvNJCo=; b=Wj6l7doMD7BhBAeBXoO5A3Zwm94jZN14V1Bt/FakJlz0F1OGkxVE6rv+SVQiEHFu++RsJS qdxHfXzb+sfwFylgZnXflrC1rcSNH7UNVm6MZdircp7UawxIkSzkBw61xuYJuMYwWOPewZ /VXe9pTu1ORX+mPRzz8QPwlarFvG3uMkVLkTtsIRYSdXfddtPwNj//SNXVXTd5lFOX67Ya 1g+nGHdRdgu1kserMNNomo8uY8lguWaE9S8QuIqCupNI+RKIZc5WBHq7hCPqP2HPOe0pcn F+30sEfe4WktiZ04RojB9oW9wURgelnkRElCd9GvlqiaSl01CJ77Vsk7X8lLNA== Received: from [IPV6:2601:648:8680:ed60:8ce3:c94a:ed81:31cb] (unknown [IPv6:2601:648:8680:ed60:8ce3:c94a:ed81:31cb]) (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 2B97826652; Wed, 18 May 2022 21:53:01 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: Date: Wed, 18 May 2022 14:53:00 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v3 00/13] Handle variable XSAVE layouts Content-Language: en-US From: John Baldwin To: gdb-patches@sourceware.org References: <20220503210515.30739-1-jhb@FreeBSD.org> In-Reply-To: <20220503210515.30739-1-jhb@FreeBSD.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1652910781; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YGYpxZ4eMucNvPsO5o/C8m/5UFPjoLCUGsCtzjvNJCo=; b=KjgWA4ehkjIIJpvwulYTqRPVObsWvblBrMNw9YvcS9vyMzhKUe/M9F4WbB4ylZ76B24qjq Wdz6+jZsUyICJJhsp2YfE/xTiA2n2RsFD5NJQOyGf2jPZA3Ryh/kSBBJi9vvTgIYvSIKlz UCV+RnqyZD8HGPXUUgcX6R2G0HcnXWllk+LWhuLceUmnPaGoQBlxKyiXXhPVjiX8v+QL5M uKm5VlWHHOE9Evej0vMvFcOj6Sl/y56g2ywlJM/VW5wfpzHhU8dlsruoXDxhGcpthP+H7u JnQZmDIEG/P72EjDPU64jVfUWRj9Wy66WebLydaaeF6ykNaEtjmRyxmoF0CMDw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1652910781; a=rsa-sha256; cv=none; b=KGhyt64AuHHMaWF7L7YzkmX+FcCIAembceBHtwwUZYL36mr2Lf50Rm87Y+GkL+U4cvUHB/ G8Q4MSPg7pHASyLsoh5/lsmCfo0zs+7j1wV/yB6N5SH+dGRimUz5gfKS+o0240dhQBeF6t ghuDU7KycK1P4gCk6kr3exHMSK2PabgjvX840z480YTqZz2ysYuAdFz4AckQem7vvJSOs/ u0NkPzH1eDCF/YT1vEm/unj9VEojPaX0ND6VPA7Kgy2uFhuG/acSxrCn/VNfPw3r/JRWC7 14wcsn9jbMx3IHee8wrJJWibe7S5LkXiJ+cE/gXKjJekJFg+RlELbRQ0zMtP/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-6.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 May 2022 21:53:03 -0000 Felix, Did you have any thoughts on this series? I had tried to cc you on it, but that didn't succeed it seems. This does have some conflicts with your AMX series, but those should be minor to resolve. On 5/3/22 2:05 PM, John Baldwin wrote: > Changes since V2: > > - Pulled in some of the changes from Intel's branch Felix pointed me > at, in particular gdbserver support. However, relative to that > branch these patches make the following changes: > > - The i387_* structs and class remain in gdbserver/i387-fp.cc > rather than moving to gdbsupport/. > > - Rather than invoking cpuid each time an XSAVE area is parsed, > the x86_xsave_layout structure is used to hold offsets and > CPUID is only invoked the first time NT_X86_XSTATE is probed > with the offsets cached for later use. > > - I did not update the ChangeLog bits of these log messages, but > probably they can be dropped for the Intel commits as GDB > commits generally do not include these now? > > - Added Linux support both for gdbarches and the x86 native targets. > I wasn't sure if PT_GETREGSET on Linux provides a way to query the > size of the XSAVE register set (on FreeBSD PT_GETREGSET returns > the register set's size in iov_len of the passed-in iovec if the > original iovec has a NULL pointer and zero length), so I used > cpuid leaf 0xd subleaf 0x0 to query the size of the register set > for the native targets as well as for the Linux gdbserver support. > > Note that this still depends on the size and xcr0 mask heuristic for > Linux and FreeBSD core dumps to determine the layout (and I have not > added any additional layouts as I wasn't sure if Jini was intending to > add additional AMD-specific layouts). I'd kind of like to land this > series before doing a followup to flesh out a new core dump note. > > I think for the new core dump note what I would propose is a simple > array of CPUID results for sub-leaves of the 0xd leaf (as a > NT_X86_XSTATE_CPUID or the like) where each entry in the array > contained the subleaf as well as eax, ebx, ecx, and edx results. This > note might even eventually permit handling "compact" XSTATE in future > core dumps rather than only "standard". > > I have tested this on both an AMD Ryzen 9 5900X and Intel Core > i7-8650U on FreeBSD/amd64 as well as on a Linux/x86-64 VM on the Intel > system. I also tested FreeBSD/i386 in a VM on the AMD system. > > Aleksandar Paunovic (2): > gdbserver: Refactor the legacy region within the xsave struct > gdbserver: Read offsets of the XSAVE extended region via CPUID > > John Baldwin (11): > x86: Add an x86_xsave_layout structure to handle variable XSAVE > layouts. > core: Support fetching TARGET_OBJECT_X86_XSAVE_LAYOUT from > architectures. > nat/x86-cpuid.h: Add x86_cpuid_count wrapper around __get_cpuid_count. > x86 nat: Add helper functions to save the XSAVE layout for the host. > gdb: Update x86 FreeBSD architectures to support XSAVE layouts. > gdb: Support XSAVE layouts for the current host in the FreeBSD x86 > targets. > gdb: Update x86 Linux architectures to support XSAVE layouts. > gdb: Support XSAVE layouts for the current host in the Linux x86 > targets. > gdb: Use x86_xstate_layout to parse the XSAVE extended state area. > gdbserver: Add a function to set the XSAVE mask and size. > x86: Remove X86_XSTATE_SIZE and related constants. > > gdb/amd64-fbsd-nat.c | 40 +-- > gdb/amd64-fbsd-tdep.c | 8 +- > gdb/amd64-linux-nat.c | 6 +- > gdb/amd64-linux-tdep.c | 8 +- > gdb/configure.nat | 8 +- > gdb/corelow.c | 22 ++ > gdb/gdbarch-components.py | 13 + > gdb/gdbarch-gen.h | 10 + > gdb/gdbarch.c | 32 +++ > gdb/i386-fbsd-nat.c | 39 +-- > gdb/i386-fbsd-tdep.c | 37 ++- > gdb/i386-fbsd-tdep.h | 6 + > gdb/i386-linux-nat.c | 8 +- > gdb/i386-linux-tdep.c | 34 ++- > gdb/i386-linux-tdep.h | 6 + > gdb/i386-tdep.c | 36 ++- > gdb/i386-tdep.h | 3 + > gdb/i387-tdep.c | 493 ++++++++++++++++++++++++------------- > gdb/i387-tdep.h | 8 + > gdb/nat/x86-cpuid.h | 27 ++ > gdb/nat/x86-xstate.c | 65 +++++ > gdb/nat/x86-xstate.h | 35 +++ > gdb/target.h | 2 + > gdb/x86-fbsd-nat.c | 51 ++++ > gdb/x86-fbsd-nat.h | 29 ++- > gdb/x86-linux-nat.c | 33 +++ > gdb/x86-linux-nat.h | 11 + > gdbserver/configure.srv | 12 +- > gdbserver/i387-fp.cc | 312 ++++++++++++++--------- > gdbserver/i387-fp.h | 2 +- > gdbserver/linux-x86-low.cc | 10 +- > gdbsupport/x86-xstate.h | 69 ++++-- > 32 files changed, 1067 insertions(+), 408 deletions(-) > create mode 100644 gdb/nat/x86-xstate.c > create mode 100644 gdb/nat/x86-xstate.h > -- John Baldwin