Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 
0003 #include <linux/regset.h>
0004 
0005 #include <asm/switch_to.h>
0006 
0007 #include "ptrace-decl.h"
0008 
0009 /*
0010  * Regardless of transactions, 'fp_state' holds the current running
0011  * value of all FPR registers and 'ckfp_state' holds the last checkpointed
0012  * value of all FPR registers for the current transaction.
0013  *
0014  * Userspace interface buffer layout:
0015  *
0016  * struct data {
0017  *  u64 fpr[32];
0018  *  u64 fpscr;
0019  * };
0020  */
0021 int fpr_get(struct task_struct *target, const struct user_regset *regset,
0022         struct membuf to)
0023 {
0024 #ifdef CONFIG_PPC_FPU_REGS
0025     BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
0026              offsetof(struct thread_fp_state, fpr[32]));
0027 
0028     flush_fp_to_thread(target);
0029 
0030     return membuf_write(&to, &target->thread.fp_state, 33 * sizeof(u64));
0031 #else
0032     return membuf_write(&to, &empty_zero_page, 33 * sizeof(u64));
0033 #endif
0034 }
0035 
0036 /*
0037  * Regardless of transactions, 'fp_state' holds the current running
0038  * value of all FPR registers and 'ckfp_state' holds the last checkpointed
0039  * value of all FPR registers for the current transaction.
0040  *
0041  * Userspace interface buffer layout:
0042  *
0043  * struct data {
0044  *  u64 fpr[32];
0045  *  u64 fpscr;
0046  * };
0047  *
0048  */
0049 int fpr_set(struct task_struct *target, const struct user_regset *regset,
0050         unsigned int pos, unsigned int count,
0051         const void *kbuf, const void __user *ubuf)
0052 {
0053 #ifdef CONFIG_PPC_FPU_REGS
0054     BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
0055              offsetof(struct thread_fp_state, fpr[32]));
0056 
0057     flush_fp_to_thread(target);
0058 
0059     return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
0060                   &target->thread.fp_state, 0, -1);
0061 #else
0062     return 0;
0063 #endif
0064 }