public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@polymtl.ca>
To: John Baldwin <jhb@FreeBSD.org>, gdb-patches@sourceware.org
Cc: Willgerodt@smtp.polymtl.ca, Felix <felix.willgerodt@intel.com>,
	George@smtp.polymtl.ca, Jini Susan <JiniSusan.George@amd.com>
Subject: Re: [RFC 00/13] Proposal for a new NT_X86_CPUID core dump note
Date: Thu, 12 Oct 2023 00:01:11 -0400	[thread overview]
Message-ID: <79fd06f3-a821-46d1-8f03-b91d1ad79ddb@polymtl.ca> (raw)
In-Reply-To: <20231009183617.24862-1-jhb@FreeBSD.org>



On 2023-10-09 14:36, John Baldwin wrote:
> One of the shortcomings of the previous XSAVE patch series is that it
> depends on heuristics based on the total XSAVE register set size and
> XCR0 mask to infer layouts of the various register blocks for core
> dumps.  This series introduces a new x86-specific core dump note
> intended to supplant these heuristics by storing the raw CPUID leaves
> describing the XSAVE layout in core dumps.
> 
> This series proposes a new core dump note, NT_X86_CPUID (0x205), which
> contains an array of structures.  Each structure describes an invidual
> CPUID sub-leaf containing both the inputs to CPUID (%eax and %ecx) and
> the outputs (%eax, %ebx, %ecx, and %edx) in a format roughly matching
> the follow C structure:
> 
> struct cpuid_leaf
> {
>     uint32_t leaf;
>     uint32_t subleaf;
>     uint32_t eax;
>     uint32_t ebx;
>     uint32_t ecx;
>     uint32_t edx;
> };
> 
> This format is not XSAVE-specific and implementations could choose to
> add additional CPUID leaves to this structure if needed in the future.
> Consumers of this note should lookup the value of required leaves and
> ignore any unneeded leaves.
> 
> An alternate approach might be to write out a more XSAVE-specific note
> that is an array containing the offset and size of each XSAVE region.
> 
> Note that either approach would enable storing XSAVE notes in the
> "compact" format at some point in the future.
> 
> This series adds support for reading/writing the note to binutils as
> well as suport for parsing and generating the note in GDB.  It also
> hooks this into both the FreeBSD and Linux x86 architectures in GDB to
> read the XSAVE layout from this note when present, and to write out a
> note when generating a core via `gcore'.  I've done some limited
> testing on FreeBSD/amd64 and Linux/x86-64, but it could probably use
> some more testing on Linux in particular.  (I know Simon has an AMD
> machine with a layout not handled by the current heuristics for
> example.)

I suppose you are referring to this one, which has support for PKRU but
where PKRU is not enabled (for a reason I don't know), leading to the
total sizes being different (832 vs 896):

   XSAVE features (0xd/0):
      XCR0 valid bit field mask               = 0x0000000000000207
         x87 state                            = true
         SSE state                            = true
         AVX state                            = true
         MPX BNDREGS                          = false
         MPX BNDCSR                           = false
         AVX-512 opmask                       = false
         AVX-512 ZMM_Hi256                    = false
         AVX-512 Hi16_ZMM                     = false
         PKRU state                           = true
         XTILECFG state                       = false
         XTILEDATA state                      = false
      bytes required by fields in XCR0        = 0x00000340 (832)
      bytes required by XSAVE/XRSTOR area     = 0x00000380 (896)

That machine's layout is handled by the heuristic since commit:

  gdb/x86: use size of XSAVE area of enabled features
  https://gitlab.com/gnutools/binutils-gdb/-/commit/054f25955c2b77f6e21073bfdd70a60e9df1ffe7

But anyhow, I can use it for testing.

> For the gcore side, a new TARGET_OBJECT_X86_CPUID is used to fetch the
> current note contents from a native target.  There is still one gap
> even with this patch series which is that if you are connected to a
> remote target (e.g. gdbserver), we currently do not have a known XSAVE
> layout to use when writing out a core via `gcore'.  One option that
> would close this gap would be to extend the remote protocol to permit
> reading this new object from a debug server.  The remote target could
> then implement fetching this object and also make use of this object
> to implement the target::fetch_x86_xsave_layout method which would
> close that gap.  Another possibility would be to just pick a "known"
> XSAVE format that matches one of the heuristics.

I think it would make sense to send the CPUID info over the wire.  Can
it be extra data in the target description XML?  Otherwise, a new
qxfer packet I suppose.

If the current GDBserver doesn't support sending the CPUID info, I'm not
sure I would make the remote target write a CPUID note based on a
heuristic.  It has pros and cons, we can talk about that when we get
there.

Simon

  parent reply	other threads:[~2023-10-12  4:01 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-09 18:36 John Baldwin
2023-10-09 18:36 ` [RFC 01/13] binutils: Support for the " John Baldwin
2023-10-16  9:23   ` Lancelot SIX
2023-10-16 23:23     ` John Baldwin
2023-10-09 18:36 ` [RFC 02/13] i387-tdep: Add function to read XSAVE layout from NT_X86_CPUID John Baldwin
2023-10-12  4:27   ` Simon Marchi
2023-10-16 23:52     ` John Baldwin
2023-10-16  9:17   ` Lancelot SIX
2023-10-17  0:04     ` John Baldwin
2023-10-09 18:36 ` [RFC 03/13] gdb: Use NT_X86_CPUID in x86 FreeBSD architectures to read XSAVE layouts John Baldwin
2023-10-09 18:36 ` [RFC 04/13] " John Baldwin
2023-10-12  4:28   ` Simon Marchi
2023-10-17  0:07     ` John Baldwin
2023-10-09 18:36 ` [RFC 05/13] nat/x86-cpuid.h: Remove non-x86 fallbacks John Baldwin
2023-10-12  4:29   ` Simon Marchi
2023-10-09 18:36 ` [RFC 06/13] nat/x86-cpuid: Add a function to build the contents of a NT_X86_CPUID note John Baldwin
2023-10-12  4:41   ` Simon Marchi
2023-10-17  0:22     ` John Baldwin
2023-10-09 18:36 ` [RFC 07/13] x86_elf_make_cpuid_note: Helper routine to build NT_X86_CPUID ELF note John Baldwin
2023-10-09 18:36 ` [RFC 08/13] x86-fbsd-nat: Support fetching TARGET_OBJECT_X86_CPUID objects John Baldwin
2023-10-09 18:36 ` [RFC 09/13] fbsd-tdep: Export fbsd_make_corefile_notes John Baldwin
2023-10-09 18:36 ` [RFC 10/13] {amd64,i386}-fbsd-tdep: Include NT_X86_CPUID notes in core dumps from gcore John Baldwin
2023-10-16  9:31   ` [RFC 10/13] {amd64, i386}-fbsd-tdep: " Lancelot SIX
2023-10-17  0:26     ` John Baldwin
2023-10-09 18:36 ` [RFC 11/13] x86-linux-nat: Support fetching TARGET_OBJECT_X86_CPUID objects John Baldwin
2023-10-09 18:36 ` [RFC 12/13] linux-tdep: Export linux_make_corefile_notes John Baldwin
2023-10-09 18:36 ` [RFC 13/13] {amd64,i386}-linux-tdep: Include NT_X86_CPUID notes in core dumps from gcore John Baldwin
2023-10-10 16:30 ` [RFC 00/13] Proposal for a new NT_X86_CPUID core dump note George, Jini Susan
2023-10-12  4:01 ` Simon Marchi [this message]
2023-10-12 14:33 ` Simon Marchi
2023-10-12 17:18   ` John Baldwin
2023-10-13  9:38     ` George, Jini Susan
2023-10-17  0:36       ` John Baldwin
2023-10-26 16:18         ` George, Jini Susan
2023-10-27  2:53           ` John Baldwin
2023-10-27 11:11             ` George, Jini Susan
2023-10-31 16:41               ` John Baldwin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=79fd06f3-a821-46d1-8f03-b91d1ad79ddb@polymtl.ca \
    --to=simon.marchi@polymtl.ca \
    --cc=George@smtp.polymtl.ca \
    --cc=JiniSusan.George@amd.com \
    --cc=Willgerodt@smtp.polymtl.ca \
    --cc=felix.willgerodt@intel.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).