1
2
3#include <linux/regset.h>
4#include <linux/elf.h>
5
6#include <asm/switch_to.h>
7
8#include "ptrace-decl.h"
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23int vr_active(struct task_struct *target, const struct user_regset *regset)
24{
25 flush_altivec_to_thread(target);
26 return target->thread.used_vr ? regset->n : 0;
27}
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43int vr_get(struct task_struct *target, const struct user_regset *regset,
44 struct membuf to)
45{
46 union {
47 elf_vrreg_t reg;
48 u32 word;
49 } vrsave;
50
51 flush_altivec_to_thread(target);
52
53 BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
54 offsetof(struct thread_vr_state, vr[32]));
55
56 membuf_write(&to, &target->thread.vr_state, 33 * sizeof(vector128));
57
58
59
60 memset(&vrsave, 0, sizeof(vrsave));
61 vrsave.word = target->thread.vrsave;
62 return membuf_write(&to, &vrsave, sizeof(vrsave));
63}
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79int 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)
82{
83 int ret;
84
85 flush_altivec_to_thread(target);
86
87 BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
88 offsetof(struct thread_vr_state, vr[32]));
89
90 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
91 &target->thread.vr_state, 0,
92 33 * sizeof(vector128));
93 if (!ret && count > 0) {
94
95
96
97 int start, end;
98 union {
99 elf_vrreg_t reg;
100 u32 word;
101 } vrsave;
102 memset(&vrsave, 0, sizeof(vrsave));
103
104 vrsave.word = target->thread.vrsave;
105
106 start = 33 * sizeof(vector128);
107 end = start + sizeof(vrsave);
108 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &vrsave,
109 start, end);
110 if (!ret)
111 target->thread.vrsave = vrsave.word;
112 }
113
114 return ret;
115}
116