Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Joos, Christina" <christina.joos@intel.com>
To: "Rohr, Stephan" <stephan.rohr@intel.com>,
	"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: "pedro@palves.net" <pedro@palves.net>,
	"eliz@gnu.org" <eliz@gnu.org>,
	"jhb@FreeBSD.org" <jhb@FreeBSD.org>,
	"luis.machado@arm.com" <luis.machado@arm.com>
Subject: RE: [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers.
Date: Tue, 3 Nov 2026 14:40:35 +0000	[thread overview]
Message-ID: <SN7PR11MB76389F0371C3CEFA716B9AD689692@SN7PR11MB7638.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20261030115016.45786-3-stephan.rohr@intel.com>

> -----Original Message-----
> From: Stephan Rohr <stephan.rohr@intel.com>
> Sent: Freitag, 30. Oktober 2026 12:50
> To: gdb-patches@sourceware.org
> Cc: pedro@palves.net; eliz@gnu.org; jhb@FreeBSD.org;
> luis.machado@arm.com
> Subject: [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers.
> 
> From: Felix Willgerodt <felix.willgerodt@intel.com>
> 
> Intel Advanced Matrix Extensions (AMX) adds one 64-byte TILECFG register
> and eight 1024-byte tile registers TMM0, TMM1, ..., TMM7.  The tile
> registers each represent a matrix, whose dimensions are configured via
> TILECFG.  In XSAVE, all tiles are represented in the 8kB TILEDATA section.
> 
> Future platforms are free to add new palettes, which are run-time
> configurable partitionings of the TILEDATA space.  Currently only
> palette 0 (initialized zero state) and palette 1 exist.  New palettes
> might change any of the following parameters, which are defined in the
> palette_table (which can be accessed via CPUID):
> 
> define palette_table[id]:
> 	uint16_t total_tile_bytes
> 	uint16_t bytes_per_tile
> 	uint16_t bytes_per_row
> 	uint16_t max_names
> 	uint16_t max_rows
> 
> More information about Intel AMX can be found in the Intel Software
> Developer's Manual, September 2026.
> 
> The $tilecfg register is implemented as a pseudo register.  For convenience,
> reserved bytes are not shown.  To also be able to show the full register,
> $tilecfg_raw is implemented as a uint512 value.
> 
> The $tmm0_raw-$tmm7_raw registers hold the contents of the tiles.  Each is
> shown with the maximum dimensions of 16 rows of 64 bytes.  Only the
> elements
> within the dimensions configured in $tilecfg hold data.
> 
> To hide the raw registers, they are added to the "save" and "restore"
> register groups only.  A following patch introduces user registers and adds
> the tile user registers to the "all" group such that the tile registers show
> up in the "info registers all" command.
> 
> Intel AMX is supported for 64-bit only.
> 
> Co-Authored-By: Stephan Rohr <stephan.rohr@intel.com>
> ---
>  gdb/NEWS                             |   5 +
>  gdb/amd64-linux-tdep.c               |   2 +
>  gdb/amd64-tdep.c                     |  67 ++++++++-
>  gdb/amd64-tdep.h                     |   3 +
>  gdb/arch/amd64.c                     |   4 +
>  gdb/arch/x86-linux-tdesc-features.c  |   5 +-
>  gdb/doc/gdb.texinfo                  |  40 ++++++
>  gdb/features/Makefile                |   1 +
>  gdb/features/i386/64bit-amx.c        |  26 ++++
>  gdb/features/i386/64bit-amx.xml      |  26 ++++
>  gdb/i386-tdep.c                      | 132 +++++++++++++++++-
>  gdb/i386-tdep.h                      |  25 +++-
>  gdb/i387-tdep.c                      | 196 +++++++++++++++++++++++++--
>  gdb/i387-tdep.h                      |   6 +
>  gdb/nat/x86-xstate.c                 |   2 +
>  gdb/target-debug.h                   |   2 +
>  gdb/testsuite/gdb.arch/amd64-amx.c   | 115 ++++++++++++++++
>  gdb/testsuite/gdb.arch/amd64-amx.exp | 192
> ++++++++++++++++++++++++++
>  gdb/testsuite/lib/amd64-amx.h        |  41 ++++++
>  gdb/testsuite/lib/gdb.exp            |  75 ++++++++++
>  gdbserver/i387-fp.cc                 |  70 +++++++++-
>  gdbserver/linux-x86-low.cc           |   2 +
>  gdbsupport/x86-xstate.h              |  26 +++-
>  23 files changed, 1042 insertions(+), 21 deletions(-)
>  create mode 100644 gdb/features/i386/64bit-amx.c
>  create mode 100644 gdb/features/i386/64bit-amx.xml
>  create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.c
>  create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.exp
>  create mode 100644 gdb/testsuite/lib/amd64-amx.h
> 
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 7303ec0e460..2047e7376fb 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -7,6 +7,11 @@
>    Support displaying and modifying Intel APX registers (Extended GPRs
>    $r16 - $r31) including byte, word and dword pseudo registers.
> 
> +* Support for Intel AMX registers on GNU/Linux.
> +  Support displaying and modifying Intel AMX raw registers
> +  $tmm0_raw - $tmm7_raw and the $tilecfg_raw register.  The $tilecfg
> +  pseudo register provides a parsed view of the tile configuration.
> +
>  * GDB now distinguishes between the GNU (MinGW) and MSVC Windows
> ABIs.
> 
>    The "set osabi" command accepts two new values, "Windows-GNU" and
> diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
> index 81e66be75c1..28e18ed47d2 100644
> --- a/gdb/amd64-linux-tdep.c
> +++ b/gdb/amd64-linux-tdep.c
> @@ -115,6 +115,8 @@ int amd64_linux_gregset_reg_offset[] =
>    -1, 				/* CET user mode register PL3_SSP.  */
>    -1, -1, -1, -1, -1, -1, -1, -1,     /* r16 ... r31.  */
>    -1, -1, -1, -1, -1, -1, -1, -1,
> +  -1,				/* TILECFG register (AMX).  */
> +  -1, -1, -1, -1, -1, -1, -1, -1,     /* tmm0_raw ... tmm7_raw (AMX).  */
> 
>    /* End of hardware registers */
>    21 * 8, 22 * 8,		      /* fs_base and gs_base.  */
> diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
> index 18b8f2a4c0b..13242e293b5 100644
> --- a/gdb/amd64-tdep.c
> +++ b/gdb/amd64-tdep.c
> @@ -188,6 +188,17 @@ static const char * const amd64_pkeys_names[] = {
>      "pkru"
>  };
> 
> +static const char *amd64_tilecfg_raw_names[] = {
> +    "tilecfg_raw"
> +};
> +
> +/* Register names for the raw AMX tile registers.  */
> +
> +static const char *amd64_tmm_raw_names[] = {
> +    "tmm0_raw", "tmm1_raw", "tmm2_raw", "tmm3_raw",
> +    "tmm4_raw", "tmm5_raw", "tmm6_raw", "tmm7_raw"
> +};
> +
>  /* DWARF Register Number Mapping as defined in the System V psABI,
>     section 3.6.  */
> 
> @@ -429,6 +440,12 @@ static const char * const amd64_apx_dword_names[]
> =
>  static_assert (ARRAY_SIZE (amd64_apx_dword_names)
>  	       == AMD64_APX_NUM_DWORD_REGS + 1);
> 
> +/* Register name for tilecfg pseudo-register.  */
> +
> +static const char *amd64_tilecfg_names[] = {
> +    "tilecfg"
> +};
> +
>  /* Return the name of register REGNUM.  */
> 
>  static const char *
> @@ -441,6 +458,8 @@ amd64_pseudo_register_name (struct gdbarch
> *gdbarch, int regnum)
>      return amd64_ymm_names[regnum - tdep->ymm0_regnum];
>    else if (i386_ymm_avx512_regnum_p (gdbarch, regnum))
>      return amd64_ymm_avx512_names[regnum - tdep->ymm16_regnum];
> +  else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> +    return amd64_tilecfg_names[regnum - tdep->tilecfg_regnum];
>    else if (i386_dword_regnum_p (gdbarch, regnum))
>      return tdep->dword_names[regnum - tdep->eax_regnum];
>    else
> @@ -521,6 +540,22 @@ amd64_pseudo_register_read_value (gdbarch
> *gdbarch, const frame_info_ptr &next_f
>        const int gpnum = amd64_raw_dword_register (tdep, regnum);
>        return pseudo_from_raw_part (next_frame, regnum, gpnum, 0);
>      }
> +  else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> +    {
> +      /* Read tilecfg.  */
> +      value *pseudo_reg_val
> +	= value::allocate_register (next_frame, regnum);
> +      value *raw_reg_val = value_of_register (tdep->tilecfg_raw_regnum,
> +					      next_frame);
> +      /* Copy palette and start_row.  See tilecfg_type ().  */
> +      raw_reg_val->contents_copy (pseudo_reg_val,  0,  0, 2 * 1);
> +      /* Copy all colsb.  */
> +      raw_reg_val->contents_copy (pseudo_reg_val,  2, 16, 2 * 8);
> +      /* Copy all rows.  */
> +      raw_reg_val->contents_copy (pseudo_reg_val, 18, 48, 1 * 8);
> +
> +      return pseudo_reg_val;
> +    }
>    else
>      return i386_pseudo_register_read_value (gdbarch, next_frame, regnum);
>  }
> @@ -547,6 +582,22 @@ amd64_pseudo_register_write (gdbarch *gdbarch,
> const frame_info_ptr &next_frame,
>        const int gpnum = amd64_raw_dword_register (tdep, regnum);
>        pseudo_to_raw_part (next_frame, buf, gpnum, 0);
>      }
> +  else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> +    {
> +      const int raw_reg_num = tdep->tilecfg_raw_regnum;
> +      const int raw_size = register_size (gdbarch, raw_reg_num);
> +      gdb::byte_vector raw_buf (raw_size, 0);
> +      /* Copy palette and start_row.  See tilecfg_type ().  */
> +      memcpy (raw_buf.data (), buf.data (), 2 * 1);
> +      /* Copy all colsb.  */
> +      memcpy (raw_buf.data () + 16, buf.data () + 2, 2 * 8);
> +      /* Copy all rows.  */
> +      memcpy (raw_buf.data () + 48, buf.data () + 18, 1 * 8);
> +
> +      put_frame_register_bytes
> +	(next_frame, raw_reg_num, 0,
> +	 gdb::make_array_view (raw_buf.data (), raw_size));
> +    }
>    else
>      i386_pseudo_register_write (gdbarch, next_frame, regnum, buf);
>  }
> @@ -3706,6 +3757,19 @@ amd64_init_abi (struct gdbarch_info info, struct
> gdbarch *gdbarch,
>        tdep->num_dword_regs = AMD64_NUM_DWORD_REGS;
>      }
> 
> +  if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx") != nullptr)
> +    {
> +      tdep->tilecfg_raw_register_names = amd64_tilecfg_raw_names;
> +      tdep->tilecfg_raw_regnum = AMD64_AMX_TILECFG_RAW_REGNUM;
> +
> +      tdep->tilecfg_register_names = amd64_tilecfg_names;
> +      tdep->num_tilecfg_regs = 1;
> +
> +      tdep->tmm_raw_register_names = amd64_tmm_raw_names;
> +      tdep->tmm_raw_regnum = AMD64_AMX_TMM0_RAW_REGNUM;
> +      tdep->num_tmm_raw_regs = 8;
> +    }
> +
>    /* Avoid wiring in the MMX registers for now.  */
>    tdep->num_mmx_regs = 0;
> 
> @@ -3858,7 +3922,7 @@ const struct target_desc *
>  amd64_target_description (uint64_t xstate_bv, bool segments)
>  {
>    static const_target_desc_up amd64_tdescs \
> -    [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*APX*/] \
> +    [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*APX*/][2/*AMX*/]
> \
>      [2/*segments*/] = {};
>    const_target_desc_up &tdesc
>      = amd64_tdescs[(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
> @@ -3866,6 +3930,7 @@ amd64_target_description (uint64_t xstate_bv, bool
> segments)
>  		  [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
>  		  [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
>  		  [(xstate_bv & X86_XSTATE_APX_F) ? 1 : 0]
> +		  [(xstate_bv & X86_XSTATE_AMX) ? 1 : 0]
>  		  [segments ? 1 : 0];
> 
>    if (tdesc == nullptr)
> diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
> index 93b3cb61b17..02172ccfa14 100644
> --- a/gdb/amd64-tdep.h
> +++ b/gdb/amd64-tdep.h
> @@ -84,6 +84,9 @@ enum amd64_regnum
>    AMD64_PL3_SSP_REGNUM,
>    AMD64_R16_REGNUM,
>    AMD64_R31_REGNUM = AMD64_R16_REGNUM + 15,
> +  AMD64_AMX_TILECFG_RAW_REGNUM,
> +  AMD64_AMX_TMM0_RAW_REGNUM,
> +  AMD64_AMX_TMM7_RAW_REGNUM =
> AMD64_AMX_TMM0_RAW_REGNUM + 7,
>    AMD64_FSBASE_REGNUM,
>    AMD64_GSBASE_REGNUM
>  };
> diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
> index 3992bbf512e..60932f420b3 100644
> --- a/gdb/arch/amd64.c
> +++ b/gdb/arch/amd64.c
> @@ -22,6 +22,7 @@
> 
>  #include "../features/i386/64bit-avx.c"
>  #include "../features/i386/64bit-avx512.c"
> +#include "../features/i386/64bit-amx.c"
>  #include "../features/i386/64bit-core.c"
>  #include "../features/i386/64bit-apx.c"
>  #include "../features/i386/64bit-linux.c"
> @@ -82,5 +83,8 @@ amd64_create_target_description (uint64_t xstate_bv,
> bool is_x32,
>    if (xstate_bv & X86_XSTATE_APX_F)
>      regnum = create_feature_i386_64bit_apx (tdesc.get (), regnum);
> 
> +  if (xstate_bv & X86_XSTATE_AMX)
> +    regnum = create_feature_i386_64bit_amx (tdesc.get (), regnum);
> +
>    return tdesc;
>  }
> diff --git a/gdb/arch/x86-linux-tdesc-features.c b/gdb/arch/x86-linux-tdesc-
> features.c
> index 0191f326834..90722d4dd58 100644
> --- a/gdb/arch/x86-linux-tdesc-features.c
> +++ b/gdb/arch/x86-linux-tdesc-features.c
> @@ -66,6 +66,7 @@ struct x86_xstate_feature {
>  static constexpr x86_xstate_feature x86_linux_all_xstate_features[] = {
>    /* Feature,           i386,	amd64,	x32.  */
>    { X86_XSTATE_APX_F,	false,	true, 	true },
> +  { X86_XSTATE_AMX,	false,	true, 	true },
>    { X86_XSTATE_CET_U,	false,	true, 	true },
>    { X86_XSTATE_PKRU,	true,	true, 	true },
>    { X86_XSTATE_AVX512,	true,	true, 	true },
> @@ -155,8 +156,8 @@ x86_linux_xstate_bv_to_tdesc_idx (uint64_t
> xstate_bv)
>       represents the bit order within the generated index number.
> 
>       i386  | x87 sse avx avx512 pkru
> -     amd64 |         avx avx512 pkru
> -     i32   |         avx avx512 pkru
> +     amd64 |         avx avx512 pkru amx
> +     i32   |         avx avx512 pkru amx
> 
>       The features are ordered so that for each mode (i386, amd64, i32) the
>       generated index will form a continuous range.  */
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 53773780b56..9e3b6fca669 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -27448,6 +27448,41 @@ stack.  @value{GDBN} corrects this value to
> avoid a control protection
>  exception.  For more details on displaced stepping, see @ref{displaced-
> stepping}.
>  @end itemize
> 
> +@subsubsection Intel Advanced Matrix Extensions
> +@cindex Intel Advanced Matrix Extensions
> +@cindex AMX, Intel
> +
> +Intel @dfn{Advanced Matrix Extensions} (@acronym{AMX}) add one 64-byte
> +@samp{tilecfg} register and eight 1024-byte tile registers @samp{tmm0},
> +@samp{tmm1}, @dots{}, @samp{tmm7} for amd64.  The tile registers each
> +represent a matrix, whose dimensions are configured via @samp{tilecfg}.
> +Future platforms might also partition the register area of 8192 bytes
> +between a different number of tiles.
> +
> +@value{GDBN} provides a user-friendly view of the @samp{tilecfg} register,
> +omitting reserved bits.  The tile registers are supplied as the raw registers
> +@samp{tmm0_raw}, @samp{tmm1_raw}, @dots{}, @samp{tmm7_raw},
> which show the
> +contents of a tile with its maximum dimensions of @w{16 rows} of
> +@w{64 bytes}.  The raw tile registers hold one @code{uint512} per row and
> only
> +the elements within the dimensions configured in @samp{tilecfg} hold data.
> +For example:
> +
> +@smallexample
> +(gdb) print/x $tilecfg_raw
> +$1 =
> 0x10201000000000000000000000000000000000000000000000000000000
> 0c0
> +  00c000800000000000000000000000000000001
> +(gdb) print $tilecfg
> +$2 = @{palette = 1, start_row = 0, colsb = @{8, 12, 12, 0, 0, 0, 0, 0@},
> +  rows = @{1, 2, 1, 0, 0, 0, 0, 0@}@}
> +(gdb) print $tmm1_raw
> +$3 = @{621397352980713455329738752,
> 932096029507240269422067969,
> +  0 <repeats 14 times>@}
> +(gdb) print/d (uint8_t[16][64]) $tmm1_raw
> +$4 = @{@{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0 <repeats 52 times>@},
> +  @{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>@},
> +  @{0 <repeats 64 times>@} <repeats 14 times>@}
> +@end smallexample
> +
>  @node Alpha
>  @subsection Alpha
> 
> @@ -50888,6 +50923,11 @@ The @samp{org.gnu.gdb.i386.apx} feature is
> optional.  It should describe
>  @samp{r16} - @samp{r31} with 64 bits each.  All Intel @acronym{APX}
>  registers are valid only on amd64.
> 
> +The @samp{org.gnu.gdb.i386.amx} feature is optional.  It should describe
> +one configuration register @samp{tilecfg_raw} that has 64 bytes, and the
> +eight tile registers @samp{tmm0_raw} @dots{} @samp{tmm7_raw}, each of
> which
> +has 1024 bytes.  All Intel @acronym{AMX} registers are valid only for amd64.
> +
>  @node LoongArch Features
>  @subsection LoongArch Features
>  @cindex target descriptions, LoongArch Features
> diff --git a/gdb/features/Makefile b/gdb/features/Makefile
> index 0ab24bca000..15e715aab70 100644
> --- a/gdb/features/Makefile
> +++ b/gdb/features/Makefile
> @@ -241,6 +241,7 @@ FEATURE_XMLFILES = aarch64-core.xml \
>  	i386/64bit-core.xml \
>  	i386/64bit-segments.xml \
>  	i386/64bit-avx.xml \
> +	i386/64bit-amx.xml \
>  	i386/64bit-linux.xml \
>  	i386/64bit-sse.xml \
>  	i386/pkeys.xml \
> diff --git a/gdb/features/i386/64bit-amx.c b/gdb/features/i386/64bit-amx.c
> new file mode 100644
> index 00000000000..14779ec1fb7
> --- /dev/null
> +++ b/gdb/features/i386/64bit-amx.c
> @@ -0,0 +1,26 @@
> +/* THIS FILE IS GENERATED.  -*- buffer-read-only: t -*- vi:set ro:
> +  Original: 64bit-amx.xml */
> +
> +#include "gdbsupport/tdesc.h"
> +
> +static int
> +create_feature_i386_64bit_amx (struct target_desc *result, long regnum)
> +{
> +  struct tdesc_feature *feature;
> +
> +  feature = tdesc_create_feature (result, "org.gnu.gdb.i386.amx");
> +  tdesc_type *element_type;
> +  element_type = tdesc_named_type (feature, "uint512");
> +  tdesc_create_vector (feature, "v_ui512", element_type, 16);
> +
> +  tdesc_create_reg (feature, "tilecfg_raw", regnum++, 1, NULL, 512,
> "uint512");
> +  tdesc_create_reg (feature, "tmm0_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> +  tdesc_create_reg (feature, "tmm1_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> +  tdesc_create_reg (feature, "tmm2_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> +  tdesc_create_reg (feature, "tmm3_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> +  tdesc_create_reg (feature, "tmm4_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> +  tdesc_create_reg (feature, "tmm5_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> +  tdesc_create_reg (feature, "tmm6_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> +  tdesc_create_reg (feature, "tmm7_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> +  return regnum;
> +}
> diff --git a/gdb/features/i386/64bit-amx.xml b/gdb/features/i386/64bit-
> amx.xml
> new file mode 100644
> index 00000000000..a40c6c65f6d
> --- /dev/null
> +++ b/gdb/features/i386/64bit-amx.xml
> @@ -0,0 +1,26 @@
> +<?xml version="1.0"?>
> +<!-- Copyright (C) 2020-2026 Free Software Foundation, Inc.
> +
> +     Copying and distribution of this file, with or without modification,
> +     are permitted in any medium without royalty provided the copyright
> +     notice and this notice are preserved.  -->
> +
> +<!DOCTYPE feature SYSTEM "gdb-target.dtd">
> +<feature name="org.gnu.gdb.i386.amx">
> +  <!-- One uint512 value per row of a tile.  -->
> +  <vector id="v_ui512" type="uint512" count="16"/>
> +
> +  <!-- The raw contents of the tile configuration register.  -->
> +  <reg name="tilecfg_raw" bitsize="512" type="uint512"/>
> +
> +  <!-- The raw contents of the eight tiles, each of which is 16 rows of
> +       64 bytes.  -->
> +  <reg name="tmm0_raw" bitsize="8192" type="v_ui512"/>
> +  <reg name="tmm1_raw" bitsize="8192" type="v_ui512"/>
> +  <reg name="tmm2_raw" bitsize="8192" type="v_ui512"/>
> +  <reg name="tmm3_raw" bitsize="8192" type="v_ui512"/>
> +  <reg name="tmm4_raw" bitsize="8192" type="v_ui512"/>
> +  <reg name="tmm5_raw" bitsize="8192" type="v_ui512"/>
> +  <reg name="tmm6_raw" bitsize="8192" type="v_ui512"/>
> +  <reg name="tmm7_raw" bitsize="8192" type="v_ui512"/>
> +</feature>
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 071d8e004ae..a25abfbd1bc 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -378,6 +378,34 @@ i386_pkru_regnum_p (struct gdbarch *gdbarch, int
> regnum)
>    return regnum >= 0 && regnum < I387_NUM_PKEYS_REGS;
>  }
> 
> +/* AMX tilecfg register?  */
> +
> +bool
> +i386_tilecfg_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> +  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +  return regnum >= 0 && regnum == tdep->tilecfg_regnum;
> +}
> +
> +/* Raw AMX tile register?  */
> +
> +bool
> +i386_tmm_raw_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> +  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +  return (tdep->tmm_raw_regnum <= regnum
> +	  && regnum < tdep->tmm_raw_regnum + tdep-
> >num_tmm_raw_regs);
> +}
> +
> +/* AMX tilecfg_raw register?  */
> +
> +static bool
> +i386_tilecfg_raw_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> +  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +  return regnum >= 0 && regnum == tdep->tilecfg_raw_regnum;
> +}
> +
>  /* Return the name of register REGNUM, or the empty string if it is
>     an anonymous register.  */
> 
> @@ -3222,6 +3250,47 @@ i386_mmx_type (struct gdbarch *gdbarch)
>    return tdep->i386_mmx_type;
>  }
> 
> +/* The type of the TILECFG registers.  */
> +
> +static type *
> +i386_tilecfg_type (gdbarch *gdbarch)
> +{
> +  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +
> +  if (!tdep->i386_tilecfg_type)
> +    {
> +      const struct builtin_type *bt = builtin_type (gdbarch);
> +
> +      /* The type we're building is this:
> +
> +	 struct __gdb_builtin_type_tilecfg
> +	   {
> +	     uint8_t palette;
> +	     uint8_t start_row;
> +	     uint16_t colsb[8];
> +	     uint8_t rows[8];
> +	   };
> +
> +	 Bytes 2-15, 32-47 and 56-63 of the register are reserved, so the
> +	 colsb and rows arrays are packed together here.  */
> +
> +    type *t = arch_composite_type (gdbarch, "builtin_type_tilecfg",
> +				   TYPE_CODE_STRUCT);
> +
> +    append_composite_type_field (t, "palette", bt->builtin_uint8);
> +    append_composite_type_field (t, "start_row", bt->builtin_uint8);
> +    append_composite_type_field
> +      (t, "colsb", lookup_array_range_type (bt->builtin_uint16, 0, 7));
> +    append_composite_type_field
> +      (t, "rows", lookup_array_range_type (bt->builtin_uint8, 0, 7));
> +
> +    t->set_name ("builtin_type_tilecfg");
> +    tdep->i386_tilecfg_type = t;
> +  }
> +
> +  return tdep->i386_tilecfg_type;
> +}
> +
>  /* Return the GDB type object for the "standard" data type of data in
>     register REGNUM.  */
> 
> @@ -3236,6 +3305,8 @@ i386_pseudo_register_type (struct gdbarch
> *gdbarch, int regnum)
>      return i386_ymm_type (gdbarch);
>    else if (i386_zmm_regnum_p (gdbarch, regnum))
>      return i386_zmm_type (gdbarch);
> +  else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> +    return i386_tilecfg_type (gdbarch);
>    else
>      {
>        const struct builtin_type *bt = builtin_type (gdbarch);
> @@ -4269,7 +4340,8 @@ i386_register_reggroup_p (struct gdbarch *gdbarch,
> int regnum,
>    int fp_regnum_p, mmx_regnum_p, xmm_regnum_p, mxcsr_regnum_p,
>        ymm_regnum_p, ymmh_regnum_p, ymm_avx512_regnum_p,
> ymmh_avx512_regnum_p,
>        zmm_regnum_p, zmmh_regnum_p, xmm_avx512_regnum_p, avx512_p,
> avx_p,
> -      sse_p, pkru_regnum_p;
> +      sse_p, pkru_regnum_p, tilecfg_regnum_p, tmm_raw_regnum_p,
> +      tilecfg_raw_regnum_p;
> 
>    /* Don't include pseudo registers, except for MMX, in any register
>       groups.  */
> @@ -4296,6 +4368,9 @@ i386_register_reggroup_p (struct gdbarch *gdbarch,
> int regnum,
>    ymm_regnum_p = i386_ymm_regnum_p (gdbarch, regnum);
>    ymm_avx512_regnum_p = i386_ymm_avx512_regnum_p (gdbarch, regnum);
>    zmm_regnum_p = i386_zmm_regnum_p (gdbarch, regnum);
> +  tmm_raw_regnum_p = i386_tmm_raw_regnum_p (gdbarch, regnum);
> +  tilecfg_regnum_p = i386_tilecfg_regnum_p (gdbarch, regnum);
> +  tilecfg_raw_regnum_p = i386_tilecfg_raw_regnum_p (gdbarch, regnum);
> 
>    avx512_p = ((tdep->xcr0 & X86_XSTATE_AVX_AVX512_MASK)
>  	      == X86_XSTATE_AVX_AVX512_MASK);
> @@ -4329,6 +4404,11 @@ i386_register_reggroup_p (struct gdbarch
> *gdbarch, int regnum,
>  	  || zmmh_regnum_p))
>      return false;
> 
> +  /* For "info reg all", don't include the raw Intel AMX registers.  */
> +  if (group == all_reggroup
> +      && (tmm_raw_regnum_p || tilecfg_raw_regnum_p))
> +    return false;
> +
>    if (group == general_reggroup)
>      return (!fp_regnum_p
>  	    && !mmx_regnum_p
> @@ -4341,7 +4421,10 @@ i386_register_reggroup_p (struct gdbarch
> *gdbarch, int regnum,
>  	    && !ymmh_avx512_regnum_p
>  	    && !zmm_regnum_p
>  	    && !zmmh_regnum_p
> -	    && !pkru_regnum_p);
> +	    && !pkru_regnum_p
> +	    && !tmm_raw_regnum_p
> +	    && !tilecfg_regnum_p
> +	    && !tilecfg_raw_regnum_p);
> 
>    return default_register_reggroup_p (gdbarch, regnum, group);
>  }
> @@ -8520,7 +8603,7 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
> 
>    const struct tdesc_feature *feature_sse, *feature_avx,
>  			     *feature_avx512, *feature_pkeys,
> -			     *feature_apx;
> +			     *feature_apx, *feature_amx;
> 
>    /* Get core registers.  */
>    feature_core = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.core");
> @@ -8542,6 +8625,9 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
>    /* Try PKEYS  */
>    feature_pkeys = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pkeys");
> 
> +  /* Try Intel AMX.  */
> +  feature_amx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx");
> +
>    /* The XCR0 bits.  */
>    uint64_t xcr0 = X86_XSTATE_X87;
> 
> @@ -8572,6 +8658,9 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
>    if (feature_pkeys)
>      xcr0 |= X86_XSTATE_PKRU;
> 
> +  if (feature_amx)
> +    xcr0 |= X86_XSTATE_AMX;
> +
>    return xcr0;
>  }
> 
> @@ -8584,7 +8673,7 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
> 
>    const struct tdesc_feature *feature_sse, *feature_avx, *feature_avx512,
>  			     *feature_pkeys, *feature_segments,
> -			     *feature_pl3_ssp, *feature_apx;
> +			     *feature_pl3_ssp, *feature_apx, *feature_amx;
>    int i, num_regs, valid_p;
> 
>    if (! tdesc_has_registers (tdesc))
> @@ -8616,6 +8705,9 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
>    /* Try Shadow Stack.  */
>    feature_pl3_ssp = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pl3_ssp");
> 
> +  /* Try Intel AMX.  */
> +  feature_amx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx");
> +
>    valid_p = 1;
> 
>    /* The XCR0 bits.  */
> @@ -8752,6 +8844,26 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
>  					  tdep->ssp_regnum, "pl3_ssp");
>      }
> 
> +  if (feature_amx != nullptr
> +      && tdep->tilecfg_raw_regnum != -1
> +      && tdep->tilecfg_raw_register_names != nullptr
> +      && tdep->tmm_raw_regnum != -1
> +      && tdep->tmm_raw_register_names != nullptr)
> +    {
> +      tdep->xcr0 |= X86_XSTATE_TILECFG;
> +
> +      valid_p &= tdesc_numbered_register (feature_amx, tdesc_data,
> +					  tdep->tilecfg_raw_regnum,
> +					  tdep-
> >tilecfg_raw_register_names[0]);
> +
> +      tdep->xcr0 |= X86_XSTATE_TILEDATA;
> +
> +      for (i = 0; i < tdep->num_tmm_raw_regs; i++)
> +	valid_p &= tdesc_numbered_register (feature_amx, tdesc_data,
> +					    tdep->tmm_raw_regnum + i,
> +					    tdep->tmm_raw_register_names[i]);
> +    }
> +
>    return valid_p;
>  }
> 
> @@ -9010,7 +9122,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct
> gdbarch_list *arches)
>  					 + tdep->num_mmx_regs
>  					 + tdep->num_ymm_regs
>  					 + tdep->num_ymm_avx512_regs
> -					 + tdep->num_zmm_regs));
> +					 + tdep->num_zmm_regs
> +					 + tdep->num_tilecfg_regs));
> 
>    /* Target description may be changed.  */
>    tdesc = tdep->tdesc;
> @@ -9062,6 +9175,15 @@ i386_gdbarch_init (struct gdbarch_info info, struct
> gdbarch_list *arches)
>    else
>      tdep->zmm0_regnum = -1;
> 
> +  if (tdep->num_tilecfg_regs != 0)
> +    {
> +      /* Support TILECFG pseudo-register if it is available.  */
> +      tdep->tilecfg_regnum = mm0_regnum;
> +      mm0_regnum += tdep->num_tilecfg_regs;
> +    }
> +  else
> +    tdep->tilecfg_regnum = -1;
> +
>    if (tdep->num_mmx_regs != 0)
>      {
>        /* Support MMX pseudo-register if MMX hasn't been disabled.  */
> diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
> index bdafd523834..898a76dfb50 100644
> --- a/gdb/i386-tdep.h
> +++ b/gdb/i386-tdep.h
> @@ -225,6 +225,26 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
>       set this to a value >= 0.  */
>    int ssp_regnum = -1;
> 
> +  /* Register number for the raw tilecfg register and the tilecfg pseudo
> +     register.  If supported, set them to a value >= 0.  */
> +  int tilecfg_regnum = -1;
> +  int tilecfg_raw_regnum = -1;
> +
> +  /* Number of tilecfg registers, including pseudo register.  */
> +  int num_tilecfg_regs = 0;
> +
> +  /* Register number for the first raw tile register, tmm0_raw.  If supported,
> +     set this to a value >= 0.  */
> +  int tmm_raw_regnum = -1;
> +
> +  /* Number of raw tile registers.  */
> +  int num_tmm_raw_regs = 0;
> +
> +  /* Intel AMX register names.  */
> +  const char * const *tilecfg_raw_register_names = nullptr;
> +  const char * const *tilecfg_register_names = nullptr;
> +  const char * const *tmm_raw_register_names = nullptr;
> +
>    /* Register number for %fsbase.  If supported, set this to a value
>       >= 0.  */
>    int fsbase_regnum = -1;
> @@ -265,6 +285,7 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
>    struct type *i386_ymm_type = nullptr;
>    struct type *i386_zmm_type = nullptr;
>    struct type *i387_ext_type = nullptr;
> +  type *i386_tilecfg_type = nullptr;
> 
>    /* If the registers containing the i386 Linux TLS related global
>       descriptor table information are available.  This is used to decide
> @@ -379,7 +400,7 @@ enum record_i386_regnum
>  #define I386_NUM_XREGS  9
> 
>  /* Size of the largest register.  */
> -#define I386_MAX_REGISTER_SIZE	64
> +#define I386_MAX_REGISTER_SIZE	1024
> 
>  /* Types for i386-specific registers.  */
>  extern struct type *i387_ext_type (struct gdbarch *gdbarch);
> @@ -396,6 +417,8 @@ extern int i386_k_regnum_p (struct gdbarch *gdbarch,
> int regnum);
>  extern int i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum);
>  extern int i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum);
>  extern bool i386_pkru_regnum_p (struct gdbarch *gdbarch, int regnum);
> +extern bool i386_tilecfg_regnum_p (gdbarch *gdbarch, int regnum);
> +extern bool i386_tmm_raw_regnum_p (gdbarch *gdbarch, int regnum);
> 
>  extern const char *i386_pseudo_register_name (struct gdbarch *gdbarch,
>  					      int regnum);
> diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
> index 8f972338b3d..e7b4b53462f 100644
> --- a/gdb/i387-tdep.c
> +++ b/gdb/i387-tdep.c
> @@ -939,6 +939,30 @@ static int xsave_pkeys_offset[] =
>    (xsave + (tdep)->xsave_layout.pkru_offset				\
>     + xsave_pkeys_offset[regnum - I387_PKRU_REGNUM (tdep)])
> 
> +static int xsave_tilecfg_raw_offset[] =
> +{
> +  0 * 64		/* tilecfg.  */
> +};
> +
> +#define XSAVE_TILECFG_RAW_ADDR(tdep, xsave, regnum) \
> +  (xsave + (tdep)->xsave_layout.tilecfg_offset \
> +   + xsave_tilecfg_raw_offset[regnum - I387_TILECFG_RAW_REGNUM (tdep)])
> +
> +static int xsave_tmm_raw_offset[] =
> +{
> +  0 * X86_AMX_TMM_SIZE,	/* tmm0_raw.  */
> +  1 * X86_AMX_TMM_SIZE,	/* tmm1_raw.  */
> +  2 * X86_AMX_TMM_SIZE,	/* tmm2_raw.  */
> +  3 * X86_AMX_TMM_SIZE,	/* tmm3_raw.  */
> +  4 * X86_AMX_TMM_SIZE,	/* tmm4_raw.  */
> +  5 * X86_AMX_TMM_SIZE,	/* tmm5_raw.  */
> +  6 * X86_AMX_TMM_SIZE,	/* tmm6_raw.  */
> +  7 * X86_AMX_TMM_SIZE,	/* tmm7_raw.  */
> +};
> +
> +#define XSAVE_TMM_RAW_ADDR(tdep, xsave, regnum) \
> +  (xsave + (tdep)->xsave_layout.tiledata_offset \
> +   + xsave_tmm_raw_offset[regnum - I387_TMM0_RAW_REGNUM (tdep)])
> 
>  /* See i387-tdep.h.  */
> 
> @@ -946,14 +970,40 @@ bool
>  i387_guess_xsave_layout (uint64_t xcr0, size_t xsave_size,
>  			 x86_xsave_layout &layout)
>  {
> -  if (HAS_PKRU (xcr0) && (xsave_size == 2696 || xsave_size == 11008))
> +  if (HAS_AMX (xcr0) && xsave_size == 11008)
> +    {
> +      /* Intel CPUs supporting AMX.  */
> +      layout.avx_offset = 576;
> +      layout.apx_offset = 960;
> +      layout.k_offset = 1088;
> +      layout.zmm_h_offset = 1152;
> +      layout.zmm_offset = 1664;
> +      layout.pkru_offset = 2688;
> +      layout.tilecfg_offset = 2752;
> +      layout.tiledata_offset = 2816;
> +    }
> +  else if (HAS_PKRU (xcr0) && (xsave_size == 2696 || xsave_size == 11008))
>      {
>        /* Intel CPUs supporting PKRU.
> -	 GDB does not yet support Intel AMX, but CPUs with AMX have
> -	 a larger XSAVE_SIZE (11008).  We must handle this size here,
> -	 otherwise we cannot read any xsave registers from OS generated
> -	 core files on AMX systems.  The AMX registers themselves will
> -	 still not be readable though.  */
> +
> +	 XCR0 in core files generated by the gcore command in GDB is based on
> +	 tdep->xcr0, which i387_collect_xsave writes.  tdep->xcr0 is derived
> +	 from the target description, which does not contain Intel AMX for a
> +	 32-bit debuggee.
> +
> +	 For remote targets, core files generated by the gcore command have
> an
> +	 XSAVE size based on i387_fallback_xsave_layout, which is therefore
> +	 only 2696 bytes for a 32-bit debuggee.
> +
> +	 Native targets derive the XSAVE layout from the XCR0 as reported by
> +	 the kernel, see x86_linux_tdesc_for_tid.  It has the full XSAVE size
> +	 of 11008 bytes on systems with Intel AMX.  For a 32-bit debuggee,
> +	 tdep->xcr0 does not include Intel AMX, see i386_validate_tdesc_p,
> +	 while i386_gdbarch_init still stores the native layout in
> +	 tdep->xsave_layout.  The gcore command writes the XSAVE note with
> that
> +	 size and with tdep->xcr0, e.g. with XCR0 0x2e7 and 11008 bytes.
> +	 Thus, we must also accept an XSAVE size of 11008 bytes here, to avoid
> +	 a warning about an unexpected XSAVE size.  */
>        layout.avx_offset = 576;
>        /* Intel APX can be available on CPUs supporting Intel PKRU with or
>  	 without Intel AMX support.  */
> @@ -1004,7 +1054,20 @@ i387_fallback_xsave_layout (uint64_t xcr0)
>  {
>    x86_xsave_layout layout;
> 
> -  if (HAS_PKRU (xcr0))
> +  if (HAS_AMX (xcr0))
> +    {
> +      /* Intel CPUs supporting AMX.  */
> +      layout.avx_offset = 576;
> +      layout.apx_offset = 960;
> +      layout.k_offset = 1088;
> +      layout.zmm_h_offset = 1152;
> +      layout.zmm_offset = 1664;
> +      layout.pkru_offset = 2688;
> +      layout.tilecfg_offset = 2752;
> +      layout.tiledata_offset = 2816;
> +      layout.sizeof_xsave = 11008;
> +    }
> +  else if (HAS_PKRU (xcr0))
>      {
>        /* Intel CPUs supporting PKRU.  */
>        layout.avx_offset = 576;
> @@ -1086,8 +1149,11 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
>        avx512_xmm_avx512 = 0x80,
>        pkeys = 0x100,
>        apx = 0x200,
> +      tilecfg_raw = 0x400,
> +      tmm_raw = 0x800,
>        all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
>  	    | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx
> +	    | tilecfg_raw | tmm_raw
>      } regclass;
> 
>    gdb_assert (regs != NULL);
> @@ -1099,6 +1165,11 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
>    else if (regnum >= I387_R16_REGNUM (tdep)
>  	   && regnum < I387_APX_END_REGNUM (tdep))
>      regclass = apx;
> +  else if (regnum == I387_TILECFG_RAW_REGNUM (tdep))
> +    regclass = tilecfg_raw;
> +  else if (regnum >= I387_TMM0_RAW_REGNUM (tdep)
> +	   && regnum < I387_TMMEND_RAW_REGNUM (tdep))
> +    regclass = tmm_raw;
>    else if (regnum >= I387_PKRU_REGNUM (tdep)
>  	   && regnum < I387_PKEYSEND_REGNUM (tdep))
>      regclass = pkeys;
> @@ -1152,6 +1223,21 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
>  	regcache->raw_supply (regnum, XSAVE_APX_EGPR_ADDR (tdep, regs,
> regnum));
>        return;
> 
> +    case tilecfg_raw:
> +      if ((clear_bv & X86_XSTATE_TILECFG))
> +	regcache->raw_supply_zeroed (regnum);
> +      else
> +	regcache->raw_supply (regnum,
> +			      XSAVE_TILECFG_RAW_ADDR (tdep, regs, regnum));
> +      return;
> +
> +    case tmm_raw:
> +      if ((clear_bv & X86_XSTATE_TILEDATA))
> +	regcache->raw_supply_zeroed (regnum);
> +      else
> +	regcache->raw_supply (regnum, XSAVE_TMM_RAW_ADDR (tdep, regs,
> regnum));
> +      return;
> +
>      case pkeys:
>        if ((clear_bv & X86_XSTATE_PKRU))
>  	regcache->raw_supply_zeroed (regnum);
> @@ -1346,6 +1432,32 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
>  	    }
>  	}
> 
> +      /* Handle the tilecfg register.  */
> +      if ((tdep->xcr0 & X86_XSTATE_TILECFG) != 0)
> +	{
> +	  if ((clear_bv & X86_XSTATE_TILECFG) != 0)
> +	    regcache->raw_supply_zeroed (I387_TILECFG_RAW_REGNUM
> (tdep));
> +	  else
> +	    {
> +	      i = I387_TILECFG_RAW_REGNUM (tdep);
> +	      regcache->raw_supply (i,
> +				    XSAVE_TILECFG_RAW_ADDR (tdep, regs, i));
> +	    }
> +	}
> +
> +      /* Handle the raw tile registers.  */
> +      if ((tdep->xcr0 & X86_XSTATE_TILEDATA) != 0)
> +	{
> +	  for (i = I387_TMM0_RAW_REGNUM (tdep);
> +	       i < I387_TMMEND_RAW_REGNUM (tdep); i++)
> +	    {
> +	      if ((clear_bv & X86_XSTATE_TILEDATA) != 0)
> +		regcache->raw_supply_zeroed (i);
> +	      else
> +		regcache->raw_supply (i, XSAVE_TMM_RAW_ADDR (tdep, regs,
> i));
> +	    }
> +	}
> +
>        /* Handle the XMM registers.  */
>        if ((tdep->xcr0 & X86_XSTATE_SSE))
>  	{
> @@ -1505,8 +1617,11 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
>        avx512_xmm_avx512 = 0x100,
>        pkeys = 0x200,
>        apx = 0x400,
> +      tilecfg = 0x800,
> +      tmm_raw = 0x1000,
>        all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
> -	    | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx
> +	    | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx |
> tilecfg
> +	    | tmm_raw
>      } regclass;
> 
>    gdb_assert (tdep->st0_regnum >= I386_ST0_REGNUM);
> @@ -1517,6 +1632,11 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
>    else if (regnum >= I387_R16_REGNUM (tdep)
>  	   && regnum < I387_APX_END_REGNUM (tdep))
>      regclass = apx;
> +  else if (regnum == I387_TILECFG_RAW_REGNUM (tdep))
> +    regclass = tilecfg;
> +  else if (regnum >= I387_TMM0_RAW_REGNUM (tdep)
> +	   && regnum < I387_TMMEND_RAW_REGNUM (tdep))
> +    regclass = tmm_raw;
>    else if (regnum >= I387_PKRU_REGNUM (tdep)
>  	   && regnum < I387_PKEYSEND_REGNUM (tdep))
>      regclass = pkeys;
> @@ -1589,6 +1709,19 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
>  	    memset (XSAVE_APX_EGPR_ADDR (tdep, regs, i), 0, 8);
>  	}
> 
> +      if ((clear_bv & X86_XSTATE_TILECFG))
> +	{
> +	  i = I387_TILECFG_RAW_REGNUM (tdep);
> +	  memset (XSAVE_TILECFG_RAW_ADDR (tdep, regs, i), 0, 64);
> +	}
> +
> +      if ((clear_bv & X86_XSTATE_TILEDATA))
> +	{
> +	  i = I387_TMM0_RAW_REGNUM (tdep);
> +	  memset (XSAVE_TMM_RAW_ADDR (tdep, regs, i), 0,
> +		  X86_AMX_TILEDATA_SIZE);
> +	}
> +
>        if ((clear_bv & X86_XSTATE_PKRU))
>  	for (i = I387_PKRU_REGNUM (tdep);
>  	     i < I387_PKEYSEND_REGNUM (tdep); i++)
> @@ -1672,6 +1805,33 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
>  	    }
>  	}
> 
> +      /* Check if the tilecfg register is changed.  */
> +      if ((tdep->xcr0 & X86_XSTATE_TILECFG))
> +	{
> +	  i = I387_TILECFG_RAW_REGNUM (tdep);
> +	  regcache->raw_collect (i, raw);
> +	  p = XSAVE_TILECFG_RAW_ADDR (tdep, regs, i);
> +	  if (memcmp (raw, p, 64) != 0)
> +	    {
> +	      xstate_bv |= X86_XSTATE_TILECFG;
> +	      memcpy (p, raw, 64);
> +	    }
> +	}
> +
> +      /* Check if any raw tile register is changed.  */
> +      if ((tdep->xcr0 & X86_XSTATE_TILEDATA))
> +	for (i = I387_TMM0_RAW_REGNUM (tdep);
> +	     i < I387_TMMEND_RAW_REGNUM (tdep); i++)
> +	  {
> +	    regcache->raw_collect (i, raw);
> +	    p = XSAVE_TMM_RAW_ADDR (tdep, regs, i);
> +	    if (memcmp (raw, p, X86_AMX_TMM_SIZE) != 0)
> +	      {
> +		xstate_bv |= X86_XSTATE_TILEDATA;
> +		memcpy (p, raw, X86_AMX_TMM_SIZE);
> +	      }
> +	  }
> +
>        /* Check if any PKEYS registers are changed.  */
>        if ((tdep->xcr0 & X86_XSTATE_PKRU))
>  	for (i = I387_PKRU_REGNUM (tdep);
> @@ -1814,6 +1974,16 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
>  	      }
>  	  }
>      }
> +  else if (regclass == tmm_raw)
> +    {
> +      regcache->raw_collect (regnum, raw);
> +      p = XSAVE_TMM_RAW_ADDR (tdep, regs, regnum);
> +      if (memcmp (raw, p, 1024) != 0)
> +	{
> +	  xstate_bv |= X86_XSTATE_TILEDATA;
> +	  memcpy (p, raw, 1024);
> +	}
> +    }
>    else
>      {
>        /* Check if REGNUM is changed.  */
> @@ -1834,6 +2004,16 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
>  	    }
>  	  break;
> 
> +	case tilecfg:
> +	  /* This is a tilecfg register.  */
> +	  p = XSAVE_TILECFG_RAW_ADDR (tdep, regs, regnum);
> +	  if (memcmp (raw, p, 64) != 0)
> +	    {
> +	      xstate_bv |= X86_XSTATE_TILECFG;
> +	      memcpy (p, raw, 64);
> +	    }
> +	  break;
> +
>  	case pkeys:
>  	  /* This is a PKEYS register.  */
>  	  p = XSAVE_PKEYS_ADDR (tdep, regs, regnum);
> diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
> index f029c1e5119..6055b122cba 100644
> --- a/gdb/i387-tdep.h
> +++ b/gdb/i387-tdep.h
> @@ -43,14 +43,18 @@ struct x86_xsave_layout;
>  /* Set of constants used for 32 and 64-bit.  */
>  #define I387_NUM_K_REGS 8
>  #define I387_NUM_PKEYS_REGS 1
> +#define I387_NUM_TILECFG_REGS 1
> 
>  #define I387_PKRU_REGNUM(tdep) ((tdep)->pkru_regnum)
>  #define I387_K0_REGNUM(tdep) ((tdep)->k0_regnum)
>  #define I387_NUM_ZMMH_REGS(tdep) ((tdep)->num_zmm_regs)
> +#define I387_NUM_TMM_RAW_REGS(tdep) ((tdep)->num_tmm_raw_regs)
>  #define I387_ZMM0H_REGNUM(tdep) ((tdep)->zmm0h_regnum)
>  #define I387_ZMM16H_REGNUM(tdep) ((tdep)->zmm0h_regnum + 16)
>  #define I387_NUM_YMM_AVX512_REGS(tdep) ((tdep)-
> >num_ymm_avx512_regs)
>  #define I387_YMM16H_REGNUM(tdep) ((tdep)->ymm16h_regnum)
> +#define I387_TILECFG_RAW_REGNUM(tdep) ((tdep)->tilecfg_raw_regnum)
> +#define I387_TMM0_RAW_REGNUM(tdep) ((tdep)->tmm_raw_regnum)
> 
>  #define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) + 8)
>  #define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 1)
> @@ -83,6 +87,8 @@ struct x86_xsave_layout;
> 
>  #define I387_PKEYSEND_REGNUM(tdep) \
>    (I387_PKRU_REGNUM (tdep) + I387_NUM_PKEYS_REGS)
> +#define I387_TMMEND_RAW_REGNUM(tdep) \
> +  (I387_TMM0_RAW_REGNUM (tdep) + I387_NUM_TMM_RAW_REGS (tdep))
> 
>  /* Print out the i387 floating point state.  */
> 
> diff --git a/gdb/nat/x86-xstate.c b/gdb/nat/x86-xstate.c
> index f0f0b00e859..75719b98746 100644
> --- a/gdb/nat/x86-xstate.c
> +++ b/gdb/nat/x86-xstate.c
> @@ -61,5 +61,7 @@ x86_fetch_xsave_layout (uint64_t xcr0, int len)
>    layout.zmm_h_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_H_ID);
>    layout.zmm_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_ID);
>    layout.pkru_offset = xsave_feature_offset (xcr0, X86_XSTATE_PKRU_ID);
> +  layout.tilecfg_offset = xsave_feature_offset (xcr0, X86_XSTATE_TILECFG_ID);
> +  layout.tiledata_offset = xsave_feature_offset (xcr0,
> X86_XSTATE_TILEDATA_ID);
>    return layout;
>  }
> diff --git a/gdb/target-debug.h b/gdb/target-debug.h
> index 949847b181c..9e096a18b7b 100644
> --- a/gdb/target-debug.h
> +++ b/gdb/target-debug.h
> @@ -381,6 +381,8 @@ target_debug_print_x86_xsave_layout (const
> x86_xsave_layout &layout)
>    POFFS(zmm);
>    POFFS(pkru);
>    POFFS(apx);
> +  POFFS(tilecfg);
> +  POFFS(tiledata);
> 
>  #undef POFFS
> 
> diff --git a/gdb/testsuite/gdb.arch/amd64-amx.c
> b/gdb/testsuite/gdb.arch/amd64-amx.c
> new file mode 100644
> index 00000000000..5dca29ad183
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/amd64-amx.c
> @@ -0,0 +1,115 @@
> +/* Test program for Intel AMX registers.
> +
> +   Copyright 2022-2026 Free Software Foundation, Inc.
> +
> +   This file is part of GDB.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#include <immintrin.h>
> +#include <stdint.h>
> +
> +#include "amd64-amx.h"
> +
> +#define TILE int
> +
> +#define N 2
> +#define K 3
> +#define M 4
> +
> +uint8_t memA[N][4 * K] = { { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2 },
> +			      { 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 } };
> +
> +uint8_t memB[K][4 * M] = {
> +  { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 },
> +  { 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4 },
> +  { 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 },
> +};
> +
> +uint32_t memC[N][M] = { 0 };
> +
> +/* Data for type testing.  */
> +
> +int8_t int8_matrix[2][8] = { { -1, -1, -1, -1, 1, 1, 1, 1 },
> +			     { 1, 1, 1, 1, -5, -5, -5, -5 } };
> +
> +float fp32_matrix[2][2] = { { 1.0, 1.125 },
> +			    { 1.25, 1.375 } };
> +
> +
> +static void
> +tfmaps_calc (void)
> +{
> +  const int strideA = 4 * K;
> +  const int strideB = 4 * M;
> +  const int strideC = 4 * M;
> +
> +  /* Configure.  */
> +  struct tileconfig_t
> +  {
> +    uint8_t palette_id;
> +    uint8_t startRow;
> +    uint8_t reserved[14];
> +    uint16_t cols[16];
> +    uint8_t rows[16];
> +  };
> +
> +  struct tileconfig_t tc = { 1 };
> +
> +  const TILE A = 0;
> +  const TILE B = 1;
> +  const TILE C = 2;
> +
> +  tc.rows[A] = N;
> +  tc.cols[A] = K * 4;
> +  tc.rows[B] = K;
> +  tc.cols[B] = M * 4;
> +  tc.rows[C] = N;
> +  tc.cols[C] = M * 4;
> +
> +  /* Tiles for testing the remaining element types.  */
> +  tc.rows[4] = 2;
> +  tc.cols[4] = 8;
> +  tc.rows[5] = 2;
> +  tc.cols[5] = 8;
> +
> +  _tile_loadconfig (&tc);
> +
> +  /* Load additional types for type testing.  */
> +  _tile_loadd (4, fp32_matrix, 2 * 4);
> +  _tile_loadd (5, int8_matrix, 4 * 2);
> +
> +  /* Computation.  */
> +  _tile_loadd (0, memA, strideA);
> +  _tile_loadd (1, memB, strideB);
> +  _tile_dpbuud (2, 0, 1);
> +  _tile_stored (2, memC, strideC);
> +
> +  /* Provoke a SIGSEGV while the tiles are still live, so that the OS
> +     writes a core file containing them.  */
> +  *(volatile int *) 0; /* Crash.  */
> +}
> +
> +
> +int
> +main (void)
> +{
> +  /* Ask the OS to configure Intel AMX in xsave.  */
> +  if (amx_enable () != 0)
> +    return -1;
> +
> +  tfmaps_calc ();
> +
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.arch/amd64-amx.exp
> b/gdb/testsuite/gdb.arch/amd64-amx.exp
> new file mode 100644
> index 00000000000..af92e2d37a0
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/amd64-amx.exp
> @@ -0,0 +1,192 @@
> +# Copyright 2022-2026 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# This file tests basic Intel AMX functionality.  The raw tile registers
> +# always show a tile with its maximum dimensions, that is 16 rows of 64
> bytes.
> +# Only the elements configured in $tilecfg hold data.
> +
> +require allow_amx_tests
> +
> +standard_testfile
> +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
> +	{debug additional_flags=-mamx-tile additional_flags=-mamx-int8}]} {
> +    return
> +}
> +
> +if {![runto_main]} {
> +    return
> +}
> +
> +proc test_zeroed_tile {reg} {
> +    gdb_test "print/d (uint8_t\[16\]\[64\]) $reg" \
> +	"= \\{\\{0 <repeats 64 times>\\} <repeats 16 times>\\}"
> +}
> +
> +# Check the tile registers as loaded by the program at the "Crash" line.
> +
> +proc test_loaded_tiles {} {
> +    gdb_test "print/x \$tilecfg_raw" \
> +	[join {"= 0x20200020302000000000000000000000000000000000" \
> +
> "000000000080008000000100010000c000000000000000000000000000000
> 01"} ""]
> +
> +    gdb_test "print \$tilecfg" \
> +	[string_to_regexp "= {palette = 1, start_row = 0,\
> +	     colsb = {12, 16, 16, 0, 8, 8, 0, 0}, rows = {2, 3, 2, 0, 2, 2, 0, 0}}"]
> +
> +    gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
> +	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\
> +		     0 <repeats 52 times>\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>\\}" \
> +	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
> +	    ", "]
> +
> +    gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm1_raw" \
> +	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,\
> +		     0 <repeats 48 times>\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,\
> +	     0 <repeats 48 times>\\}" \
> +	    "\\{2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,\
> +	     0 <repeats 48 times>\\}" \
> +	    "\\{0 <repeats 64 times>\\} <repeats 13 times>\\}"} \
> +	    ", "]
> +
> +    gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
> +	[join {"= \\{\\{20, 32, 44, 56, 0 <repeats 12 times>\\}" \
> +	    "\\{32, 56, 80, 104, 0 <repeats 12 times>\\}" \
> +	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
> +	    ", "]
> +
> +    gdb_test "print (float\[16\]\[16\]) \$tmm4_raw" \
> +	[join {"= \\{\\{1, 1.125, 0 <repeats 14 times>\\}" \
> +	    "\\{1.25, 1.375, 0 <repeats 14 times>\\}" \
> +	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
> +	    ", "]
> +
> +    gdb_test "print/d (int8_t\[16\]\[64\]) \$tmm5_raw" \
> +	[join {"= \\{\\{-1, -1, -1, -1, 1, 1, 1, 1, 0 <repeats 56 times>\\}" \
> +	    "\\{1, 1, 1, 1, -5, -5, -5, -5, 0 <repeats 56 times>\\}" \
> +	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
> +	    ", "]
> +
> +    foreach i {3 6 7} {
> +	test_zeroed_tile "\$tmm${i}_raw"
> +    }
> +}
> +
> +# Restart gdb, load the core file generated by gcore or the OS
> +# and check reading registers from the core file.
> +
> +proc test_corefile {core_filename} {
> +    clean_restart $::testfile
> +
> +    gdb_test "core $core_filename" "Core was generated by .*" \
> +	"load core file"
> +
> +    test_loaded_tiles
> +}
> +
> +# Registers should be displayed as zeroed before Intel AMX enablement.
> +with_test_prefix "before Intel AMX is enabled" {
> +    gdb_test "print \$tilecfg_raw" "= 0"
> +    for {set i 0} {$i < 8} {incr i} {
> +	test_zeroed_tile "\$tmm${i}_raw"
> +    }
> +}
> +
> +# Continue until the program provokes a SIGSEGV.  This is required to test
> +# reading tile registers from the OS generated core file below.
> +set line [gdb_get_line_number "Crash"]
> +gdb_breakpoint $line
> +gdb_continue_to_breakpoint "tiles are loaded" ".*$srcfile:$line.*"
> +
> +with_test_prefix "read tiles" {
> +    test_loaded_tiles
> +}
> +
> +# Write a core file before modifying the tile registers.
> +set gcorefile $binfile.gcore
> +set gcore_generated [gdb_gcore_cmd $gcorefile "save a core file"]
> +
> +# Test setting tiles.
> +with_test_prefix "setting tiles" {
> +    gdb_test_no_output "set ((uint8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\] =
> 1"
> +    gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
> +	[join {"= \\{\\{1, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\
> +		     0 <repeats 52 times>\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>\\}" \
> +	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
> +	    ", "]
> +
> +    gdb_test_no_output "set ((int\[16\]\[16\]) \$tmm2_raw)\[0\] = {1, 1, 1}"
> +    gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
> +	[join {"= \\{\\{1, 1, 1, 0 <repeats 13 times>\\}" \
> +	    "\\{32, 56, 80, 104, 0 <repeats 12 times>\\}" \
> +	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
> +	    ", "]
> +
> +    gdb_test_no_output "set ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\] =
> 0.75"
> +    gdb_test "print ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\]" "= 0.75"
> +
> +    gdb_test_no_output "set ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\] = -1"
> +    gdb_test "print/d ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\]" "= -1"
> +}
> +
> +# Test generic setting.
> +with_test_prefix "set tilecfg raw" {
> +    gdb_test_no_output "set \$tilecfg_raw = 0"
> +    gdb_test_no_output "set \$tilecfg.palette = 1"
> +
> +    gdb_test "print/x \$tilecfg_raw" "= 0x1"
> +    gdb_test "print \$tilecfg" \
> +	[string_to_regexp "= {palette = 1, start_row = 0,\
> +	     colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {0, 0, 0, 0, 0, 0, 0, 0}}"]
> +}
> +
> +with_test_prefix "set tilecfg" {
> +    gdb_test_no_output "set \$tilecfg.palette = 0x2"
> +    gdb_test_no_output "set \$tilecfg.start_row = 0x3"
> +    gdb_test_no_output "set \$tilecfg.rows\[0\] = 0x4"
> +
> +    gdb_test "print/x \$tilecfg_raw" \
> +	[join {"= 0x40000000000000000000000000000000000000000000" \
> +
> "00000000000000000000000000000000000000000000000000302"} ""]
> +    gdb_test "print \$tilecfg" \
> +	[string_to_regexp "= {palette = 2, start_row = 3,\
> +	     colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {4, 0, 0, 0, 0, 0, 0, 0}}"]
> +}
> +
> +# Test the core file generated by gcore.  We expect the registers values that
> +# the live process had before the core file is generated.
> +if {$gcore_generated} {
> +    with_test_prefix "gcore core file" {
> +	test_corefile $gcorefile
> +    }
> +}
> +
> +# Like the above, but test the core file generated by the OS.
> +with_test_prefix "OS generated core file" {
> +    # This test relies on reading address zero triggering a SIGSEGV.
> +    # If address zero is readable skip this test.
> +    if {[is_address_zero_readable]} {
> +	unsupported "address zero is readable"
> +    } else {
> +	set corefile [core_find $binfile]
> +	if {$corefile eq ""} {
> +	    unsupported "unable to generate core file"
> +	} else {
> +	    test_corefile $corefile
> +	}
> +    }
> +}
> diff --git a/gdb/testsuite/lib/amd64-amx.h b/gdb/testsuite/lib/amd64-amx.h
> new file mode 100644
> index 00000000000..4b2d0b7ba71
> --- /dev/null
> +++ b/gdb/testsuite/lib/amd64-amx.h
> @@ -0,0 +1,41 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> +   Copyright 2026 Free Software Foundation, Inc.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#ifndef AMD64_AMX_H
> +#define AMD64_AMX_H
> +
> +#include <asm/prctl.h>
> +#include <sys/syscall.h>
> +#include <unistd.h>
> +
> +/* Intel AMX requires Linux 5.16.  ARCH_XCOMP_TILEDATA is added in Linux
> 6.4.
> +   Add fallback for previous kernels.  */
> +
> +#ifndef ARCH_XCOMP_TILEDATA
> +#define ARCH_XCOMP_TILEDATA 18
> +#endif
> +
> +/* Ask the OS to configure Intel AMX in xsave.  Tile data registers are
> +   only usable after this succeeded.  Return zero on success.  */
> +
> +static inline int
> +amx_enable (void)
> +{
> +  return syscall (SYS_arch_prctl, ARCH_REQ_XCOMP_PERM,
> ARCH_XCOMP_TILEDATA);
> +}
> +
> +#endif /* AMD64_AMX_H */
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index bc6725b948f..c24cfd5dfbd 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -4635,6 +4635,81 @@ gdb_caching_proc allow_ssp_tests {} {
>      return $allow_ssp_tests
>  }
> 
> +# Run a test on the target to see if it supports AMX.  Return 1 if so,
> +# 0 if it does not.
> +
> +gdb_caching_proc allow_amx_tests {} {
> +    global srcdir subdir gdb_prompt inferior_exited_re
> +
> +    set me "allow_amx_tests"
> +    if { ![istarget "x86_64-*-*"] } {
> +	verbose "$me: target does not support AMX" 2
> +	return 0
> +    }
> +
> +    # Compile a test program.
> +    set src {
> +	#include <stdint.h>
> +	#include <immintrin.h>
> +
> +	#include "amd64-amx.h"
> +
> +	int
> +	main ()
> +	{
> +	  if (amx_enable () != 0)
> +	    return 1;
> +
> +	  struct tileconfig_t {
> +	     uint8_t  palette_id;
> +	     uint8_t  startRow;
> +	     uint8_t  reserved[14];
> +	     uint16_t cols[16];
> +	     uint8_t  rows[16];
> +	  };
> +
> +	  struct tileconfig_t tc = {1};
> +	  _tile_loadconfig (&tc);
> +	  _tile_release ();
> +
> +	  return 0;
> +	}
> +    }
> +    set compile_flags "additional_flags=-mamx-tile"
> +    if {![gdb_simple_compile $me $src executable $compile_flags]} {
> +	return 0
> +    }
> +
> +    # No error message, compilation succeeded so now run it via gdb.
> +
> +    gdb_exit
> +    gdb_start
> +    gdb_reinitialize_dir $srcdir/$subdir
> +    gdb_load "$obj"
> +    gdb_run_cmd
> +    set allow_amx_tests 0
> +    gdb_expect {
> +	-re ".*Illegal instruction.*${gdb_prompt} $" {
> +	    verbose -log "$me: AMX hardware not detected."
> +	}
> +	-re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
> +	    verbose -log "$me:  AMX not enabled by the OS."
> +	}
> +	-re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
> +	    verbose -log "$me: AMX hardware detected."
> +	    set allow_amx_tests 1
> +	}
> +	default {
> +	    warning "\n$me: default case taken."
> +	}
> +    }
> +    gdb_exit
> +    remote_file build delete $obj
> +
> +    verbose "$me: returning $allow_amx_tests" 2
> +    return $allow_amx_tests
> +}
> +
>  # Run a test on the target to see if it supports avx512bf16.  Return 1 if so,
>  # 0 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
> 
> diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
> index 90f146a74d2..7d195c554ce 100644
> --- a/gdbserver/i387-fp.cc
> +++ b/gdbserver/i387-fp.cc
> @@ -138,6 +138,14 @@ public:
>       32 bits.  */
>    unsigned char *pkru_space ()
>    { return xsave () + xsave_layout.pkru_offset; }
> +
> +  /* Memory address for the TILECFG register, which is 64 bytes.  */
> +  unsigned char *tilecfg_space ()
> +  { return xsave () + xsave_layout.tilecfg_offset; }
> +
> +  /* Memory address of the TILEDATA state component.  */
> +  unsigned char *tiledata_space ()
> +  { return xsave () + xsave_layout.tiledata_offset; }
>  };
> 
>  static_assert (sizeof(i387_xsave) == 576);
> @@ -260,7 +268,7 @@ i387_cache_to_xsave (struct regcache *regcache, void
> *buf)
>    unsigned long val, val2;
>    unsigned long long xstate_bv = 0;
>    unsigned long long clear_bv = 0;
> -  char raw[64];
> +  char raw[1024];
>    unsigned char *p;
> 
>    /* Amd64 has 16 xmm regs; I386 has 8 xmm regs.  */
> @@ -321,6 +329,12 @@ i387_cache_to_xsave (struct regcache *regcache,
> void *buf)
>        if (amd64 && (clear_bv & X86_XSTATE_APX_F) != 0)
>  	for (i = 0; i < num_apx_registers; i++)
>  	  memset (fp->apx_space () + i * 8, 0, 8);
> +
> +      if (amd64 && (clear_bv & X86_XSTATE_AMX) != 0)
> +	{
> +	  memset (fp->tilecfg_space (), 0, X86_AMX_TILECFG_SIZE);
> +	  memset (fp->tiledata_space (), 0, X86_AMX_TILEDATA_SIZE);
> +	}
>      }
> 
>    /* Check if any x87 registers are changed.  */
> @@ -462,6 +476,35 @@ i387_cache_to_xsave (struct regcache *regcache,
> void *buf)
>  	}
>      }
> 
> +  /* Check if TILECFG register is changed (only for amd64).  */
> +  if (amd64 && ((x86_xstate_bv & X86_XSTATE_TILECFG) != 0))
> +    {
> +      collect_register_by_name (regcache, "tilecfg_raw", raw);
> +      p = fp->tilecfg_space ();
> +      if (memcmp (raw, p, X86_AMX_TILECFG_SIZE) != 0)
> +	{
> +	  xstate_bv |= X86_XSTATE_TILECFG;
> +	  memcpy (p, raw, X86_AMX_TILECFG_SIZE);
> +	}
> +    }
> +
> +  /* Check if any raw tile register is changed (only for amd64).  */
> +  if (amd64 && ((x86_xstate_bv & X86_XSTATE_TILEDATA) != 0))
> +    {
> +      int tmm0_raw_regnum = find_regno (regcache->tdesc, "tmm0_raw");
> +
> +      for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> +	{
> +	  collect_register (regcache, tmm0_raw_regnum + i, raw);
> +	  p = fp->tiledata_space () + i * X86_AMX_TMM_SIZE;
> +	  if (memcmp (raw, p, X86_AMX_TMM_SIZE) != 0)
> +	    {
> +	      xstate_bv |= X86_XSTATE_TILEDATA;
> +	      memcpy (p, raw, X86_AMX_TMM_SIZE);
> +	    }
> +	}
> +    }
> +
>    if ((x86_xstate_bv & X86_XSTATE_SSE) || (x86_xstate_bv &
> X86_XSTATE_AVX))
>      {
>        collect_register_by_name (regcache, "mxcsr", raw);
> @@ -833,6 +876,31 @@ i387_xsave_to_cache (struct regcache *regcache,
> const void *buf)
>  	}
>      }
> 
> +  if (amd64 && (x86_xstate_bv & X86_XSTATE_AMX) != 0)
> +    {
> +      int tilecfg_regnum = find_regno (regcache->tdesc, "tilecfg_raw");
> +      int tmm0_raw_regnum = find_regno (regcache->tdesc, "tmm0_raw");
> +
> +      if ((clear_bv & X86_XSTATE_TILECFG) != 0)
> +	supply_register_zeroed (regcache, tilecfg_regnum);
> +      else
> +	{
> +	  p = fp->tilecfg_space ();
> +	  supply_register (regcache, tilecfg_regnum, p);
> +	}
> +
> +      if ((clear_bv & X86_XSTATE_TILEDATA) != 0)
> +	for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> +	  supply_register_zeroed (regcache, tmm0_raw_regnum + i);
> +      else
> +	{
> +	  p = fp->tiledata_space ();
> +	  for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> +	    supply_register (regcache, tmm0_raw_regnum + i,
> +			     p + i * X86_AMX_TMM_SIZE);
> +	}
> +    }
> +
>    if ((clear_bv & (X86_XSTATE_SSE | X86_XSTATE_AVX))
>        == (X86_XSTATE_SSE | X86_XSTATE_AVX))
>      {
> diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
> index f893821fa48..24473ae1916 100644
> --- a/gdbserver/linux-x86-low.cc
> +++ b/gdbserver/linux-x86-low.cc
> @@ -263,6 +263,8 @@ static const int x86_64_regmap[] =
>    -1,					/* CET user mode register PL3_SSP.  */
>    -1, -1, -1, -1, -1, -1, -1, -1,       /* r16...r31 (APX).  */
>    -1, -1, -1, -1, -1, -1, -1, -1,
> +  -1,					/* AMX TILECFG register.  */
> +  -1, -1, -1, -1, -1, -1, -1, -1,	/* AMX tmm0_raw ... tmm7_raw.  */
>  };
> 
>  #define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof
> (x86_64_regmap[0]))
> diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
> index 3cb75ccfed6..368c34426b1 100644
> --- a/gdbsupport/x86-xstate.h
> +++ b/gdbsupport/x86-xstate.h
> @@ -29,6 +29,8 @@
>  #define X86_XSTATE_ZMM_ID	7
>  #define X86_XSTATE_PKRU_ID	9
>  #define X86_XSTATE_CET_U_ID	11
> +#define X86_XSTATE_TILECFG_ID	17
> +#define X86_XSTATE_TILEDATA_ID	18
>  #define X86_XSTATE_APX_F_ID	19
> 
>  /* The extended state feature bits.  */
> @@ -47,6 +49,11 @@
>  #define X86_XSTATE_PKRU		(1ULL << X86_XSTATE_PKRU_ID)
>  #define X86_XSTATE_CET_U	(1ULL << X86_XSTATE_CET_U_ID)
> 
> +/* AMX adds two feature bits.  Both must be enabled.  */
> +#define X86_XSTATE_TILECFG	(1ULL << X86_XSTATE_TILECFG_ID)
> +#define X86_XSTATE_TILEDATA	(1ULL << X86_XSTATE_TILEDATA_ID)
> +#define X86_XSTATE_AMX		(X86_XSTATE_TILECFG |
> X86_XSTATE_TILEDATA)
> +
>  /* Total size of the XSAVE area extended region and offsets of
>     register states within the region.  Offsets are set to 0 to
>     indicate the absence of the associated registers.  */
> @@ -60,6 +67,8 @@ struct x86_xsave_layout
>    int zmm_h_offset = 0;
>    int zmm_offset = 0;
>    int pkru_offset = 0;
> +  int tilecfg_offset = 0;
> +  int tiledata_offset = 0;
>  };
> 
>  constexpr bool operator== (const x86_xsave_layout &lhs,
> @@ -71,7 +80,9 @@ constexpr bool operator== (const x86_xsave_layout &lhs,
>      && lhs.k_offset == rhs.k_offset
>      && lhs.zmm_h_offset == rhs.zmm_h_offset
>      && lhs.zmm_offset == rhs.zmm_offset
> -    && lhs.pkru_offset == rhs.pkru_offset;
> +    && lhs.pkru_offset == rhs.pkru_offset
> +    && lhs.tilecfg_offset == rhs.tilecfg_offset
> +    && lhs.tiledata_offset == rhs.tiledata_offset;
>  }
> 
>  constexpr bool operator!= (const x86_xsave_layout &lhs,
> @@ -90,21 +101,30 @@ constexpr bool operator!= (const x86_xsave_layout
> &lhs,
>  					| X86_XSTATE_AVX512 |
> X86_XSTATE_PKRU)
>  #define X86_XSTATE_AVX_AVX512_PKU_APX_MASK\
>    (X86_XSTATE_AVX_AVX512_PKU_MASK | X86_XSTATE_APX_F)
> +#define X86_XSTATE_AVX_AVX512_PKU_APX_AMX_MASK\
> +  (X86_XSTATE_AVX_AVX512_PKU_APX_MASK | X86_XSTATE_AMX)
> 
>  /* Supported mask of state-component bitmap xstate_bv.  The SDM defines
>     xstate_bv as XCR0 | IA32_XSS.  */
> 
> -#define X86_XSTATE_ALL_MASK
> 	(X86_XSTATE_AVX_AVX512_PKU_APX_MASK\
> -					| X86_XSTATE_CET_U)
> +#define X86_XSTATE_ALL_MASK\
> +  (X86_XSTATE_AVX_AVX512_PKU_APX_AMX_MASK | X86_XSTATE_CET_U)
> 
>  #define X86_XSTATE_SSE_SIZE	576
>  #define X86_XSTATE_AVX_SIZE	832
> 
> +/* Size of the AMX TILECFG register and of the raw tile registers.  */
> +
> +#define X86_AMX_TILECFG_SIZE	64
> +#define X86_AMX_TMM_SIZE	1024
> +#define X86_AMX_NUM_TMM_REGISTERS	8
> +#define X86_AMX_TILEDATA_SIZE	(X86_AMX_NUM_TMM_REGISTERS *
> X86_AMX_TMM_SIZE)
> 
>  #define HAS_AVX(XCR0) (((XCR0) & X86_XSTATE_AVX) != 0)
>  #define HAS_AVX512(XCR0) (((XCR0) & X86_XSTATE_AVX512) != 0)
>  #define HAS_APX(XCR0) (((XCR0) & X86_XSTATE_APX_F) != 0)
>  #define HAS_PKRU(XCR0) (((XCR0) & X86_XSTATE_PKRU) != 0)
> +#define HAS_AMX(XCR0) (((XCR0) & X86_XSTATE_AMX) != 0)
> 
>  /* Initial value for fctrl register, as defined in the X86 manual, and
>     confirmed in the (Linux) kernel source.  When the x87 floating point
> --
> 2.43.0
> 
> ________________________________________
> Intel Deutschland GmbH
> 
> Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
> 
> Tel: +49 (89) 99143-0
> 
> www.intel.de
> 
> Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran
> Sitaraman
> 
> Chairperson of the Supervisory Board: Sonja Pierer
> 
> Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB
> 186928
> 
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.

I have 2 more comments for the test:

I think it be good if we test gdb_continue_to_end including a " _tile_release ();"
in the test source file like Felix initial version, to make sure we don't end with
an invalid state.

You can make the crash conditional, like the other x86 registers tests for OS core files.

Also, it would be nice if we ran an AMX operation based on data written by GDB.
It doesn't have to be as complex as the previous version of this test though.

Thanks,
Christina
________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

  parent reply	other threads:[~2026-11-03 14:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30 11:50 [PATCH v2 0/5] Add Intel AMX support Stephan Rohr
2026-10-30 11:50 ` [PATCH v2 1/5] gdb: define additional integer built-in types Stephan Rohr
2026-10-30 12:45   ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers Stephan Rohr
2026-10-30 12:47   ` Eli Zaretskii
2026-11-03 10:44   ` Joos, Christina
2026-11-03 14:40   ` Joos, Christina [this message]
2026-10-30 11:50 ` [PATCH v2 3/5] gdb: support register groups for user registers Stephan Rohr
2026-10-30 12:48   ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 4/5] gdb: add a "matrix" register group Stephan Rohr
2026-10-30 12:49   ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers Stephan Rohr
2026-10-30 12:50   ` Eli Zaretskii
2026-11-03 15:19   ` Joos, Christina
2026-11-04  9:00     ` Joos, Christina

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=SN7PR11MB76389F0371C3CEFA716B9AD689692@SN7PR11MB7638.namprd11.prod.outlook.com \
    --to=christina.joos@intel.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.org \
    --cc=luis.machado@arm.com \
    --cc=pedro@palves.net \
    --cc=stephan.rohr@intel.com \
    /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