Skip to content

Commit 65f5038

Browse files
selftest/powerpc/ptrace: Cleanup duplicate macro definitions
Both core-pkey.c and ptrace-pkey.c tests have similar macro definitions, move them to "pkeys.h" and remove the macro definitions from the C file. Reviewed-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20241216160257.87252-3-maddy@linux.ibm.com
1 parent b0e1b95 commit 65f5038

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,6 @@
1818
#include "child.h"
1919
#include "pkeys.h"
2020

21-
#ifndef NT_PPC_PKEY
22-
#define NT_PPC_PKEY 0x110
23-
#endif
24-
25-
#ifndef PKEY_DISABLE_EXECUTE
26-
#define PKEY_DISABLE_EXECUTE 0x4
27-
#endif
28-
29-
#define AMR_BITS_PER_PKEY 2
30-
#define PKEY_REG_BITS (sizeof(u64) * 8)
31-
#define pkeyshift(pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY))
32-
3321
#define CORE_FILE_LIMIT (5 * 1024 * 1024) /* 5 MB should be enough */
3422

3523
static const char core_pattern_file[] = "/proc/sys/kernel/core_pattern";

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,6 @@
99
#include "child.h"
1010
#include "pkeys.h"
1111

12-
#ifndef NT_PPC_PKEY
13-
#define NT_PPC_PKEY 0x110
14-
#endif
15-
16-
#ifndef PKEY_DISABLE_EXECUTE
17-
#define PKEY_DISABLE_EXECUTE 0x4
18-
#endif
19-
20-
#define AMR_BITS_PER_PKEY 2
21-
#define PKEY_REG_BITS (sizeof(u64) * 8)
22-
#define pkeyshift(pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY))
23-
2412
static const char user_read[] = "[User Read (Running)]";
2513
static const char user_write[] = "[User Write (Running)]";
2614
static const char ptrace_read_running[] = "[Ptrace Read (Running)]";

0 commit comments

Comments
 (0)