[v2] PowerPC: Add NT_PPC_DMR core file support

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

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

Abhay Kandpal Sept. 22, 2026, 7:08 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.
Changes in v2
- Moved elfcore_grok_ppc_dmr and elfcore_write_ppc_dmr after their
  tm_cdscr counterparts to match the declaration order in elf-bfd.h.

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

Comments

Surya Kumari Jangala Sept. 22, 2026, 9:04 a.m. UTC | #1
LGTM. Ok to upstream.

-Surya

On 22/09/26 12:38 PM, 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.
> Changes in v2
> - Moved elfcore_grok_ppc_dmr and elfcore_write_ppc_dmr after their
>   tm_cdscr counterparts to match the declaration order in elf-bfd.h.
> 
>  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 e7a98bfcd8d..6e21dcac80c 100644
> --- a/bfd/elf-bfd.h
> +++ b/bfd/elf-bfd.h
> @@ -3105,6 +3105,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 ea127919b9f..2cae97a6dd3 100644
> --- a/bfd/elf.c
> +++ b/bfd/elf.c
> @@ -81,6 +81,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"
> @@ -10567,6 +10568,12 @@ elfcore_grok_ppc_tm_cdscr (bfd *abfd, Elf_Internal_Note *note)
>    return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CDSCR, 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_s390_high_gprs (bfd *abfd, Elf_Internal_Note *note)
>  {
> @@ -11185,6 +11192,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);
> @@ -12602,6 +12610,17 @@ elfcore_write_ppc_tm_cdscr (bfd *abfd,
>  			     ppc_tm_cdscr, 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);
> +}
> +
>  static char *
>  elfcore_write_s390_high_gprs (bfd *abfd,
>  			      char *buf,
> @@ -13046,6 +13065,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 4fb9d8cbd5f..b86bf3eb294 100644
> --- a/binutils/readelf.c
> +++ b/binutils/readelf.c
> @@ -21440,6 +21440,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 14582d2385f..6b99f0075bf 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 e7a98bfcd8d..6e21dcac80c 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -3105,6 +3105,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 ea127919b9f..2cae97a6dd3 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -81,6 +81,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"
@@ -10567,6 +10568,12 @@  elfcore_grok_ppc_tm_cdscr (bfd *abfd, Elf_Internal_Note *note)
   return elfcore_make_note_pseudosection (abfd, NOTE_PSEUDO_SECTION_PPC_TM_CDSCR, 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_s390_high_gprs (bfd *abfd, Elf_Internal_Note *note)
 {
@@ -11185,6 +11192,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);
@@ -12602,6 +12610,17 @@  elfcore_write_ppc_tm_cdscr (bfd *abfd,
 			     ppc_tm_cdscr, 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);
+}
+
 static char *
 elfcore_write_s390_high_gprs (bfd *abfd,
 			      char *buf,
@@ -13046,6 +13065,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 4fb9d8cbd5f..b86bf3eb294 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -21440,6 +21440,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 14582d2385f..6b99f0075bf 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 */