xref: /linux/arch/powerpc/kernel/ptrace/ptrace-novsx.c (revision a1c3be890440a1769ed6f822376a3e3ab0d42994)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 #include <linux/regset.h>
4 
5 #include <asm/switch_to.h>
6 
7 #include "ptrace-decl.h"
8 
9 /*
10  * Regardless of transactions, 'fp_state' holds the current running
11  * value of all FPR registers and 'ckfp_state' holds the last checkpointed
12  * value of all FPR registers for the current transaction.
13  *
14  * Userspace interface buffer layout:
15  *
16  * struct data {
17  *	u64	fpr[32];
18  *	u64	fpscr;
19  * };
20  */
21 int fpr_get(struct task_struct *target, const struct user_regset *regset,
22 	    struct membuf to)
23 {
24 	BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
25 		     offsetof(struct thread_fp_state, fpr[32]));
26 
27 	flush_fp_to_thread(target);
28 
29 	return membuf_write(&to, &target->thread.fp_state, 33 * sizeof(u64));
30 }
31 
32 /*
33  * Regardless of transactions, 'fp_state' holds the current running
34  * value of all FPR registers and 'ckfp_state' holds the last checkpointed
35  * value of all FPR registers for the current transaction.
36  *
37  * Userspace interface buffer layout:
38  *
39  * struct data {
40  *	u64	fpr[32];
41  *	u64	fpscr;
42  * };
43  *
44  */
45 int fpr_set(struct task_struct *target, const struct user_regset *regset,
46 	    unsigned int pos, unsigned int count,
47 	    const void *kbuf, const void __user *ubuf)
48 {
49 	BUILD_BUG_ON(offsetof(struct thread_fp_state, fpscr) !=
50 		     offsetof(struct thread_fp_state, fpr[32]));
51 
52 	flush_fp_to_thread(target);
53 
54 	return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
55 				  &target->thread.fp_state, 0, -1);
56 }
57