public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [aarch64] sme2: Teach binutils/BFD about the NT_ARM_ZT register set
@ 2023-06-30 13:45 Luis Machado
  2023-07-07  8:46 ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Luis Machado @ 2023-06-30 13:45 UTC (permalink / raw)
  To: binutils

The Scalable Matrix Extension v2 (SME2) defines a new register, ZT0, that
the Linux Kernel handles through a new NT_ARM_ZT register set.

Teach binutils/BFD about it so that gdb can make use of it for reading
and writing core files.  This also enables readelf/objdump to show the
correct identification for the NT_ARM_ZT register set.

Validated under Fast Models.
---
 bfd/elf-bfd.h        |  2 ++
 bfd/elf.c            | 37 +++++++++++++++++++++++++++++++++++++
 binutils/readelf.c   |  2 ++
 include/elf/common.h |  2 ++
 4 files changed, 43 insertions(+)

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 2a9eed7f9ee..0baee5acfa6 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -2943,6 +2943,8 @@ extern char *elfcore_write_aarch_ssve
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_aarch_za
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_aarch_zt
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_arc_v2
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_riscv_csr
diff --git a/bfd/elf.c b/bfd/elf.c
index 2a097b02977..e8ab2546d91 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -10692,6 +10692,15 @@ elfcore_grok_aarch_za (bfd *abfd, Elf_Internal_Note *note)
   return elfcore_make_note_pseudosection (abfd, ".reg-aarch-za", note);
 }
 
+/* Convert NOTE into a bfd_section called ".reg-aarch-zt".  Return TRUE if
+   successful, otherwise return FALSE.  */
+
+static bool
+elfcore_grok_aarch_zt (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, ".reg-aarch-zt", note);
+}
+
 static bool
 elfcore_grok_arc_v2 (bfd *abfd, Elf_Internal_Note *note)
 {
@@ -11421,6 +11430,13 @@ elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
       else
 	return true;
 
+    case NT_ARM_ZT:
+      if (note->namesz == 6
+	  && strcmp (note->namedata, "LINUX") == 0)
+	return elfcore_grok_aarch_zt (abfd, note);
+      else
+	return true;
+
     case NT_GDB_TDESC:
       if (note->namesz == 4
 	  && strcmp (note->namedata, "GDB") == 0)
@@ -13063,6 +13079,25 @@ elfcore_write_aarch_za (bfd *abfd,
 			     size);
 }
 
+/* Write the buffer of zt register values in aarch_zt (length SIZE) into
+   the note buffer BUF and update *BUFSIZ.  ABFD is the bfd the note is being
+   written into.  Return a pointer to the new start of the note buffer, to
+   replace BUF which may no longer be valid.  */
+
+char *
+elfcore_write_aarch_zt (bfd *abfd,
+			char *buf,
+			int *bufsiz,
+			const void *aarch_zt,
+			int size)
+{
+  char *note_name = "LINUX";
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     note_name, NT_ARM_ZT,
+			     aarch_zt,
+			     size);
+}
+
 char *
 elfcore_write_arc_v2 (bfd *abfd,
 		      char *buf,
@@ -13248,6 +13283,8 @@ elfcore_write_register_note (bfd *abfd,
     return elfcore_write_aarch_ssve (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-aarch-za") == 0)
     return elfcore_write_aarch_za (abfd, buf, bufsiz, data, size);
+  if (strcmp (section, ".reg-aarch-zt") == 0)
+    return elfcore_write_aarch_zt (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".reg-arc-v2") == 0)
     return elfcore_write_arc_v2 (abfd, buf, bufsiz, data, size);
   if (strcmp (section, ".gdb-tdesc") == 0)
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 97d72d0b95f..d1c7e5aa450 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -19654,6 +19654,8 @@ get_note_type (Filedata * filedata, unsigned e_type)
 	return _("NT_ARM_SSVE (AArch64 streaming SVE registers)");
       case NT_ARM_ZA:
 	return _("NT_ARM_ZA (AArch64 SME ZA register)");
+      case NT_ARM_ZT:
+	return _("NT_ARM_ZT (AArch64 SME2 ZT registers)");
       case NT_ARM_PAC_ENABLED_KEYS:
 	return _("NT_ARM_PAC_ENABLED_KEYS (AArch64 pointer authentication enabled keys)");
       case NT_ARC_V2:
diff --git a/include/elf/common.h b/include/elf/common.h
index ffa6b60bd2b..932ea94e3ae 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -701,6 +701,8 @@
 					/*   Note: name must be "LINUX".  */
 #define NT_ARM_ZA       0x40c           /* AArch64 SME ZA register.  */
 					/*   Note: name must be "LINUX".  */
+#define NT_ARM_ZT       0x40d           /* AArch64 SME2 ZT registers.  */
+					/*   Note: name must be "LINUX".  */
 #define NT_ARC_V2	0x600		/* ARC HS accumulator/extra registers.  */
 					/*   note name must be "LINUX".  */
 #define NT_LARCH_CPUCFG 0xa00		/* LoongArch CPU config registers */
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [aarch64] sme2: Teach binutils/BFD about the NT_ARM_ZT register set
  2023-06-30 13:45 [PATCH] [aarch64] sme2: Teach binutils/BFD about the NT_ARM_ZT register set Luis Machado
@ 2023-07-07  8:46 ` Nick Clifton
  2023-07-07  8:57   ` Luis Machado
  2023-08-21 13:25   ` Luis Machado
  0 siblings, 2 replies; 4+ messages in thread
From: Nick Clifton @ 2023-07-07  8:46 UTC (permalink / raw)
  To: Luis Machado, binutils

Hi Luis,

> The Scalable Matrix Extension v2 (SME2) defines a new register, ZT0, that
> the Linux Kernel handles through a new NT_ARM_ZT register set.
> 
> Teach binutils/BFD about it so that gdb can make use of it for reading
> and writing core files.  This also enables readelf/objdump to show the
> correct identification for the NT_ARM_ZT register set.

Approved - please apply.

Cheers
   Nick



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [aarch64] sme2: Teach binutils/BFD about the NT_ARM_ZT register set
  2023-07-07  8:46 ` Nick Clifton
@ 2023-07-07  8:57   ` Luis Machado
  2023-08-21 13:25   ` Luis Machado
  1 sibling, 0 replies; 4+ messages in thread
From: Luis Machado @ 2023-07-07  8:57 UTC (permalink / raw)
  To: Nick Clifton, binutils

On 7/7/23 09:46, Nick Clifton wrote:
> Hi Luis,
> 
>> The Scalable Matrix Extension v2 (SME2) defines a new register, ZT0, that
>> the Linux Kernel handles through a new NT_ARM_ZT register set.
>>
>> Teach binutils/BFD about it so that gdb can make use of it for reading
>> and writing core files.  This also enables readelf/objdump to show the
>> correct identification for the NT_ARM_ZT register set.
> 
> Approved - please apply.
> 
> Cheers
>   Nick
> 
> 

Thanks. Same as the SME patch. I'll wait for the gdb-side changes to be OK-ed before I push this.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] [aarch64] sme2: Teach binutils/BFD about the NT_ARM_ZT register set
  2023-07-07  8:46 ` Nick Clifton
  2023-07-07  8:57   ` Luis Machado
@ 2023-08-21 13:25   ` Luis Machado
  1 sibling, 0 replies; 4+ messages in thread
From: Luis Machado @ 2023-08-21 13:25 UTC (permalink / raw)
  To: Nick Clifton, binutils

On 7/7/23 09:46, Nick Clifton wrote:
> Hi Luis,
> 
>> The Scalable Matrix Extension v2 (SME2) defines a new register, ZT0, that
>> the Linux Kernel handles through a new NT_ARM_ZT register set.
>>
>> Teach binutils/BFD about it so that gdb can make use of it for reading
>> and writing core files.  This also enables readelf/objdump to show the
>> correct identification for the NT_ARM_ZT register set.
> 
> Approved - please apply.
> 
> Cheers
>   Nick
> 
> 

Pushed this now.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-08-21 13:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-30 13:45 [PATCH] [aarch64] sme2: Teach binutils/BFD about the NT_ARM_ZT register set Luis Machado
2023-07-07  8:46 ` Nick Clifton
2023-07-07  8:57   ` Luis Machado
2023-08-21 13:25   ` Luis Machado

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).