Skip to content

Commit 60ef9db

Browse files
chleroympe
authored andcommitted
powerpc/ptrace: split out SPE related functions.
Move CONFIG_SPE functions out of ptrace.c, into ptrace-spe.c Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/0f17a331760310b5562fae3791cdd3cf9c64237b.1582848567.git.christophe.leroy@c-s.fr
1 parent 1b20773 commit 60ef9db

File tree

4 files changed

+78
-66
lines changed

4 files changed

+78
-66
lines changed

arch/powerpc/kernel/ptrace/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ ifneq ($(CONFIG_VSX),y)
1212
obj-y += ptrace-novsx.o
1313
endif
1414
obj-$(CONFIG_ALTIVEC) += ptrace-altivec.o
15+
obj-$(CONFIG_SPE) += ptrace-spe.o

arch/powerpc/kernel/ptrace/ptrace-decl.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ int vr_set(struct task_struct *target, const struct user_regset *regset,
2626
unsigned int pos, unsigned int count,
2727
const void *kbuf, const void __user *ubuf);
2828

29+
/* ptrace-spe */
30+
31+
int evr_active(struct task_struct *target, const struct user_regset *regset);
32+
int evr_get(struct task_struct *target, const struct user_regset *regset,
33+
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
34+
int evr_set(struct task_struct *target, const struct user_regset *regset,
35+
unsigned int pos, unsigned int count,
36+
const void *kbuf, const void __user *ubuf);
37+
2938
/* ptrace */
3039

3140
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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+
* For get_evrregs/set_evrregs functions 'data' has the following layout:
11+
*
12+
* struct {
13+
* u32 evr[32];
14+
* u64 acc;
15+
* u32 spefscr;
16+
* }
17+
*/
18+
19+
int evr_active(struct task_struct *target, const struct user_regset *regset)
20+
{
21+
flush_spe_to_thread(target);
22+
return target->thread.used_spe ? regset->n : 0;
23+
}
24+
25+
int evr_get(struct task_struct *target, const struct user_regset *regset,
26+
unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
27+
{
28+
int ret;
29+
30+
flush_spe_to_thread(target);
31+
32+
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
33+
&target->thread.evr,
34+
0, sizeof(target->thread.evr));
35+
36+
BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
37+
offsetof(struct thread_struct, spefscr));
38+
39+
if (!ret)
40+
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
41+
&target->thread.acc,
42+
sizeof(target->thread.evr), -1);
43+
44+
return ret;
45+
}
46+
47+
int evr_set(struct task_struct *target, const struct user_regset *regset,
48+
unsigned int pos, unsigned int count,
49+
const void *kbuf, const void __user *ubuf)
50+
{
51+
int ret;
52+
53+
flush_spe_to_thread(target);
54+
55+
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
56+
&target->thread.evr,
57+
0, sizeof(target->thread.evr));
58+
59+
BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
60+
offsetof(struct thread_struct, spefscr));
61+
62+
if (!ret)
63+
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
64+
&target->thread.acc,
65+
sizeof(target->thread.evr), -1);
66+
67+
return ret;
68+
}

arch/powerpc/kernel/ptrace/ptrace.c

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -403,72 +403,6 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,
403403
return ret;
404404
}
405405

406-
#ifdef CONFIG_SPE
407-
408-
/*
409-
* For get_evrregs/set_evrregs functions 'data' has the following layout:
410-
*
411-
* struct {
412-
* u32 evr[32];
413-
* u64 acc;
414-
* u32 spefscr;
415-
* }
416-
*/
417-
418-
static int evr_active(struct task_struct *target,
419-
const struct user_regset *regset)
420-
{
421-
flush_spe_to_thread(target);
422-
return target->thread.used_spe ? regset->n : 0;
423-
}
424-
425-
static int evr_get(struct task_struct *target, const struct user_regset *regset,
426-
unsigned int pos, unsigned int count,
427-
void *kbuf, void __user *ubuf)
428-
{
429-
int ret;
430-
431-
flush_spe_to_thread(target);
432-
433-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
434-
&target->thread.evr,
435-
0, sizeof(target->thread.evr));
436-
437-
BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
438-
offsetof(struct thread_struct, spefscr));
439-
440-
if (!ret)
441-
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
442-
&target->thread.acc,
443-
sizeof(target->thread.evr), -1);
444-
445-
return ret;
446-
}
447-
448-
static int evr_set(struct task_struct *target, const struct user_regset *regset,
449-
unsigned int pos, unsigned int count,
450-
const void *kbuf, const void __user *ubuf)
451-
{
452-
int ret;
453-
454-
flush_spe_to_thread(target);
455-
456-
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
457-
&target->thread.evr,
458-
0, sizeof(target->thread.evr));
459-
460-
BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
461-
offsetof(struct thread_struct, spefscr));
462-
463-
if (!ret)
464-
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
465-
&target->thread.acc,
466-
sizeof(target->thread.evr), -1);
467-
468-
return ret;
469-
}
470-
#endif /* CONFIG_SPE */
471-
472406
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
473407
/**
474408
* tm_cgpr_active - get active number of registers in CGPR

0 commit comments

Comments
 (0)