On the same model as ptrace_get_reg() and ptrace_put_reg(), create ptrace_get_fpr() and ptrace_put_fpr() to get/set the floating points registers. We move the boundary checkings in them. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/24a1baedea7f7ae7b6bf27be98bab6d01b5ca2c1.1597770847.git.christophe.leroy@csgroup.eu
41 lines
812 B
C
41 lines
812 B
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <linux/regset.h>
|
|
|
|
#include <asm/switch_to.h>
|
|
|
|
#include "ptrace-decl.h"
|
|
|
|
int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data)
|
|
{
|
|
unsigned int fpidx = index - PT_FPR0;
|
|
|
|
if (index > PT_FPSCR)
|
|
return -EIO;
|
|
|
|
flush_fp_to_thread(child);
|
|
if (fpidx < (PT_FPSCR - PT_FPR0))
|
|
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
|
|
else
|
|
*data = child->thread.fp_state.fpscr;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
|
|
{
|
|
unsigned int fpidx = index - PT_FPR0;
|
|
|
|
if (index > PT_FPSCR)
|
|
return -EIO;
|
|
|
|
flush_fp_to_thread(child);
|
|
if (fpidx < (PT_FPSCR - PT_FPR0))
|
|
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
|
|
else
|
|
child->thread.fp_state.fpscr = data;
|
|
|
|
return 0;
|
|
}
|
|
|