1 // SPDX-License-Identifier: GPL-2.0-or-later
3 #include <linux/regset.h>
6 #include <asm/switch_to.h>
8 #include "ptrace-decl.h"
11 * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
12 * The transfer totals 34 quadword. Quadwords 0-31 contain the
13 * corresponding vector registers. Quadword 32 contains the vscr as the
14 * last word (offset 12) within that quadword. Quadword 33 contains the
15 * vrsave as the first word (offset 0) within the quadword.
17 * This definition of the VMX state is compatible with the current PPC32
18 * ptrace interface. This allows signal handling and ptrace to use the
19 * same structures. This also simplifies the implementation of a bi-arch
20 * (combined (32- and 64-bit) gdb.
23 int vr_active(struct task_struct
*target
, const struct user_regset
*regset
)
25 flush_altivec_to_thread(target
);
26 return target
->thread
.used_vr
? regset
->n
: 0;
30 * Regardless of transactions, 'vr_state' holds the current running
31 * value of all the VMX registers and 'ckvr_state' holds the last
32 * checkpointed value of all the VMX registers for the current
33 * transaction to fall back on in case it aborts.
35 * Userspace interface buffer layout:
43 int vr_get(struct task_struct
*target
, const struct user_regset
*regset
,
51 flush_altivec_to_thread(target
);
53 BUILD_BUG_ON(offsetof(struct thread_vr_state
, vscr
) !=
54 offsetof(struct thread_vr_state
, vr
[32]));
56 membuf_write(&to
, &target
->thread
.vr_state
, 33 * sizeof(vector128
));
58 * Copy out only the low-order word of vrsave.
60 memset(&vrsave
, 0, sizeof(vrsave
));
61 vrsave
.word
= target
->thread
.vrsave
;
62 return membuf_write(&to
, &vrsave
, sizeof(vrsave
));
66 * Regardless of transactions, 'vr_state' holds the current running
67 * value of all the VMX registers and 'ckvr_state' holds the last
68 * checkpointed value of all the VMX registers for the current
69 * transaction to fall back on in case it aborts.
71 * Userspace interface buffer layout:
79 int vr_set(struct task_struct
*target
, const struct user_regset
*regset
,
80 unsigned int pos
, unsigned int count
,
81 const void *kbuf
, const void __user
*ubuf
)
85 flush_altivec_to_thread(target
);
87 BUILD_BUG_ON(offsetof(struct thread_vr_state
, vscr
) !=
88 offsetof(struct thread_vr_state
, vr
[32]));
90 ret
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
,
91 &target
->thread
.vr_state
, 0,
92 33 * sizeof(vector128
));
93 if (!ret
&& count
> 0) {
95 * We use only the first word of vrsave.
102 memset(&vrsave
, 0, sizeof(vrsave
));
104 vrsave
.word
= target
->thread
.vrsave
;
106 start
= 33 * sizeof(vector128
);
107 end
= start
+ sizeof(vrsave
);
108 ret
= user_regset_copyin(&pos
, &count
, &kbuf
, &ubuf
, &vrsave
,
111 target
->thread
.vrsave
= vrsave
.word
;