[v1] PowerPC: Add NT_PPC_DMR core file support

Message ID 20260622101408.1384811-1-abhay@linux.ibm.com
State New
Headers
Series [v1] PowerPC: Add NT_PPC_DMR core file support |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Abhay Kandpal June 22, 2026, 10:14 a.m. UTC
  Add BFD and readelf support for the new NT_PPC_DMR note type, which
carries the contents of the Dense Math Registers (DMR) available on
a future PowerPC processor. The DMR register set consists of eight
1024-bit registers introduced by the Dense Math facility in a future
Power ISA revision.

GDB support for reading and writing DMR registers, both from live
processes and from core files, will be added as a follow-up patch.

bfd/
	* elf-bfd.h (elfcore_write_ppc_dmr): Declare.
	* elf.c (NOTE_PSEUDO_SECTION_PPC_DMR): Define.
	(elfcore_grok_ppc_dmr): New function.
	(elfcore_grok_note) <NT_PPC_DMR>: Handle it.
	(elfcore_write_ppc_dmr): New function.
	(elfcore_write_register_note): Handle .reg-ppc-dmr.

binutils/
	* readelf.c (get_note_type) <NT_PPC_DMR>: Handle it.

include/
	* elf/common.h (NT_PPC_DMR): New macro.
---
This patch is reg tested.

 bfd/elf-bfd.h        |  2 ++
 bfd/elf.c            | 20 ++++++++++++++++++++
 binutils/readelf.c   |  2 ++
 include/elf/common.h |  2 ++
 4 files changed, 26 insertions(+)
  

Comments

Abhay Kandpal July 13, 2026, 8:09 a.m. UTC | #1
Hi all,

Just a gentle ping to see if anyone has had a chance to review this patch,
or if any further changes are needed on my end.

Regards
Abhay Kandpal

On 22/06/26 15:44, Abhay Kandpal wrote:
> Add BFD and readelf support for the new NT_PPC_DMR note type, which
> carries the contents of the Dense Math Registers (DMR) available on
> a future PowerPC processor. The DMR register set consists of eight
> 1024-bit registers introduced by the Dense Math facility in a future
> Power ISA revision.
>
> GDB support for reading and writing DMR registers, both from live
> processes and from core files, will be added as a follow-up patch.
>
> bfd/
> 	* elf-bfd.h (elfcore_write_ppc_dmr): Declare.
> 	* elf.c (NOTE_PSEUDO_SECTION_PPC_DMR): Define.
> 	(elfcore_grok_ppc_dmr): New function.
> 	(elfcore_grok_note) <NT_PPC_DMR>: Handle it.
> 	(elfcore_write_ppc_dmr): New function.
> 	(elfcore_write_register_note): Handle .reg-ppc-dmr.
>
> binutils/
> 	* readelf.c (get_note_type) <NT_PPC_DMR>: Handle it.
>
> include/
> 	* elf/common.h (NT_PPC_DMR): New macro.
> ---
> This patch is reg tested.
>
>   bfd/elf-bfd.h        |  2 ++
>   bfd/elf.c            | 20 ++++++++++++++++++++
>   binutils/readelf.c   |  2 ++
>   include/elf/common.h |  2 ++
>   4 files changed, 26 insertions(+)
>
> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
> index 88d35925987..0605d31107f 100644
> --- a/bfd/elf-bfd.h
> +++ b/bfd/elf-bfd.h
> @@ -3100,6 +3100,8 @@ extern char *elfcore_write_ppc_tm_cppr
>     (bfd *, char *, int *, const void *, int);
>   extern char *elfcore_write_ppc_tm_cdscr
>     (bfd *, char *, int *, const void *, int);
> +extern char *elfcore_write_ppc_dmr
> +  (bfd *, char *, int *, const void *, int);
>   extern char *elfcore_write_s390_timer
>     (bfd *, char *, int *, const void *, int);
>   extern char *elfcore_write_s390_todcmp
> diff --git a/bfd/elf.c b/bfd/elf.c
> index c9a68404e9d..d0769d03644 100644
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -80,6 +80,7 @@ SECTION
>   #define NOTE_PSEUDO_SECTION_LOONGARCH_LASX	".reg-loongarch-lasx"
>   #define NOTE_PSEUDO_SECTION_LOONGARCH_LBT	".reg-loongarch-lbt"
>   #define NOTE_PSEUDO_SECTION_LOONGARCH_LSX	".reg-loongarch-lsx"
> +#define NOTE_PSEUDO_SECTION_PPC_DMR		".reg-ppc-dmr"
>   #define NOTE_PSEUDO_SECTION_PPC_DSCR		".reg-ppc-dscr"
>   #define NOTE_PSEUDO_SECTION_PPC_EBB		".reg-ppc-ebb"
>   #define NOTE_PSEUDO_SECTION_PPC_PMU		".reg-ppc-pmu" @@ -10507,6 +10508,12 @@ elfcore_grok_ppc_vsx (bfd *abfd, 
> Elf_Internal_Note *note) return elfcore_make_note_pseudosection (abfd, 
> NOTE_PSEUDO_SECTION_PPC_VSX, note); } +static bool 
> +elfcore_grok_ppc_dmr (bfd *abfd, Elf_Internal_Note *note) +{ + return 
> elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_DMR, 
> note); +} + static bool elfcore_grok_ppc_tar (bfd *abfd, 
> Elf_Internal_Note *note) { @@ -11193,6 +11200,7 @@ elfcore_grok_note 
> (bfd *abfd, Elf_Internal_Note *note) case NT_LARCH_LASX: return 
> elfcore_grok_loongarch_lasx (abfd, note); case NT_LARCH_LBT: return 
> elfcore_grok_loongarch_lbt (abfd, note); case NT_LARCH_LSX: return 
> elfcore_grok_loongarch_lsx (abfd, note); + case NT_PPC_DMR: return 
> elfcore_grok_ppc_dmr (abfd, note); case NT_PPC_DSCR: return 
> elfcore_grok_ppc_dscr (abfd, note); case NT_PPC_EBB: return 
> elfcore_grok_ppc_ebb (abfd, note); case NT_PPC_PMU: return 
> elfcore_grok_ppc_pmu (abfd, note); @@ -12459,6 +12467,17 @@ 
> elfcore_write_ppc_vsx (bfd *abfd, NOTE_NAME_LINUX, NT_PPC_VSX, 
> ppc_vsx, size); } +char * +elfcore_write_ppc_dmr (bfd *abfd, + char 
> *buf, + int *bufsiz, + const void *ppc_dmr, + int size) +{ + return 
> elfcore_write_note (abfd, buf, bufsiz, + NOTE_NAME_LINUX, NT_PPC_DMR, 
> ppc_dmr, size); +} + char * elfcore_write_ppc_tar (bfd *abfd, char 
> *buf, @@ -13040,6 +13059,7 @@ elfcore_write_register_note (bfd *abfd, 
> { NOTE_PSEUDO_SECTION_LOONGARCH_LASX, elfcore_write_loongarch_lasx}, { 
> NOTE_PSEUDO_SECTION_LOONGARCH_LBT, elfcore_write_loongarch_lbt}, { 
> NOTE_PSEUDO_SECTION_LOONGARCH_LSX, elfcore_write_loongarch_lsx}, + { 
> NOTE_PSEUDO_SECTION_PPC_DMR, elfcore_write_ppc_dmr}, { 
> NOTE_PSEUDO_SECTION_PPC_DSCR, elfcore_write_ppc_dscr}, { 
> NOTE_PSEUDO_SECTION_PPC_EBB, elfcore_write_ppc_ebb}, { 
> NOTE_PSEUDO_SECTION_PPC_PMU, elfcore_write_ppc_pmu}, diff --git 
> a/binutils/readelf.c b/binutils/readelf.c index 
> bf27f9eec23..aed0b058732 100644 --- a/binutils/readelf.c +++ 
> b/binutils/readelf.c @@ -21847,6 +21847,8 @@ get_note_type (Filedata * 
> filedata, unsigned e_type) return _("NT_PPC_TM_CPPR (ppc checkpointed PPR register)");
>         case NT_PPC_TM_CDSCR:
>   	return _("NT_PPC_TM_CDSCR (ppc checkpointed DSCR register)");
> +      case NT_PPC_DMR:
> +	return _("NT_PPC_DMR (ppc Dense Math registers)");
>         case NT_386_TLS:
>   	return _("NT_386_TLS (x86 TLS information)");
>         case NT_386_IOPERM:
> diff --git a/include/elf/common.h b/include/elf/common.h
> index 1ae68221a89..bd327194b7e 100644
> --- a/include/elf/common.h
> +++ b/include/elf/common.h
> @@ -686,6 +686,8 @@
>   					/*   note name must be "LINUX".  */
>   #define NT_PPC_TM_CDSCR	0x10f		/* PowerPC TM checkpointed Data SCR */
>   					/*   note name must be "LINUX".  */
> +#define NT_PPC_DMR	0x113		/* PowerPC Dense Math Registers */
> +					/*   note name must be "LINUX".  */
>   #define NT_386_TLS	0x200		/* x86 TLS information */
>   					/*   note name must be "LINUX".  */
>   #define NT_386_IOPERM	0x201		/* x86 io permissions */
  

Patch

diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index 88d35925987..0605d31107f 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -3100,6 +3100,8 @@  extern char *elfcore_write_ppc_tm_cppr
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_ppc_tm_cdscr
   (bfd *, char *, int *, const void *, int);
+extern char *elfcore_write_ppc_dmr
+  (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_s390_timer
   (bfd *, char *, int *, const void *, int);
 extern char *elfcore_write_s390_todcmp
diff --git a/bfd/elf.c b/bfd/elf.c
index c9a68404e9d..d0769d03644 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -80,6 +80,7 @@  SECTION
 #define NOTE_PSEUDO_SECTION_LOONGARCH_LASX	".reg-loongarch-lasx"
 #define NOTE_PSEUDO_SECTION_LOONGARCH_LBT	".reg-loongarch-lbt"
 #define NOTE_PSEUDO_SECTION_LOONGARCH_LSX	".reg-loongarch-lsx"
+#define NOTE_PSEUDO_SECTION_PPC_DMR		".reg-ppc-dmr"
 #define NOTE_PSEUDO_SECTION_PPC_DSCR		".reg-ppc-dscr"
 #define NOTE_PSEUDO_SECTION_PPC_EBB		".reg-ppc-ebb"
 #define NOTE_PSEUDO_SECTION_PPC_PMU		".reg-ppc-pmu"
@@ -10507,6 +10508,12 @@  elfcore_grok_ppc_vsx (bfd *abfd, Elf_Internal_Note *note)
   return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_VSX, note);
 }
 
+static bool
+elfcore_grok_ppc_dmr (bfd *abfd, Elf_Internal_Note *note)
+{
+  return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_DMR, note);
+}
+
 static bool
 elfcore_grok_ppc_tar (bfd *abfd, Elf_Internal_Note *note)
 {
@@ -11193,6 +11200,7 @@  elfcore_grok_note (bfd *abfd, Elf_Internal_Note *note)
 	case NT_LARCH_LASX:	return elfcore_grok_loongarch_lasx (abfd, note);
 	case NT_LARCH_LBT:	return elfcore_grok_loongarch_lbt (abfd, note);
 	case NT_LARCH_LSX:	return elfcore_grok_loongarch_lsx (abfd, note);
+	case NT_PPC_DMR:	return elfcore_grok_ppc_dmr (abfd, note);
 	case NT_PPC_DSCR:	return elfcore_grok_ppc_dscr (abfd, note);
 	case NT_PPC_EBB:	return elfcore_grok_ppc_ebb (abfd, note);
 	case NT_PPC_PMU:	return elfcore_grok_ppc_pmu (abfd, note);
@@ -12459,6 +12467,17 @@  elfcore_write_ppc_vsx (bfd *abfd,
 			     NOTE_NAME_LINUX, NT_PPC_VSX, ppc_vsx, size);
 }
 
+char *
+elfcore_write_ppc_dmr (bfd *abfd,
+		       char *buf,
+		       int *bufsiz,
+		       const void *ppc_dmr,
+		       int size)
+{
+  return elfcore_write_note (abfd, buf, bufsiz,
+			     NOTE_NAME_LINUX, NT_PPC_DMR, ppc_dmr, size);
+}
+
 char *
 elfcore_write_ppc_tar (bfd *abfd,
 		       char *buf,
@@ -13040,6 +13059,7 @@  elfcore_write_register_note (bfd *abfd,
       { NOTE_PSEUDO_SECTION_LOONGARCH_LASX,   elfcore_write_loongarch_lasx},
       { NOTE_PSEUDO_SECTION_LOONGARCH_LBT,    elfcore_write_loongarch_lbt},
       { NOTE_PSEUDO_SECTION_LOONGARCH_LSX,    elfcore_write_loongarch_lsx},
+      { NOTE_PSEUDO_SECTION_PPC_DMR,          elfcore_write_ppc_dmr},
       { NOTE_PSEUDO_SECTION_PPC_DSCR,         elfcore_write_ppc_dscr},
       { NOTE_PSEUDO_SECTION_PPC_EBB,          elfcore_write_ppc_ebb},
       { NOTE_PSEUDO_SECTION_PPC_PMU,          elfcore_write_ppc_pmu},
diff --git a/binutils/readelf.c b/binutils/readelf.c
index bf27f9eec23..aed0b058732 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -21847,6 +21847,8 @@  get_note_type (Filedata * filedata, unsigned e_type)
 	return _("NT_PPC_TM_CPPR (ppc checkpointed PPR register)");
       case NT_PPC_TM_CDSCR:
 	return _("NT_PPC_TM_CDSCR (ppc checkpointed DSCR register)");
+      case NT_PPC_DMR:
+	return _("NT_PPC_DMR (ppc Dense Math registers)");
       case NT_386_TLS:
 	return _("NT_386_TLS (x86 TLS information)");
       case NT_386_IOPERM:
diff --git a/include/elf/common.h b/include/elf/common.h
index 1ae68221a89..bd327194b7e 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -686,6 +686,8 @@ 
 					/*   note name must be "LINUX".  */
 #define NT_PPC_TM_CDSCR	0x10f		/* PowerPC TM checkpointed Data SCR */
 					/*   note name must be "LINUX".  */
+#define NT_PPC_DMR	0x113		/* PowerPC Dense Math Registers */
+					/*   note name must be "LINUX".  */
 #define NT_386_TLS	0x200		/* x86 TLS information */
 					/*   note name must be "LINUX".  */
 #define NT_386_IOPERM	0x201		/* x86 io permissions */