Skip to content

Commit

Permalink
[elf][non-regset] uninline elf_core_copy_task_fpregs() (and lose pt_r…
Browse files Browse the repository at this point in the history
…egs argument)

Don't bother with pointless macros - we are not sharing it with aout coredumps
anymore.  Just convert the underlying functions to the same arguments (nobody
uses regs, actually) and call them elf_core_copy_task_fpregs().  And unexport
the entire bunch, while we are at it.

[added missing includes in arch/{csky,m68k,um}/kernel/process.c to avoid extra
warnings about the lack of externs getting added to huge piles for those
files.  Pointless, but...]

Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Al Viro committed Nov 25, 2022
1 parent fcf1492 commit bdbadfc
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 34 deletions.
6 changes: 0 additions & 6 deletions arch/alpha/include/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,6 @@ extern int dump_elf_task(elf_greg_t *dest, struct task_struct *task);
#define ELF_CORE_COPY_TASK_REGS(TASK, DEST) \
dump_elf_task(*(DEST), TASK)

/* Similar, but for the FP registers. */

extern int dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task);
#define ELF_CORE_COPY_FPREGS(TASK, DEST) \
dump_elf_task_fp(*(DEST), TASK)

/* This yields a mask that user programs can use to figure out what
instruction set this CPU supports. This is trivial on Alpha,
but not so on other machines. */
Expand Down
8 changes: 3 additions & 5 deletions arch/alpha/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,12 @@ dump_elf_task(elf_greg_t *dest, struct task_struct *task)
}
EXPORT_SYMBOL(dump_elf_task);

int
dump_elf_task_fp(elf_fpreg_t *dest, struct task_struct *task)
int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu)
{
struct switch_stack *sw = (struct switch_stack *)task_pt_regs(task) - 1;
memcpy(dest, sw->fp, 32 * 8);
struct switch_stack *sw = (struct switch_stack *)task_pt_regs(t) - 1;
memcpy(fpu, sw->fp, 32 * 8);
return 1;
}
EXPORT_SYMBOL(dump_elf_task_fp);

/*
* Return saved PC of a blocked thread. This assumes the frame
Expand Down
4 changes: 2 additions & 2 deletions arch/csky/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/kallsyms.h>
#include <linux/uaccess.h>
#include <linux/ptrace.h>
#include <linux/elfcore.h>

#include <asm/elf.h>
#include <abi/reg_ops.h>
Expand Down Expand Up @@ -69,12 +70,11 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
}

/* Fill in the fpu structure for a core dump. */
int dump_fpu(struct pt_regs *regs, struct user_fp *fpu)
int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu)
{
memcpy(fpu, &current->thread.user_fp, sizeof(*fpu));
return 1;
}
EXPORT_SYMBOL(dump_fpu);

int dump_task_regs(struct task_struct *tsk, elf_gregset_t *pr_regs)
{
Expand Down
4 changes: 2 additions & 2 deletions arch/m68k/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <linux/rcupdate.h>
#include <linux/syscalls.h>
#include <linux/uaccess.h>
#include <linux/elfcore.h>

#include <asm/traps.h>
#include <asm/machdep.h>
Expand Down Expand Up @@ -213,7 +214,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
}

/* Fill in the fpu structure for a core dump. */
int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)
int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu)
{
if (FPU_IS_EMU) {
int i;
Expand Down Expand Up @@ -262,7 +263,6 @@ int dump_fpu (struct pt_regs *regs, struct user_m68kfp_struct *fpu)

return 1;
}
EXPORT_SYMBOL(dump_fpu);

unsigned long __get_wchan(struct task_struct *p)
{
Expand Down
2 changes: 1 addition & 1 deletion arch/microblaze/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp)
/*
* Set up a thread for executing a new program
*/
int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs)
int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu)
{
return 0; /* MicroBlaze has no separate FPU registers */
}
Expand Down
3 changes: 2 additions & 1 deletion arch/um/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <skas.h>
#include <registers.h>
#include <linux/time-internal.h>
#include <linux/elfcore.h>

/*
* This is a per-cpu array. A processor only modifies its entry and it only
Expand Down Expand Up @@ -393,7 +394,7 @@ unsigned long __get_wchan(struct task_struct *p)
return 0;
}

int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu)
int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu)
{
int cpu = current_thread_info()->cpu;

Expand Down
4 changes: 0 additions & 4 deletions arch/x86/um/asm/elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ typedef struct user_i387_struct elf_fpregset_t;

struct task_struct;

extern int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu);

#define ELF_CORE_COPY_FPREGS(t, fpu) elf_core_copy_fpregs(t, fpu)

#define ELF_EXEC_PAGESIZE 4096

#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
Expand Down
5 changes: 2 additions & 3 deletions fs/binfmt_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -2001,8 +2001,7 @@ static int elf_dump_thread_status(long signr, struct elf_thread_status *t)
t->num_notes++;
sz += notesize(&t->notes[0]);

if ((t->prstatus.pr_fpvalid = elf_core_copy_task_fpregs(p, NULL,
&t->fpu))) {
if ((t->prstatus.pr_fpvalid = elf_core_copy_task_fpregs(p, &t->fpu))) {
fill_note(&t->notes[1], "CORE", NT_PRFPREG, sizeof(t->fpu),
&(t->fpu));
t->num_notes++;
Expand Down Expand Up @@ -2100,7 +2099,7 @@ static int fill_note_info(struct elfhdr *elf, int phdrs,

/* Try to dump the FPU. */
info->prstatus->pr_fpvalid =
elf_core_copy_task_fpregs(current, task_pt_regs(current), info->fpu);
elf_core_copy_task_fpregs(current, info->fpu);
if (info->prstatus->pr_fpvalid)
fill_note(info->notes + info->numnote++,
"CORE", NT_PRFPREG, sizeof(*info->fpu), info->fpu);
Expand Down
11 changes: 1 addition & 10 deletions include/linux/elfcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,7 @@ static inline int elf_core_copy_task_regs(struct task_struct *t, elf_gregset_t*
return 0;
}

extern int dump_fpu (struct pt_regs *, elf_fpregset_t *);

static inline int elf_core_copy_task_fpregs(struct task_struct *t, struct pt_regs *regs, elf_fpregset_t *fpu)
{
#ifdef ELF_CORE_COPY_FPREGS
return ELF_CORE_COPY_FPREGS(t, fpu);
#else
return dump_fpu(regs, fpu);
#endif
}
int elf_core_copy_task_fpregs(struct task_struct *t, elf_fpregset_t *fpu);

#ifdef CONFIG_ARCH_BINFMT_ELF_EXTRA_PHDRS
/*
Expand Down

0 comments on commit bdbadfc

Please sign in to comment.