Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com> Tested-by: Peter Schneider <pschneider1968@googlemail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Salvatore Bonaccorso <carnil@debian.org> Tested-by: Brett A C Sheffield <bacs@librecast.net> Tested-by: Mark Brown <broonie@kernel.org> Tested-by: Luna Jernberg <droidbittin@gmail.com> Tested-by: Ronald Warsow <rwarsow@gmx.de> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Tested-by: Ron Economos <re@w6rz.net> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
59 lines
1.3 KiB
C
59 lines
1.3 KiB
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)
|
|
{
|
|
#ifdef CONFIG_PPC_FPU_REGS
|
|
unsigned int fpidx = index - PT_FPR0;
|
|
#endif
|
|
|
|
if (index > PT_FPSCR)
|
|
return -EIO;
|
|
|
|
#ifdef CONFIG_PPC_FPU_REGS
|
|
flush_fp_to_thread(child);
|
|
if (fpidx < (PT_FPSCR - PT_FPR0)) {
|
|
if (IS_ENABLED(CONFIG_PPC32))
|
|
// On 32-bit the index we are passed refers to 32-bit words
|
|
*data = ((u32 *)child->thread.fp_state.fpr)[fpidx];
|
|
else
|
|
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
|
|
} else
|
|
*data = child->thread.fp_state.fpscr;
|
|
#else
|
|
*data = 0;
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|
|
int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
|
|
{
|
|
#ifdef CONFIG_PPC_FPU_REGS
|
|
unsigned int fpidx = index - PT_FPR0;
|
|
#endif
|
|
|
|
if (index > PT_FPSCR)
|
|
return -EIO;
|
|
|
|
#ifdef CONFIG_PPC_FPU_REGS
|
|
flush_fp_to_thread(child);
|
|
if (fpidx < (PT_FPSCR - PT_FPR0)) {
|
|
if (IS_ENABLED(CONFIG_PPC32))
|
|
// On 32-bit the index we are passed refers to 32-bit words
|
|
((u32 *)child->thread.fp_state.fpr)[fpidx] = data;
|
|
else
|
|
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
|
|
} else
|
|
child->thread.fp_state.fpscr = data;
|
|
#endif
|
|
|
|
return 0;
|
|
}
|
|
|