selftest/powerpc/ptrace/core-pkey: Remove duplicate macros
Madhavan Srinivasan
maintainerPATCH v2 1/3 selftest/powerpc/ptrace/core-pkey: Remove duplicate macros
./powerpc/ptrace/Makefile includes flags.mk. In flags.mk, -I$(selfdir)/powerpc/include is always included as part of CFLAGS. So it will pick up the "pkeys.h" defined in powerpc/include.
core-pkey.c test has couple of macros defined which are part of "pkeys.h" header file. Remove those duplicates and include "pkeys.h"
---
Changelog v1:
- Added Reviewed-by tag
- made changes to commit message
.../selftests/powerpc/ptrace/core-pkey.c | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-)
tools/testing/selftests/powerpc/ptrace/core-pkey.c +1 -18
@@ -16,14 +16,7 @@#include <unistd.h> #include "ptrace.h" #include "child.h" - -#ifndef __NR_pkey_alloc -#define __NR_pkey_alloc 384 -#endif - -#ifndef __NR_pkey_free -#define __NR_pkey_free 385 -#endif +#include "pkeys.h" #ifndef NT_PPC_PKEY #define NT_PPC_PKEY 0x110
@@ -61,16 +54,6 @@ struct shared_info {time_t core_time; }; -static int sys_pkey_alloc (unsigned long flags,unsigned long init_access_rights) -{ -return syscall (__NR_pkey_alloc, flags, init_access_rights); -} - -static int sys_pkey_free (int pkey) -{ -return syscall (__NR_pkey_free, pkey); -} -static int increase_core_file_limit (void ) {struct rlimit rlim;
Signature · 1 line
2.47.0
Madhavan Srinivasan
maintainerPATCH v2 2/3 selftest/powerpc/ptrace/ptrace-pkey: Remove duplicate macros
./powerpc/ptrace/Makefile includes flags.mk.
In flags.mk, -I$(selfdir)/powerpc/include is always included as part of CFLAGS. So it will pick up the "pkeys.h" defined in powerpc/include.
ptrace-pkey.c test has macros defined which
are part of "pkeys.h" header file. Remove those duplicates and include "pkeys.h"
---
Changelog v1:
- Added Reviewed-by tag
- made changes to commit message
.../testing/selftests/powerpc/ptrace/ptrace-pkey.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c +1 -13
@@ -7,14 +7,7 @@*/ #include "ptrace.h" #include "child.h" - -#ifndef __NR_pkey_alloc -#define __NR_pkey_alloc 384 -#endif - -#ifndef __NR_pkey_free -#define __NR_pkey_free 385 -#endif +#include "pkeys.h" #ifndef NT_PPC_PKEY #define NT_PPC_PKEY 0x110
@@ -61,11 +54,6 @@ struct shared_info {unsigned long invalid_uamor; }; -static int sys_pkey_alloc (unsigned long flags,unsigned long init_access_rights) -{ -return syscall (__NR_pkey_alloc, flags, init_access_rights); -} -static int child (struct shared_info *info) {unsigned long reg;
Signature · 1 line
2.47.0
Madhavan Srinivasan
maintainerPATCH v2 3/3 selftest/powerpc/ptrace: Cleanup duplicate macro definitions
In reply to Madhavan SrinivasanBoth 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.
---
Changelog v1:
- Removed additional macros pointed out by Ritesh which are duplicates and are avilable in "pkeys.h"
tools/testing/selftests/powerpc/include/pkeys.h | 8 ++++++++ tools/testing/selftests/powerpc/ptrace/core-pkey.c | 12 ------------ tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c | 12 ------------ 3 files changed, 8 insertions(+), 24 deletions(-)
tools/testing/selftests/powerpc/include/pkeys.h +8 -0
@@ -35,10 +35,18 @@#define __NR_pkey_alloc 384#define __NR_pkey_free 385 +#ifndef NT_PPC_PKEY +#define NT_PPC_PKEY 0x110 +#endif +#define PKEY_BITS_PER_PKEY 2#define NR_PKEYS 32#define PKEY_BITS_MASK ((1UL << PKEY_BITS_PER_PKEY) - 1) +#define AMR_BITS_PER_PKEY 2 +#define PKEY_REG_BITS (sizeof(u64) * 8) +#define pkeyshift (pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY)) +inline unsigned long pkeyreg_get (void ) {return mfspr (SPRN_AMR );
tools/testing/selftests/powerpc/ptrace/core-pkey.c +0 -12
@@ -18,18 +18,6 @@#include "child.h" #include "pkeys.h" -#ifndef NT_PPC_PKEY -#define NT_PPC_PKEY 0x110 -#endif - -#ifndef PKEY_DISABLE_EXECUTE -#define PKEY_DISABLE_EXECUTE 0x4 -#endif - -#define AMR_BITS_PER_PKEY 2 -#define PKEY_REG_BITS (sizeof(u64) * 8) -#define pkeyshift (pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY)) -#define CORE_FILE_LIMIT (5 * 1024 * 1024)/* 5 MB should be enough */ static const char core_pattern_file[] ="/proc/sys/kernel/core_pattern" ;
tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c +0 -12
@@ -9,18 +9,6 @@#include "child.h" #include "pkeys.h" -#ifndef NT_PPC_PKEY -#define NT_PPC_PKEY 0x110 -#endif - -#ifndef PKEY_DISABLE_EXECUTE -#define PKEY_DISABLE_EXECUTE 0x4 -#endif - -#define AMR_BITS_PER_PKEY 2 -#define PKEY_REG_BITS (sizeof(u64) * 8) -#define pkeyshift (pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY)) -static const char user_read[] ="[User Read (Running)]" ;static const char user_write[] ="[User Write (Running)]" ;static const char ptrace_read_running[] ="[Ptrace Read (Running)]" ;
Signature · 1 line
2.47.0
Re: [PATCH v2 3/3] selftest/powerpc/ptrace: Cleanup duplicate macro definitions
Quoted 9 lines · Madhavan Srinivasan
Both
core-pkey.candptrace-pkey.ctests have
similar macro definitions, move them to "pkeys.h"
and remove the macro definitions from the C file.Signed-off-by Madhavan Srinivasan <[email protected]>---
Changelog v1:
- Removed additional macros pointed out by Ritesh which are duplicates and are avilable in "pkeys.h"
Thanks! The changes looks good to me.
Please feel free to add -
Gave a quick run on my lpar too -
# selftests: powerpc/ptrace: core-pkey
# test: core_pkey
# [User Write (Running)] AMR: 3cffffffffffffff pkey1: 4 pkey2: 5 pkey3: 6
# success: core_pkey
ok 9 selftests: powerpc/ptrace: core-pkey
# selftests: powerpc/ptrace: ptrace-pkey
# test: ptrace_pkey
# [User Write (Running)] AMR: 3cffffffffffffff pkey1: 4 pkey2: 5 pkey3: 6
# success: ptrace_pkey
ok 13 selftests: powerpc/ptrace: ptrace-pkey
-ritesh
Quoted 77 lines
tools/testing/selftests/powerpc/include/pkeys.h | 8 ++++++++ tools/testing/selftests/powerpc/ptrace/core-pkey.c | 12 ------------ tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c | 12 ------------ 3 files changed, 8 insertions(+), 24 deletions(-)tools/testing/selftests/powerpc/include/pkeys.h +8
-0@@ -35,10 +35,18 @@#define __NR_pkey_alloc 384#define __NR_pkey_free 385 +#ifndef NT_PPC_PKEY +#define NT_PPC_PKEY 0x110 +#endif +#define PKEY_BITS_PER_PKEY 2#define NR_PKEYS 32#define PKEY_BITS_MASK ((1UL << PKEY_BITS_PER_PKEY) - 1) +#define AMR_BITS_PER_PKEY 2 +#define PKEY_REG_BITS (sizeof(u64) * 8) +#define pkeyshift (pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY)) +inline unsigned long pkeyreg_get (void ) {return mfspr (SPRN_AMR );tools/testing/selftests/powerpc/ptrace/core-pkey.c +0
-12@@ -18,18 +18,6 @@#include "child.h" #include "pkeys.h" -#ifndef NT_PPC_PKEY -#define NT_PPC_PKEY 0x110 -#endif - -#ifndef PKEY_DISABLE_EXECUTE -#define PKEY_DISABLE_EXECUTE 0x4 -#endif - -#define AMR_BITS_PER_PKEY 2 -#define PKEY_REG_BITS (sizeof(u64) * 8) -#define pkeyshift (pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY)) -#define CORE_FILE_LIMIT (5 * 1024 * 1024)/* 5 MB should be enough */ static const char core_pattern_file[] ="/proc/sys/kernel/core_pattern" ;tools/testing/selftests/powerpc/ptrace/ptrace-pkey.c +0
-12@@ -9,18 +9,6 @@#include "child.h" #include "pkeys.h" -#ifndef NT_PPC_PKEY -#define NT_PPC_PKEY 0x110 -#endif - -#ifndef PKEY_DISABLE_EXECUTE -#define PKEY_DISABLE_EXECUTE 0x4 -#endif - -#define AMR_BITS_PER_PKEY 2 -#define PKEY_REG_BITS (sizeof(u64) * 8) -#define pkeyshift (pkey) (PKEY_REG_BITS - ((pkey + 1) * AMR_BITS_PER_PKEY)) -static const char user_read[] ="[User Read (Running)]" ;static const char user_write[] ="[User Write (Running)]" ;static const char ptrace_read_running[] ="[Ptrace Read (Running)]" ;Signature · 1 line
2.47.0
Quoted 10 lines · Madhavan Srinivasan
./powerpc/ptrace/Makefile includes flags.mk. In flags.mk, -I$(selfdir)/powerpc/include is always included as part of CFLAGS. So it will pick up the "
pkeys.h" defined in powerpc/include.
core-pkey.ctest has couple of macros defined which are part of "pkeys.h" header file. Remove those duplicates and include "pkeys.h"[...]
Applied to powerpc/next.
[1/3] selftest/powerpc/ptrace/core-pkey: Remove duplicate macros
https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=026ac4dda8f666f737b375731e30ef8f5698b215 [2/3] selftest/powerpc/ptrace/ptrace-pkey: Remove duplicate macros https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=b0e1b95b1597ad3d87ff91d52f6b67cc9423c31e [3/3] selftest/powerpc/ptrace: Cleanup duplicate macro definitions https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?h=next&id=65f5038352e8f635fb827f7482f1d08fae4d16bf
Thanks