Skip to content

Commit 329b101

Browse files
author
Fox Snowpatch
committed
1 parent 1ecdccb commit 329b101

File tree

3 files changed

+10
-47
lines changed

3 files changed

+10
-47
lines changed

tools/testing/selftests/powerpc/include/pkeys.h

+8
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,18 @@
3535
#define __NR_pkey_alloc 384
3636
#define __NR_pkey_free 385
3737

38+
#ifndef NT_PPC_PKEY
39+
#define NT_PPC_PKEY 0x110
40+
#endif
41+
3842
#define PKEY_BITS_PER_PKEY 2
3943
#define NR_PKEYS 32
4044
#define PKEY_BITS_MASK ((1UL << PKEY_BITS_PER_PKEY) - 1)
4145

46+
#define AMR_BITS_PER_PKEY 2
47+
#define PKEY_REG_BITS (sizeof(u64) * 8)
48+
#define pkeyshift(pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY))
49+
4250
inline unsigned long pkeyreg_get(void)
4351
{
4452
return mfspr(SPRN_AMR);

tools/testing/selftests/powerpc/ptrace/core-pkey.c

+1-26
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,12 @@
1616
#include <unistd.h>
1717
#include "ptrace.h"
1818
#include "child.h"
19-
20-
#ifndef __NR_pkey_alloc
21-
#define __NR_pkey_alloc 384
22-
#endif
23-
24-
#ifndef __NR_pkey_free
25-
#define __NR_pkey_free 385
26-
#endif
27-
28-
#ifndef NT_PPC_PKEY
29-
#define NT_PPC_PKEY 0x110
30-
#endif
19+
#include "pkeys.h"
3120

3221
#ifndef PKEY_DISABLE_EXECUTE
3322
#define PKEY_DISABLE_EXECUTE 0x4
3423
#endif
3524

36-
#define AMR_BITS_PER_PKEY 2
37-
#define PKEY_REG_BITS (sizeof(u64) * 8)
38-
#define pkeyshift(pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY))
39-
4025
#define CORE_FILE_LIMIT (5 * 1024 * 1024) /* 5 MB should be enough */
4126

4227
static const char core_pattern_file[] = "/proc/sys/kernel/core_pattern";
@@ -61,16 +46,6 @@ struct shared_info {
6146
time_t core_time;
6247
};
6348

64-
static int sys_pkey_alloc(unsigned long flags, unsigned long init_access_rights)
65-
{
66-
return syscall(__NR_pkey_alloc, flags, init_access_rights);
67-
}
68-
69-
static int sys_pkey_free(int pkey)
70-
{
71-
return syscall(__NR_pkey_free, pkey);
72-
}
73-
7449
static int increase_core_file_limit(void)
7550
{
7651
struct rlimit rlim;

tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c

+1-21
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,12 @@
77
*/
88
#include "ptrace.h"
99
#include "child.h"
10-
11-
#ifndef __NR_pkey_alloc
12-
#define __NR_pkey_alloc 384
13-
#endif
14-
15-
#ifndef __NR_pkey_free
16-
#define __NR_pkey_free 385
17-
#endif
18-
19-
#ifndef NT_PPC_PKEY
20-
#define NT_PPC_PKEY 0x110
21-
#endif
10+
#include "pkeys.h"
2211

2312
#ifndef PKEY_DISABLE_EXECUTE
2413
#define PKEY_DISABLE_EXECUTE 0x4
2514
#endif
2615

27-
#define AMR_BITS_PER_PKEY 2
28-
#define PKEY_REG_BITS (sizeof(u64) * 8)
29-
#define pkeyshift(pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY))
30-
3116
static const char user_read[] = "[User Read (Running)]";
3217
static const char user_write[] = "[User Write (Running)]";
3318
static const char ptrace_read_running[] = "[Ptrace Read (Running)]";
@@ -61,11 +46,6 @@ struct shared_info {
6146
unsigned long invalid_uamor;
6247
};
6348

64-
static int sys_pkey_alloc(unsigned long flags, unsigned long init_access_rights)
65-
{
66-
return syscall(__NR_pkey_alloc, flags, init_access_rights);
67-
}
68-
6949
static int child(struct shared_info *info)
7050
{
7151
unsigned long reg;

0 commit comments

Comments
 (0)