Commit e5501492 authored by Michael Ellerman's avatar Michael Ellerman Committed by Paul Mackerras

[POWERPC] spufs: Cleanup ELF coredump extra notes logic

To start with, arch_notes_size() etc. is a little too ambiguous a name for
my liking, so change the function names to be more explicit.

Calling through macros is ugly, especially with hidden parameters, so don't
do that, call the routines directly.

Use ARCH_HAVE_EXTRA_ELF_NOTES as the only flag, and based on it decide
whether we want the extern declarations or the empty versions.

Since we have empty routines, actually use them in the coredump code to
save a few #ifdefs.

We want to change the handling of foffset so that the write routine updates
foffset as it goes, instead of using file->f_pos (so that writing to a pipe
works).  So pass foffset to the write routine, and for now just set it to
file->f_pos at the end of writing.

It should also be possible for the write routine to fail, so change it to
return int and treat a non-zero return as failure.
Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarJeremy Kerr <jk@ozlabs.org>
Signed-off-by: default avatarPaul Mackerras <paulus@samba.org>
parent 48cad41f
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
#include <linux/file.h> #include <linux/file.h>
#include <linux/fs.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/syscalls.h> #include <linux/syscalls.h>
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
...@@ -112,7 +113,7 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus) ...@@ -112,7 +113,7 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus)
return ret; return ret;
} }
int arch_notes_size(void) int elf_coredump_extra_notes_size(void)
{ {
struct spufs_calls *calls; struct spufs_calls *calls;
int ret; int ret;
...@@ -128,17 +129,22 @@ int arch_notes_size(void) ...@@ -128,17 +129,22 @@ int arch_notes_size(void)
return ret; return ret;
} }
void arch_write_notes(struct file *file) int elf_coredump_extra_notes_write(struct file *file, loff_t *foffset)
{ {
struct spufs_calls *calls; struct spufs_calls *calls;
calls = spufs_calls_get(); calls = spufs_calls_get();
if (!calls) if (!calls)
return; return 0;
calls->coredump_extra_notes_write(file); calls->coredump_extra_notes_write(file);
spufs_calls_put(calls); spufs_calls_put(calls);
/* Fudge foffset for now */
*foffset = file->f_pos;
return 0;
} }
int register_spu_syscalls(struct spufs_calls *calls) int register_spu_syscalls(struct spufs_calls *calls)
......
...@@ -1514,9 +1514,6 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) ...@@ -1514,9 +1514,6 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
int thread_status_size = 0; int thread_status_size = 0;
elf_addr_t *auxv; elf_addr_t *auxv;
unsigned long mm_flags; unsigned long mm_flags;
#ifdef ELF_CORE_WRITE_EXTRA_NOTES
int extra_notes_size;
#endif
/* /*
* We no longer stop all VM operations. * We no longer stop all VM operations.
...@@ -1645,10 +1642,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) ...@@ -1645,10 +1642,7 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
sz += thread_status_size; sz += thread_status_size;
#ifdef ELF_CORE_WRITE_EXTRA_NOTES sz += elf_coredump_extra_notes_size();
extra_notes_size = ELF_CORE_EXTRA_NOTES_SIZE;
sz += extra_notes_size;
#endif
fill_elf_note_phdr(&phdr, sz, offset); fill_elf_note_phdr(&phdr, sz, offset);
offset += sz; offset += sz;
...@@ -1698,10 +1692,8 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file) ...@@ -1698,10 +1692,8 @@ static int elf_core_dump(long signr, struct pt_regs *regs, struct file *file)
if (!writenote(notes + i, file, &foffset)) if (!writenote(notes + i, file, &foffset))
goto end_coredump; goto end_coredump;
#ifdef ELF_CORE_WRITE_EXTRA_NOTES if (elf_coredump_extra_notes_write(file, &foffset))
ELF_CORE_WRITE_EXTRA_NOTES; goto end_coredump;
foffset += extra_notes_size;
#endif
/* write out the thread status notes section */ /* write out the thread status notes section */
list_for_each(t, &thread_list) { list_for_each(t, &thread_list) {
......
...@@ -413,13 +413,8 @@ do { \ ...@@ -413,13 +413,8 @@ do { \
/* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */ /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
#define NT_SPU 1 #define NT_SPU 1
extern int arch_notes_size(void);
extern void arch_write_notes(struct file *file);
#define ELF_CORE_EXTRA_NOTES_SIZE arch_notes_size()
#define ELF_CORE_WRITE_EXTRA_NOTES arch_write_notes(file)
#define ARCH_HAVE_EXTRA_ELF_NOTES #define ARCH_HAVE_EXTRA_ELF_NOTES
#endif /* CONFIG_PPC_CELL */
#endif /* CONFIG_SPU_BASE */
#endif /* _ASM_POWERPC_ELF_H */ #endif /* _ASM_POWERPC_ELF_H */
...@@ -389,12 +389,14 @@ extern Elf64_Dyn _DYNAMIC []; ...@@ -389,12 +389,14 @@ extern Elf64_Dyn _DYNAMIC [];
#endif #endif
/* Optional callbacks to write extra ELF notes. */
#ifndef ARCH_HAVE_EXTRA_ELF_NOTES #ifndef ARCH_HAVE_EXTRA_ELF_NOTES
static inline int arch_notes_size(void) { return 0; } static inline int elf_coredump_extra_notes_size(void) { return 0; }
static inline void arch_write_notes(struct file *file) { } static inline int elf_coredump_extra_notes_write(struct file *file,
loff_t *foffset) { return 0; }
#define ELF_CORE_EXTRA_NOTES_SIZE arch_notes_size() #else
#define ELF_CORE_WRITE_EXTRA_NOTES arch_write_notes(file) extern int elf_coredump_extra_notes_size(void);
#endif /* ARCH_HAVE_EXTRA_ELF_NOTES */ extern int elf_coredump_extra_notes_write(struct file *file, loff_t *foffset);
#endif
#endif /* _LINUX_ELF_H */ #endif /* _LINUX_ELF_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment