Skip to content

Commit 3dd4eb8

Browse files
hramrachmpe
authored andcommitted
powerpc: move common register copy functions from signal_32.c to signal.c
These functions are required for 64bit as well. Signed-off-by: Michal Suchanek <[email protected]> Reviewed-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/9fd6d9b7c5e91fab21159fe23534a2f16b4962d3.1584699455.git.msuchanek@suse.de
1 parent 9e62cce commit 3dd4eb8

File tree

2 files changed

+141
-140
lines changed

2 files changed

+141
-140
lines changed

arch/powerpc/kernel/signal.c

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,153 @@
1818
#include <linux/syscalls.h>
1919
#include <asm/hw_breakpoint.h>
2020
#include <linux/uaccess.h>
21+
#include <asm/switch_to.h>
2122
#include <asm/unistd.h>
2223
#include <asm/debug.h>
2324
#include <asm/tm.h>
2425

2526
#include "signal.h"
2627

28+
#ifdef CONFIG_VSX
29+
unsigned long copy_fpr_to_user(void __user *to,
30+
struct task_struct *task)
31+
{
32+
u64 buf[ELF_NFPREG];
33+
int i;
34+
35+
/* save FPR copy to local buffer then write to the thread_struct */
36+
for (i = 0; i < (ELF_NFPREG - 1) ; i++)
37+
buf[i] = task->thread.TS_FPR(i);
38+
buf[i] = task->thread.fp_state.fpscr;
39+
return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double));
40+
}
41+
42+
unsigned long copy_fpr_from_user(struct task_struct *task,
43+
void __user *from)
44+
{
45+
u64 buf[ELF_NFPREG];
46+
int i;
47+
48+
if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double)))
49+
return 1;
50+
for (i = 0; i < (ELF_NFPREG - 1) ; i++)
51+
task->thread.TS_FPR(i) = buf[i];
52+
task->thread.fp_state.fpscr = buf[i];
53+
54+
return 0;
55+
}
56+
57+
unsigned long copy_vsx_to_user(void __user *to,
58+
struct task_struct *task)
59+
{
60+
u64 buf[ELF_NVSRHALFREG];
61+
int i;
62+
63+
/* save FPR copy to local buffer then write to the thread_struct */
64+
for (i = 0; i < ELF_NVSRHALFREG; i++)
65+
buf[i] = task->thread.fp_state.fpr[i][TS_VSRLOWOFFSET];
66+
return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double));
67+
}
68+
69+
unsigned long copy_vsx_from_user(struct task_struct *task,
70+
void __user *from)
71+
{
72+
u64 buf[ELF_NVSRHALFREG];
73+
int i;
74+
75+
if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double)))
76+
return 1;
77+
for (i = 0; i < ELF_NVSRHALFREG ; i++)
78+
task->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i];
79+
return 0;
80+
}
81+
82+
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
83+
unsigned long copy_ckfpr_to_user(void __user *to,
84+
struct task_struct *task)
85+
{
86+
u64 buf[ELF_NFPREG];
87+
int i;
88+
89+
/* save FPR copy to local buffer then write to the thread_struct */
90+
for (i = 0; i < (ELF_NFPREG - 1) ; i++)
91+
buf[i] = task->thread.TS_CKFPR(i);
92+
buf[i] = task->thread.ckfp_state.fpscr;
93+
return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double));
94+
}
95+
96+
unsigned long copy_ckfpr_from_user(struct task_struct *task,
97+
void __user *from)
98+
{
99+
u64 buf[ELF_NFPREG];
100+
int i;
101+
102+
if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double)))
103+
return 1;
104+
for (i = 0; i < (ELF_NFPREG - 1) ; i++)
105+
task->thread.TS_CKFPR(i) = buf[i];
106+
task->thread.ckfp_state.fpscr = buf[i];
107+
108+
return 0;
109+
}
110+
111+
unsigned long copy_ckvsx_to_user(void __user *to,
112+
struct task_struct *task)
113+
{
114+
u64 buf[ELF_NVSRHALFREG];
115+
int i;
116+
117+
/* save FPR copy to local buffer then write to the thread_struct */
118+
for (i = 0; i < ELF_NVSRHALFREG; i++)
119+
buf[i] = task->thread.ckfp_state.fpr[i][TS_VSRLOWOFFSET];
120+
return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double));
121+
}
122+
123+
unsigned long copy_ckvsx_from_user(struct task_struct *task,
124+
void __user *from)
125+
{
126+
u64 buf[ELF_NVSRHALFREG];
127+
int i;
128+
129+
if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double)))
130+
return 1;
131+
for (i = 0; i < ELF_NVSRHALFREG ; i++)
132+
task->thread.ckfp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i];
133+
return 0;
134+
}
135+
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
136+
#else
137+
inline unsigned long copy_fpr_to_user(void __user *to,
138+
struct task_struct *task)
139+
{
140+
return __copy_to_user(to, task->thread.fp_state.fpr,
141+
ELF_NFPREG * sizeof(double));
142+
}
143+
144+
inline unsigned long copy_fpr_from_user(struct task_struct *task,
145+
void __user *from)
146+
{
147+
return __copy_from_user(task->thread.fp_state.fpr, from,
148+
ELF_NFPREG * sizeof(double));
149+
}
150+
151+
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
152+
inline unsigned long copy_ckfpr_to_user(void __user *to,
153+
struct task_struct *task)
154+
{
155+
return __copy_to_user(to, task->thread.ckfp_state.fpr,
156+
ELF_NFPREG * sizeof(double));
157+
}
158+
159+
inline unsigned long copy_ckfpr_from_user(struct task_struct *task,
160+
void __user *from)
161+
{
162+
return __copy_from_user(task->thread.ckfp_state.fpr, from,
163+
ELF_NFPREG * sizeof(double));
164+
}
165+
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
166+
#endif
167+
27168
/* Log an error when sending an unhandled signal to a process. Controlled
28169
* through debug.exception-trace sysctl.
29170
*/

arch/powerpc/kernel/signal_32.c

Lines changed: 0 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -235,146 +235,6 @@ struct rt_sigframe {
235235
int abigap[56];
236236
};
237237

238-
#ifdef CONFIG_VSX
239-
unsigned long copy_fpr_to_user(void __user *to,
240-
struct task_struct *task)
241-
{
242-
u64 buf[ELF_NFPREG];
243-
int i;
244-
245-
/* save FPR copy to local buffer then write to the thread_struct */
246-
for (i = 0; i < (ELF_NFPREG - 1) ; i++)
247-
buf[i] = task->thread.TS_FPR(i);
248-
buf[i] = task->thread.fp_state.fpscr;
249-
return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double));
250-
}
251-
252-
unsigned long copy_fpr_from_user(struct task_struct *task,
253-
void __user *from)
254-
{
255-
u64 buf[ELF_NFPREG];
256-
int i;
257-
258-
if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double)))
259-
return 1;
260-
for (i = 0; i < (ELF_NFPREG - 1) ; i++)
261-
task->thread.TS_FPR(i) = buf[i];
262-
task->thread.fp_state.fpscr = buf[i];
263-
264-
return 0;
265-
}
266-
267-
unsigned long copy_vsx_to_user(void __user *to,
268-
struct task_struct *task)
269-
{
270-
u64 buf[ELF_NVSRHALFREG];
271-
int i;
272-
273-
/* save FPR copy to local buffer then write to the thread_struct */
274-
for (i = 0; i < ELF_NVSRHALFREG; i++)
275-
buf[i] = task->thread.fp_state.fpr[i][TS_VSRLOWOFFSET];
276-
return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double));
277-
}
278-
279-
unsigned long copy_vsx_from_user(struct task_struct *task,
280-
void __user *from)
281-
{
282-
u64 buf[ELF_NVSRHALFREG];
283-
int i;
284-
285-
if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double)))
286-
return 1;
287-
for (i = 0; i < ELF_NVSRHALFREG ; i++)
288-
task->thread.fp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i];
289-
return 0;
290-
}
291-
292-
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
293-
unsigned long copy_ckfpr_to_user(void __user *to,
294-
struct task_struct *task)
295-
{
296-
u64 buf[ELF_NFPREG];
297-
int i;
298-
299-
/* save FPR copy to local buffer then write to the thread_struct */
300-
for (i = 0; i < (ELF_NFPREG - 1) ; i++)
301-
buf[i] = task->thread.TS_CKFPR(i);
302-
buf[i] = task->thread.ckfp_state.fpscr;
303-
return __copy_to_user(to, buf, ELF_NFPREG * sizeof(double));
304-
}
305-
306-
unsigned long copy_ckfpr_from_user(struct task_struct *task,
307-
void __user *from)
308-
{
309-
u64 buf[ELF_NFPREG];
310-
int i;
311-
312-
if (__copy_from_user(buf, from, ELF_NFPREG * sizeof(double)))
313-
return 1;
314-
for (i = 0; i < (ELF_NFPREG - 1) ; i++)
315-
task->thread.TS_CKFPR(i) = buf[i];
316-
task->thread.ckfp_state.fpscr = buf[i];
317-
318-
return 0;
319-
}
320-
321-
unsigned long copy_ckvsx_to_user(void __user *to,
322-
struct task_struct *task)
323-
{
324-
u64 buf[ELF_NVSRHALFREG];
325-
int i;
326-
327-
/* save FPR copy to local buffer then write to the thread_struct */
328-
for (i = 0; i < ELF_NVSRHALFREG; i++)
329-
buf[i] = task->thread.ckfp_state.fpr[i][TS_VSRLOWOFFSET];
330-
return __copy_to_user(to, buf, ELF_NVSRHALFREG * sizeof(double));
331-
}
332-
333-
unsigned long copy_ckvsx_from_user(struct task_struct *task,
334-
void __user *from)
335-
{
336-
u64 buf[ELF_NVSRHALFREG];
337-
int i;
338-
339-
if (__copy_from_user(buf, from, ELF_NVSRHALFREG * sizeof(double)))
340-
return 1;
341-
for (i = 0; i < ELF_NVSRHALFREG ; i++)
342-
task->thread.ckfp_state.fpr[i][TS_VSRLOWOFFSET] = buf[i];
343-
return 0;
344-
}
345-
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
346-
#else
347-
inline unsigned long copy_fpr_to_user(void __user *to,
348-
struct task_struct *task)
349-
{
350-
return __copy_to_user(to, task->thread.fp_state.fpr,
351-
ELF_NFPREG * sizeof(double));
352-
}
353-
354-
inline unsigned long copy_fpr_from_user(struct task_struct *task,
355-
void __user *from)
356-
{
357-
return __copy_from_user(task->thread.fp_state.fpr, from,
358-
ELF_NFPREG * sizeof(double));
359-
}
360-
361-
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
362-
inline unsigned long copy_ckfpr_to_user(void __user *to,
363-
struct task_struct *task)
364-
{
365-
return __copy_to_user(to, task->thread.ckfp_state.fpr,
366-
ELF_NFPREG * sizeof(double));
367-
}
368-
369-
inline unsigned long copy_ckfpr_from_user(struct task_struct *task,
370-
void __user *from)
371-
{
372-
return __copy_from_user(task->thread.ckfp_state.fpr, from,
373-
ELF_NFPREG * sizeof(double));
374-
}
375-
#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
376-
#endif
377-
378238
/*
379239
* Save the current user registers on the user stack.
380240
* We only save the altivec/spe registers if the process has used

0 commit comments

Comments
 (0)