Skip to content

Commit 772a84d

Browse files
author
Fox Snowpatch
committed
1 parent 2dd0957 commit 772a84d

File tree

3 files changed

+10
-55
lines changed

3 files changed

+10
-55
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-30
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,7 @@
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
31-
32-
#ifndef PKEY_DISABLE_EXECUTE
33-
#define PKEY_DISABLE_EXECUTE 0x4
34-
#endif
35-
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))
19+
#include "pkeys.h"
3920

4021
#define CORE_FILE_LIMIT (5 * 1024 * 1024) /* 5 MB should be enough */
4122

@@ -61,16 +42,6 @@ struct shared_info {
6142
time_t core_time;
6243
};
6344

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-
7445
static int increase_core_file_limit(void)
7546
{
7647
struct rlimit rlim;

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

+1-25
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,7 @@
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
22-
23-
#ifndef PKEY_DISABLE_EXECUTE
24-
#define PKEY_DISABLE_EXECUTE 0x4
25-
#endif
26-
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))
10+
#include "pkeys.h"
3011

3112
static const char user_read[] = "[User Read (Running)]";
3213
static const char user_write[] = "[User Write (Running)]";
@@ -61,11 +42,6 @@ struct shared_info {
6142
unsigned long invalid_uamor;
6243
};
6344

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-
6945
static int child(struct shared_info *info)
7046
{
7147
unsigned long reg;

0 commit comments

Comments
 (0)