Skip to contentSkip to conversation

add Altivec/VMX state to coredumps

PATCH Superseded [email protected] 4 participants 12 messages Oct 11, 2007 – Oct 12, 2007

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover add Altivec/VMX state to coredumps

Signature · 12 lines
Here's the new and improved patch to add Altivec/VMX state into the coredump.

It's now two patches:
* the first patch makes the note type of the state dumped by
  elf_core_copy_task_xfpregs() a #define and adds the appropriate #defines so
  that archs that support SSE still have their note type as NT_PRXFPREG
* the second patch actually adds the Altivec/VMX state to the coredumps and
  uses a note type of NT_PPC_VMX that's #defined as 0x100. Thus SPE could use
  a note type of NT_PPC_SPE and 0x101, for example.

The second patch is essentially the same as the single patch that was posted on
2007-09-25, but with the addition of the new NT_PPC_VMX note type.
#1 lore raw

PATCH 1/2 Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE in the coredump code which allows for more flexibility in the note type for the state of 'extended floating point' implementations in coredumps. New note types can now be added with an appropriate #define.

#define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

---
 arch/ia64/ia32/elfcore32.h     |    1 +
 arch/x86_64/ia32/ia32_binfmt.c |    1 +
 fs/binfmt_elf.c                |    4 ++--
 include/asm-i386/elf.h         |    1 +
 4 files changed, 5 insertions(+), 2 deletions(-)
arch/ia64/ia32/elfcore32.h +1 -0
Index: linux/arch/ia64/ia32/elfcore32.h
===================================================================
@@ -117,6 +117,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *tsk, elf_fpxregset_t *xfpu)
 {
arch/x86_64/ia32/ia32_binfmt.c +1 -0
Index: linux/arch/x86_64/ia32/ia32_binfmt.c
===================================================================
@@ -188,6 +188,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int 
 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
 {
fs/binfmt_elf.c +2 -2
Index: linux/fs/binfmt_elf.c
===================================================================
@@ -1446,8 +1446,8 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
-			  &t->xfpu);
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE,
+			  sizeof(t->xfpu), &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
 	}
include/asm-i386/elf.h +1 -0
Index: linux/include/asm-i386/elf.h
===================================================================
@@ -129,6 +129,7 @@ extern int dump_task_extended_fpu (struc
 #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
 #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs)
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 
 #define VDSO_HIGH_BASE		(__fix_to_virt(FIX_VDSO))
 #define VDSO_CURRENT_BASE	((unsigned long)current->mm->context.vdso)
#11 lore raw

PATCH 2/2 add Altivec/VMX state to coredumps

In reply to [email protected]

Update dump_task_altivec() (that has so far never been put to use) so that it dumps the Altivec/VMX registers (VR[0] - VR[31], VSCR and VRSAVE) in the same format as the ptrace get_vrregs() and add the appropriate glue typedef and #defines to make it work.

A new note type of NT_PPC_VMX was chosen to be 0x100 (arbitrarily) because it allows the low range values to be used for more generic purposes and 0x100 seems an adequate starting point for PowerPC extensions.

---
 arch/powerpc/kernel/process.c |   28 +++++++++++++++++++++++++---
 include/asm-powerpc/elf.h     |    8 ++++++++
 include/linux/elf.h           |    1 +
 3 files changed, 34 insertions(+), 3 deletions(-)
arch/powerpc/kernel/process.c +25 -3
Index: linux/arch/powerpc/kernel/process.c
===================================================================
@@ -149,10 +149,32 @@ void flush_altivec_to_thread(struct task
 	}
 }
 
-int dump_task_altivec(struct pt_regs *regs, elf_vrregset_t *vrregs)
+int dump_task_altivec(struct task_struct *tsk, elf_vrregset_t *vrregs)
 {
-	flush_altivec_to_thread(current);
-	memcpy(vrregs, &current->thread.vr[0], sizeof(*vrregs));
+	/* ELF_NVRREG includes the VSCR and VRSAVE which we need to save
+	 * separately, see below */
+	const int nregs = ELF_NVRREG - 2;
+	elf_vrreg_t *reg;
+	u32 *dest;
+
+	if (tsk == current)
+		flush_altivec_to_thread(tsk);
+
+	reg = (elf_vrreg_t *)vrregs;
+
+	/* copy the 32 vr registers */
+	memcpy(reg, &tsk->thread.vr[0], nregs * sizeof(*reg));
+	reg += nregs;
+
+	/* copy the vscr */
+	memcpy(reg, &tsk->thread.vscr, sizeof(*reg));
+	reg++;
+
+	/* vrsave is stored in the high 32bit slot of the final 128bits */
+	memset(reg, 0, sizeof(*reg));
+	dest = (u32 *)reg;
+	*dest = tsk->thread.vrsave;
+
 	return 1;
 }
 #endif /* CONFIG_ALTIVEC */
include/asm-powerpc/elf.h +8 -0
Index: linux/include/asm-powerpc/elf.h
===================================================================
@@ -212,6 +212,14 @@ static inline int dump_task_regs(struct 
 extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *); 
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
 
+typedef elf_vrregset_t elf_fpxregset_t;
+
+#ifdef CONFIG_ALTIVEC
+extern int dump_task_altivec(struct task_struct *, elf_vrregset_t *vrregs);
+#define ELF_CORE_COPY_XFPREGS(tsk, regs) dump_task_altivec(tsk, regs)
+#define ELF_CORE_XFPREG_TYPE NT_PPC_VMX
+#endif
+
 #endif /* __KERNEL__ */
 
 /* ELF_HWCAP yields a mask that user programs can use to figure out what
include/linux/elf.h +1 -0
Index: linux/include/linux/elf.h
===================================================================
@@ -355,6 +355,7 @@ typedef struct elf64_shdr {
 #define NT_TASKSTRUCT	4
 #define NT_AUXV		6
 #define NT_PRXFPREG     0x46e62b7f      /* copied from gdb5.1/include/elf/common.h */
+#define NT_PPC_VMX	0x100		/* PowerPC Altivec/VMX registers */
 
 
 /* Note header in a PT_NOTE section */
#2 lore raw

Re: [patch 1/2] Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

In reply to [email protected]
Quoted 7 lines · On Oct 11, 2007, at 2:15 AM, [email protected] wrote:

Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE in the coredump code which allows for more flexibility in the note type for the state of 'extended floating point' implementations in coredumps. New note types can now be added with an appropriate #define.

#define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

Can we make this ELF_CORE_VECREG_TYPE or something that is so coupled to the x86 specific name?

Quoted 40 lines
---
 arch/ia64/ia32/elfcore32.h     |    1 +
 arch/x86_64/ia32/ia32_binfmt.c |    1 +
 fs/binfmt_elf.c                |    4 ++--
 include/asm-i386/elf.h         |    1 +
 4 files changed, 5 insertions(+), 2 deletions(-)

Index: linux/arch/ia64/ia32/elfcore32.h
===================================================================

arch/ia64/ia32/elfcore32.h +1 -0
@@ -117,6 +117,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *tsk,  
 elf_fpxregset_t *xfpu)

{
Index: linux/arch/x86_64/ia32/ia32_binfmt.c
===================================================================

arch/x86_64/ia32/ia32_binfmt.c +1 -0
@@ -188,6 +188,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t  
 *xfpu)

{
Index: linux/fs/binfmt_elf.c
===================================================================

fs/binfmt_elf.c static int elf_dump_thread_status(long s · line 1453

Quoted 10 lines
fs/binfmt_elf.c +2 -2
@@ -1446,8 +1446,8 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
-			  &t->xfpu);
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE,
+			  sizeof(t->xfpu), &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
 	}

You've only fixed up one of 4 NT_PRXFPREG uses in the kernel.

Also, I'm not a fan of your proposed mechanism to "overload" the elf_fpxregset_t. I'd rather see us introduce a new elf_vecregset_t and have it typedef'd to be elf_fpxregset_t on i386, x86_64, ia64

Quoted 21 lines

Index: linux/include/asm-i386/elf.h
===================================================================

include/asm-i386/elf.h +1 -0
@@ -129,6 +129,7 @@ extern int dump_task_extended_fpu (struc
 #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk,  
 elf_regs)
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk,  
 elf_fpregs)
 #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs)  
 dump_task_extended_fpu(tsk, elf_xfpregs)
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG

#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO))
#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)

Signature · 4 lines
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
#3 lore raw

Re: [patch 1/2] Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

Quoted 5 lines · Kumar Gala
Quoted 2 lines

#define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

Can we make this ELF_CORE_VECREG_TYPE or something that is so coupled to the x86 specific name?

How is "extended floating point registers" x86-specific?

ELF_CORE_XFPREG_TYPE is a suitable name for something that's used in conjunction with a function called elf_core_copy_task_xfpregs().

Paul.

#4 lore raw

Re: [patch 1/2] Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

Quoted 9 lines · Paul Mackerras
Quoted 5 lines · Kumar Gala
Quoted 2 lines

#define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

Can we make this ELF_CORE_VECREG_TYPE or something that is so coupled to the x86 specific name?

How is "extended floating point registers" x86-specific?

we'll I don't consider the altivec register file as 'extended fp'. I'm assuming the name XFP came from IA32 land when MMX/SSE came into existence.

Quoted 2 lines

ELF_CORE_XFPREG_TYPE is a suitable name for something that's used in conjunction with a function called elf_core_copy_task_xfpregs().

agreed, I think the function name should change as well.

- k

#5 lore raw

Re: [patch 1/2] Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

Quoted 4 lines · Kumar Gala
Quoted 2 lines

ELF_CORE_XFPREG_TYPE is a suitable name for something that's used in conjunction with a function called elf_core_copy_task_xfpregs().

agreed, I think the function name should change as well.

Maybe. Let's do one step at a time...

Paul.

#6 lore raw

Re: [patch 1/2] Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

In reply to Kumar Gala
Quoted 69 lines · Kumar Gala
Quoted 10 lines · On Oct 11, 2007, at 2:15 AM, [email protected] wrote:

Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE in the coredump code which
allows for more flexibility in the note type for the state of 'extended
floating point' implementations in coredumps. New note types can now be
added with an appropriate #define.

#define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

Can we make this ELF_CORE_VECREG_TYPE or something that is so coupled to the x86 specific name?

Quoted 40 lines
---
 arch/ia64/ia32/elfcore32.h     |    1 +
 arch/x86_64/ia32/ia32_binfmt.c |    1 +
 fs/binfmt_elf.c                |    4 ++--
 include/asm-i386/elf.h         |    1 +
 4 files changed, 5 insertions(+), 2 deletions(-)

Index: linux/arch/ia64/ia32/elfcore32.h
===================================================================

arch/ia64/ia32/elfcore32.h +1 -0
@@ -117,6 +117,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *tsk,  
 elf_fpxregset_t *xfpu)

{
Index: linux/arch/x86_64/ia32/ia32_binfmt.c
===================================================================

arch/x86_64/ia32/ia32_binfmt.c +1 -0
@@ -188,6 +188,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t  
 *xfpu)

{
Index: linux/fs/binfmt_elf.c
===================================================================

fs/binfmt_elf.c static int elf_dump_thread_status(long s · line 1453

Quoted 10 lines
fs/binfmt_elf.c +2 -2
@@ -1446,8 +1446,8 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
-			  &t->xfpu);
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE,
+			  sizeof(t->xfpu), &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
 	}

You've only fixed up one of 4 NT_PRXFPREG uses in the kernel.

Quoted 3 lines

Also, I'm not a fan of your proposed mechanism to "overload" the elf_fpxregset_t. I'd rather see us introduce a new elf_vecregset_t and have it typedef'd to be elf_fpxregset_t on i386, x86_64, ia64

He's not overloading it, there is no such thing as an elf_fpxregset_t, unless it's typedef'd to something else by the arch code, eg:

include/asm-i386/elf.h:typedef struct user_fxsr_struct elf_fpxregset_t; include/asm-ia64/elf.h:typedef unsigned long elf_fpxregset_t;

Introducing another typedef would just be another layer of obfuscation IMO, and the elf code doesn't need any more of that.

cheers

Signature · 8 lines
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
#7 lore raw

Re: [patch 1/2] Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

In reply to Kumar Gala
Quoted 54 lines · Kumar Gala
Quoted 7 lines · On Oct 11, 2007, at 2:15 AM, [email protected] wrote:

Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE in the coredump code which allows for more flexibility in the note type for the state of 'extended floating point' implementations in coredumps. New note types can now be added with an appropriate #define.

#define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

Can we make this ELF_CORE_VECREG_TYPE or something that is so coupled to the x86 specific name?

Quoted 40 lines
---
 arch/ia64/ia32/elfcore32.h     |    1 +
 arch/x86_64/ia32/ia32_binfmt.c |    1 +
 fs/binfmt_elf.c                |    4 ++--
 include/asm-i386/elf.h         |    1 +
 4 files changed, 5 insertions(+), 2 deletions(-)

Index: linux/arch/ia64/ia32/elfcore32.h
===================================================================

arch/ia64/ia32/elfcore32.h +1 -0
@@ -117,6 +117,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *tsk, elf_fpxregset_t
 *xfpu)

{
Index: linux/arch/x86_64/ia32/ia32_binfmt.c
===================================================================

arch/x86_64/ia32/ia32_binfmt.c +1 -0
@@ -188,6 +188,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
 {

Index: linux/fs/binfmt_elf.c
===================================================================

fs/binfmt_elf.c +0 -0
@@ -1446,8 +1446,8 @@ static int elf_dump_thread_status(long s
 
Quoted 11 lines

fs/binfmt_elf.c static int elf_dump_thread_status(long s · line 1453

Quoted 9 lines
fs/binfmt_elf.c +2 -2
 #ifdef ELF_CORE_COPY_XFPREGS
     if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-        fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
-              &t->xfpu);
+        fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE,
+              sizeof(t->xfpu), &t->xfpu);
         t->num_notes++;
         sz += notesize(&t->notes[2]);
     }

You've only fixed up one of 4 NT_PRXFPREG uses in the kernel.

Ooops... Right you are - very good pickup :) Fixed in a new version (will send promptly).

Thanks!

Mark.

Quoted 27 lines

Also, I'm not a fan of your proposed mechanism to "overload" the elf_fpxregset_t. I'd rather see us introduce a new elf_vecregset_t and have it typedef'd to be elf_fpxregset_t on i386, x86_64, ia64

Quoted 21 lines

Index: linux/include/asm-i386/elf.h
===================================================================

include/asm-i386/elf.h +1 -0
@@ -129,6 +129,7 @@ extern int dump_task_extended_fpu (struc
 #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk,
 elf_regs)
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk,
 elf_fpregs)
 #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs)
 dump_task_extended_fpu(tsk, elf_xfpregs)
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG

#define VDSO_HIGH_BASE (__fix_to_virt(FIX_VDSO))
#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)

Signature · 4 lines
_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
#8 lore raw

PATCH v2 1/2 Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE in the coredump code which allows for more flexibility in the note type for the state of 'extended floating point' implementations in coredumps. New note types can now be added with an appropriate #define.

This does #define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

This will let us use different note types on powerpc for the Altivec/VMX state that some PowerPC cpus have (G4, PPC970, POWER6) and for the SPE (signal processing extension) state that some embedded PowerPC cpus from Freescale have.

---
 arch/ia64/ia32/elfcore32.h     |    1 +
 arch/x86_64/ia32/ia32_binfmt.c |    1 +
 fs/binfmt_elf.c                |    8 ++++----
 fs/binfmt_elf_fdpic.c          |    6 +++---
 include/asm-i386/elf.h         |    1 +
 5 files changed, 10 insertions(+), 7 deletions(-)
arch/ia64/ia32/elfcore32.h +1 -0
Index: linux/arch/ia64/ia32/elfcore32.h
===================================================================
@@ -117,6 +117,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *tsk, elf_fpxregset_t *xfpu)
 {
arch/x86_64/ia32/ia32_binfmt.c +1 -0
Index: linux/arch/x86_64/ia32/ia32_binfmt.c
===================================================================
@@ -188,6 +188,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int 
 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
 {
fs/binfmt_elf.c +4 -4
Index: linux/fs/binfmt_elf.c
===================================================================
@@ -1411,7 +1411,7 @@ struct elf_thread_status
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
-	elf_fpxregset_t xfpu;		/* NT_PRXFPREG */
+	elf_fpxregset_t xfpu;		/* ELF_CORE_XFPREG_TYPE */
 #endif
 	struct memelfnote notes[3];
 	int num_notes;
@@ -1446,8 +1446,8 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
-			  &t->xfpu);
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE,
+			  sizeof(t->xfpu), &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
 	}
@@ -1624,7 +1624,7 @@ static int elf_core_dump(long signr, str
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(current, xfpu))
 		fill_note(notes + numnote++,
-			  "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
+			  "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu);
 #endif	
   
 	fs = get_fs();
fs/binfmt_elf_fdpic.c +3 -3
Index: linux/fs/binfmt_elf_fdpic.c
===================================================================
@@ -1417,7 +1417,7 @@ struct elf_thread_status
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
-	elf_fpxregset_t xfpu;		/* NT_PRXFPREG */
+	elf_fpxregset_t xfpu;		/* ELF_CORE_XFPREG_TYPE */
 #endif
 	struct memelfnote notes[3];
 	int num_notes;
@@ -1453,7 +1453,7 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(t->xfpu),
 			  &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
@@ -1690,7 +1690,7 @@ static int elf_fdpic_core_dump(long sign
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(current, xfpu))
 		fill_note(notes + numnote++,
-			  "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
+			  "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu);
 #endif
 
 	fs = get_fs();
include/asm-i386/elf.h +1 -0
Index: linux/include/asm-i386/elf.h
===================================================================
@@ -129,6 +129,7 @@ extern int dump_task_extended_fpu (struc
 #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
 #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs)
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 
 #define VDSO_HIGH_BASE		(__fix_to_virt(FIX_VDSO))
 #define VDSO_CURRENT_BASE	((unsigned long)current->mm->context.vdso)
#9 lore raw

Re: [PATCH 1/2] [V2] Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

Sorry for the patch noise but please disregard this patch - a line is longer than 80 characters and I'd hate to be brought up on that...

V3 will be the perfect version then :)

Thanks and apologies again!

Mark.

Quoted 93 lines · Mark Nelson

Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE in the coredump code which allows for more flexibility in the note type for the state of 'extended floating point' implementations in coredumps. New note types can now be added with an appropriate #define.

This does #define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

This will let us use different note types on powerpc for the Altivec/VMX state that some PowerPC cpus have (G4, PPC970, POWER6) and for the SPE (signal processing extension) state that some embedded PowerPC cpus from Freescale have.

---
 arch/ia64/ia32/elfcore32.h     |    1 +
 arch/x86_64/ia32/ia32_binfmt.c |    1 +
 fs/binfmt_elf.c                |    8 ++++----
 fs/binfmt_elf_fdpic.c          |    6 +++---
 include/asm-i386/elf.h         |    1 +
 5 files changed, 10 insertions(+), 7 deletions(-)

Index: linux/arch/ia64/ia32/elfcore32.h
===================================================================

arch/ia64/ia32/elfcore32.h +1 -0
@@ -117,6 +117,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *tsk, elf_fpxregset_t *xfpu)
 {

Index: linux/arch/x86_64/ia32/ia32_binfmt.c
===================================================================

arch/x86_64/ia32/ia32_binfmt.c +1 -0
@@ -188,6 +188,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int 
 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
 {

Index: linux/fs/binfmt_elf.c
===================================================================

fs/binfmt_elf.c +4 -4
@@ -1411,7 +1411,7 @@ struct elf_thread_status
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
-	elf_fpxregset_t xfpu;		/* NT_PRXFPREG */
+	elf_fpxregset_t xfpu;		/* ELF_CORE_XFPREG_TYPE */
 #endif
 	struct memelfnote notes[3];
 	int num_notes;
@@ -1446,8 +1446,8 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
-			  &t->xfpu);
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE,
+			  sizeof(t->xfpu), &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
 	}
@@ -1624,7 +1624,7 @@ static int elf_core_dump(long signr, str
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(current, xfpu))
 		fill_note(notes + numnote++,
-			  "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
+			  "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu);
 #endif	
 
 	fs = get_fs();

Index: linux/fs/binfmt_elf_fdpic.c
===================================================================

fs/binfmt_elf_fdpic.c +1 -1
@@ -1417,7 +1417,7 @@ struct elf_thread_status
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
-	elf_fpxregset_t xfpu;		/* NT_PRXFPREG */
+	elf_fpxregset_t xfpu;		/* ELF_CORE_XFPREG_TYPE */
 #endif
 	struct memelfnote notes[3];
 	int num_notes;

fs/binfmt_elf_fdpic.c static int elf_dump_thread_status(long s · line 1456

Quoted 5 lines
fs/binfmt_elf_fdpic.c +1 -1
@@ -1453,7 +1453,7 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(t->xfpu),

the line above is the offender...

Quoted 29 lines
fs/binfmt_elf_fdpic.c +1 -1
 			  &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
@@ -1690,7 +1690,7 @@ static int elf_fdpic_core_dump(long sign
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(current, xfpu))
 		fill_note(notes + numnote++,
-			  "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
+			  "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu);
 #endif
 
 	fs = get_fs();

Index: linux/include/asm-i386/elf.h
===================================================================

include/asm-i386/elf.h +1 -0
@@ -129,6 +129,7 @@ extern int dump_task_extended_fpu (struc
 #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
 #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs)
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 
 #define VDSO_HIGH_BASE		(__fix_to_virt(FIX_VDSO))
 #define VDSO_CURRENT_BASE	((unsigned long)current->mm->context.vdso)

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev

#10 lore raw

PATCH v3 1/2 Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE #define

In reply to Mark Nelson

Replace NT_PRXFPREG with ELF_CORE_XFPREG_TYPE in the coredump code which allows for more flexibility in the note type for the state of 'extended floating point' implementations in coredumps. New note types can now be added with an appropriate #define.

This does #define ELF_CORE_XFPREG_TYPE to be NT_PRXFPREG in all current users so there's are no change in behaviour.

This will let us use different note types on powerpc for the Altivec/VMX state that some PowerPC cpus have (G4, PPC970, POWER6) and for the SPE (signal processing extension) state that some embedded PowerPC cpus from Freescale have.

---
 arch/ia64/ia32/elfcore32.h     |    1 +
 arch/x86_64/ia32/ia32_binfmt.c |    1 +
 fs/binfmt_elf.c                |    8 ++++----
 fs/binfmt_elf_fdpic.c          |    8 ++++----
 include/asm-i386/elf.h         |    1 +
 5 files changed, 11 insertions(+), 8 deletions(-)
arch/ia64/ia32/elfcore32.h +1 -0
Index: linux/arch/ia64/ia32/elfcore32.h
===================================================================
@@ -117,6 +117,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int
 elf_core_copy_task_xfpregs(struct task_struct *tsk, elf_fpxregset_t *xfpu)
 {
arch/x86_64/ia32/ia32_binfmt.c +1 -0
Index: linux/arch/x86_64/ia32/ia32_binfmt.c
===================================================================
@@ -188,6 +188,7 @@ elf_core_copy_task_fpregs(struct task_st
 }
 
 #define ELF_CORE_COPY_XFPREGS 1
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 static inline int 
 elf_core_copy_task_xfpregs(struct task_struct *t, elf_fpxregset_t *xfpu)
 {
fs/binfmt_elf.c +4 -4
Index: linux/fs/binfmt_elf.c
===================================================================
@@ -1411,7 +1411,7 @@ struct elf_thread_status
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
-	elf_fpxregset_t xfpu;		/* NT_PRXFPREG */
+	elf_fpxregset_t xfpu;		/* ELF_CORE_XFPREG_TYPE */
 #endif
 	struct memelfnote notes[3];
 	int num_notes;
@@ -1446,8 +1446,8 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
-			  &t->xfpu);
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE,
+			  sizeof(t->xfpu), &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
 	}
@@ -1624,7 +1624,7 @@ static int elf_core_dump(long signr, str
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(current, xfpu))
 		fill_note(notes + numnote++,
-			  "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
+			  "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu);
 #endif	
   
 	fs = get_fs();
fs/binfmt_elf_fdpic.c +4 -4
Index: linux/fs/binfmt_elf_fdpic.c
===================================================================
@@ -1417,7 +1417,7 @@ struct elf_thread_status
 	elf_fpregset_t fpu;		/* NT_PRFPREG */
 	struct task_struct *thread;
 #ifdef ELF_CORE_COPY_XFPREGS
-	elf_fpxregset_t xfpu;		/* NT_PRXFPREG */
+	elf_fpxregset_t xfpu;		/* ELF_CORE_XFPREG_TYPE */
 #endif
 	struct memelfnote notes[3];
 	int num_notes;
@@ -1453,8 +1453,8 @@ static int elf_dump_thread_status(long s
 
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(p, &t->xfpu)) {
-		fill_note(&t->notes[2], "LINUX", NT_PRXFPREG, sizeof(t->xfpu),
-			  &t->xfpu);
+		fill_note(&t->notes[2], "LINUX", ELF_CORE_XFPREG_TYPE,
+			  sizeof(t->xfpu), &t->xfpu);
 		t->num_notes++;
 		sz += notesize(&t->notes[2]);
 	}
@@ -1690,7 +1690,7 @@ static int elf_fdpic_core_dump(long sign
 #ifdef ELF_CORE_COPY_XFPREGS
 	if (elf_core_copy_task_xfpregs(current, xfpu))
 		fill_note(notes + numnote++,
-			  "LINUX", NT_PRXFPREG, sizeof(*xfpu), xfpu);
+			  "LINUX", ELF_CORE_XFPREG_TYPE, sizeof(*xfpu), xfpu);
 #endif
 
 	fs = get_fs();
include/asm-i386/elf.h +1 -0
Index: linux/include/asm-i386/elf.h
===================================================================
@@ -129,6 +129,7 @@ extern int dump_task_extended_fpu (struc
 #define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, elf_regs)
 #define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, elf_fpregs)
 #define ELF_CORE_COPY_XFPREGS(tsk, elf_xfpregs) dump_task_extended_fpu(tsk, elf_xfpregs)
+#define ELF_CORE_XFPREG_TYPE NT_PRXFPREG
 
 #define VDSO_HIGH_BASE		(__fix_to_virt(FIX_VDSO))
 #define VDSO_CURRENT_BASE	((unsigned long)current->mm->context.vdso)