From: Simon Marchi <simon.marchi@polymtl.ca>
To: John Baldwin <jhb@FreeBSD.org>, gdb-patches@sourceware.org
Cc: Aleksandar Paunovic <aleksandar.paunovic@intel.com>
Subject: Re: [PATCH v6 01/15] x86: Add an x86_xsave_layout structure to handle variable XSAVE layouts.
Date: Wed, 26 Jul 2023 15:22:06 -0400 [thread overview]
Message-ID: <00492b34-3d4d-6584-cce7-1624326908f0@polymtl.ca> (raw)
In-Reply-To: <20230714155151.21723-2-jhb@FreeBSD.org>
On 7/14/23 11:51, John Baldwin wrote:
> The standard layout of the XSAVE extended state area consists of three
> regions. The first 512 bytes (legacy region) match the layout of the
> FXSAVE instruction including floating point registers, MMX registers,
> and SSE registers. The next 64 bytes (XSAVE header) contains a header
> with a fixed layout. The final region (extended region) contains zero
> or more optional state components. Examples of these include the
> upper 128 bits of YMM registers for AVX.
>
> These optional state components generally have an
> architecturally-fixed size, but they are not assigned architectural
> offsets in the extended region. Instead, processors provide
> additional CPUID leafs describing the size and offset of each
> component in the "standard" layout for a given CPU. (There is also a
> "compact" format which uses an alternate layout, but existing OS's
> currently export the "standard" layout when exporting XSAVE data via
> ptrace() and core dumps.)
>
> To date, GDB has assumed the layout used on current Intel processors
> for state components in the extended region and hardcoded those
> offsets in the tables in i387-tdep.c and i387-fp.cc. However, this
> fails on recent AMD processors which use a different layout.
> Specifically, AMD Zen3 and later processors do not leave space for the
> MPX register set in between the AVX and AVX512 register sets.
>
> To rectify this, add an x86_xsave_layout structure which contains the
> total size of the XSAVE extended state area as well as the offset of
> each known optional state component.
>
> Subsequent commits will modify XSAVE parsing in both gdb and gdbserver
> to use x86_xsave_layout.
>
> Co-authored-by: Aleksandar Paunovic <aleksandar.paunovic@intel.com>
> ---
> gdbsupport/x86-xstate.h | 65 +++++++++++++++++++++++++++++++++++------
> 1 file changed, 56 insertions(+), 9 deletions(-)
>
> diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
> index b8740fd8701..27fc0bd12f2 100644
> --- a/gdbsupport/x86-xstate.h
> +++ b/gdbsupport/x86-xstate.h
> @@ -20,22 +20,69 @@
> #ifndef COMMON_X86_XSTATE_H
> #define COMMON_X86_XSTATE_H
>
> +/* The extended state feature IDs in the state component bitmap. */
> +#define X86_XSTATE_X87_ID 0
> +#define X86_XSTATE_SSE_ID 1
> +#define X86_XSTATE_AVX_ID 2
> +#define X86_XSTATE_BNDREGS_ID 3
> +#define X86_XSTATE_BNDCFG_ID 4
> +#define X86_XSTATE_K_ID 5
> +#define X86_XSTATE_ZMM_H_ID 6
> +#define X86_XSTATE_ZMM_ID 7
> +#define X86_XSTATE_PKRU_ID 9
> +
> /* The extended state feature bits. */
> -#define X86_XSTATE_X87 (1ULL << 0)
> -#define X86_XSTATE_SSE (1ULL << 1)
> -#define X86_XSTATE_AVX (1ULL << 2)
> -#define X86_XSTATE_BNDREGS (1ULL << 3)
> -#define X86_XSTATE_BNDCFG (1ULL << 4)
> +#define X86_XSTATE_X87 (1ULL << X86_XSTATE_X87_ID)
> +#define X86_XSTATE_SSE (1ULL << X86_XSTATE_SSE_ID)
> +#define X86_XSTATE_AVX (1ULL << X86_XSTATE_AVX_ID)
> +#define X86_XSTATE_BNDREGS (1ULL << X86_XSTATE_BNDREGS_ID)
> +#define X86_XSTATE_BNDCFG (1ULL << X86_XSTATE_BNDCFG_ID)
> #define X86_XSTATE_MPX (X86_XSTATE_BNDREGS | X86_XSTATE_BNDCFG)
>
> /* AVX 512 adds three feature bits. All three must be enabled. */
> -#define X86_XSTATE_K (1ULL << 5)
> -#define X86_XSTATE_ZMM_H (1ULL << 6)
> -#define X86_XSTATE_ZMM (1ULL << 7)
> +#define X86_XSTATE_K (1ULL << X86_XSTATE_K_ID)
> +#define X86_XSTATE_ZMM_H (1ULL << X86_XSTATE_ZMM_H_ID)
> +#define X86_XSTATE_ZMM (1ULL << X86_XSTATE_ZMM_ID)
> #define X86_XSTATE_AVX512 (X86_XSTATE_K | X86_XSTATE_ZMM_H \
> | X86_XSTATE_ZMM)
>
> -#define X86_XSTATE_PKRU (1ULL << 9)
> +#define X86_XSTATE_PKRU (1ULL << X86_XSTATE_PKRU_ID)
> +
> +/* Size and offsets of register states in the XSAVE area extended
> + region. Offsets are set to 0 to indicate the absence of the
> + associated registers. */
Extreme comment nitpick. In "Size and offsets", one is singular and the
other is plural. Should it be "Sizes and offsets", or "Size and
offset"?
In any case:
Approved-By: Simon Marchi <simon.marchi@efficios.com>
Simon
next prev parent reply other threads:[~2023-07-26 19:22 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 15:51 [PATCH v6 00/15] Handle " John Baldwin
2023-07-14 15:51 ` [PATCH v6 01/15] x86: Add an x86_xsave_layout structure to handle " John Baldwin
2023-07-26 19:22 ` Simon Marchi [this message]
2023-07-26 21:27 ` John Baldwin
2023-07-26 22:51 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 02/15] gdb: Store an x86_xsave_layout in i386_gdbarch_tdep John Baldwin
2023-07-14 15:51 ` [PATCH v6 03/15] core: Support fetching x86 XSAVE layout from architectures John Baldwin
2023-07-26 19:37 ` Simon Marchi
2023-07-26 21:28 ` John Baldwin
2023-07-14 15:51 ` [PATCH v6 04/15] nat/x86-cpuid.h: Add x86_cpuid_count wrapper around __get_cpuid_count John Baldwin
2023-07-26 19:41 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 05/15] x86 nat: Add helper functions to save the XSAVE layout for the host John Baldwin
2023-07-26 19:48 ` Simon Marchi
2023-07-26 21:37 ` John Baldwin
2023-07-14 15:51 ` [PATCH v6 06/15] gdb: Update x86 FreeBSD architectures to support XSAVE layouts John Baldwin
2023-07-26 20:04 ` Simon Marchi
2023-07-26 21:43 ` John Baldwin
2023-07-28 21:23 ` [PATCH v6a " John Baldwin
2023-08-28 16:01 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 07/15] gdb: Support XSAVE layouts for the current host in the FreeBSD x86 targets John Baldwin
2023-07-26 20:26 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 08/15] gdb: Update x86 Linux architectures to support XSAVE layouts John Baldwin
2023-07-26 20:45 ` Simon Marchi
2023-07-26 21:16 ` John Baldwin
2023-07-27 21:48 ` Simon Marchi
2023-07-28 16:30 ` John Baldwin
2023-07-28 17:58 ` Simon Marchi
2023-07-28 21:30 ` John Baldwin
2023-07-28 21:29 ` [PATCH v6a " John Baldwin
2023-08-14 17:52 ` John Baldwin
2023-08-28 16:21 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 09/15] gdb: Support XSAVE layouts for the current host in the Linux x86 targets John Baldwin
2023-07-26 20:51 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 10/15] gdb: Use x86_xstate_layout to parse the XSAVE extended state area John Baldwin
2023-08-28 16:34 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 11/15] gdbserver: Add a function to set the XSAVE mask and size John Baldwin
2023-08-28 16:46 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 12/15] gdbserver: Refactor the legacy region within the xsave struct John Baldwin
2023-08-28 16:50 ` Simon Marchi
2023-08-28 17:32 ` John Baldwin
2023-07-14 15:51 ` [PATCH v6 13/15] gdbserver: Use x86_xstate_layout to parse the XSAVE extended state area John Baldwin
2023-08-28 18:15 ` Simon Marchi
2023-08-28 18:37 ` John Baldwin
2023-07-14 15:51 ` [PATCH v6 14/15] x86: Remove X86_XSTATE_SIZE and related constants John Baldwin
2023-08-28 20:38 ` Simon Marchi
2023-07-14 15:51 ` [PATCH v6 15/15] gdbserver: Simplify handling of ZMM registers John Baldwin
2023-08-28 20:57 ` Simon Marchi
2023-07-14 15:58 ` [PATCH v6 00/15] Handle variable XSAVE layouts John Baldwin
2023-07-26 8:31 ` Willgerodt, Felix
2023-07-25 17:17 ` Keith Seitz
2023-07-25 18:15 ` John Baldwin
2023-07-25 18:43 ` Keith Seitz
2023-07-25 18:59 ` John Baldwin
2023-07-25 20:42 ` Keith Seitz
2023-07-25 22:05 ` John Baldwin
2023-07-26 22:31 ` John Baldwin
2023-07-27 21:36 ` Keith Seitz
2023-07-28 16:35 ` 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=00492b34-3d4d-6584-cce7-1624326908f0@polymtl.ca \
--to=simon.marchi@polymtl.ca \
--cc=aleksandar.paunovic@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).