Skip to contentSkip to conversation

pkey01: print more info when write buff fail

PATCH In review Li Wang 5 participants 8 messages Apr 11, 2022 – Oct 10, 2022

lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/2 pkey01: print more info when write buff fail

We got sporadically failed on POWER9 but couldn't reproduce the problem manually. Here add printf to show info to see if the PKEY_DISABLE_WRITE takes effect on buffers.

pkey01.c:149: TINFO: Set PKEY_DISABLE_WRITE on (MAP_ANONYMOUS|MAP_PRIVATE|MAP_HUGETLB) buffer pkey01.c:174: TFAIL: Child: exited with 0
pkey01.c:176: TINFO: Remove PKEY_DISABLE_WRITE from the buffer

---
 testcases/kernel/syscalls/pkeys/pkey01.c | 3 +++
 1 file changed, 3 insertions(+)
testcases/kernel/syscalls/pkeys/pkey01.c +3 -0
index 04f50924c..1a9194e1a 100644
@@ -161,6 +161,8 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
 		break;
 		case PKEY_DISABLE_WRITE:
 			*buffer = 'a';
+			tst_res(TFAIL | TERRNO,
+				"Write buffer success, buffer[0] = %d", *buffer);
 		break;
 		}
 		exit(0);
@@ -183,6 +185,7 @@ static void pkey_test(struct tcase *tc, struct mmap_param *mpa)
 	break;
 	case PROT_WRITE:
 		*buffer = 'a';
+		tst_res(TPASS, "Write buffer success, buffer[0] = %d", *buffer);
 	break;
 	case PROT_READ | PROT_WRITE:
 	case PROT_READ | PROT_WRITE | PROT_EXEC:
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH 2/2 pkey: correct the PKEY_DISABLE_ACCESS definitions on PowerPC

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9506394a159

---
 testcases/kernel/syscalls/pkeys/pkey.h | 7 +++++++
 1 file changed, 7 insertions(+)
testcases/kernel/syscalls/pkeys/pkey.h +7 -0
index 6e32326b6..6cda88ff1 100644
@@ -11,6 +11,13 @@
 #include "lapi/syscalls.h"
 #include "lapi/mmap.h"
 
+#if defined(__powerpc__) || defined(__ppc__)
+# undef PKEY_DISABLE_ACCESS
+# define PKEY_DISABLE_ACCESS 0x3
+# undef PKEY_DISABLE_WRITE
+# define PKEY_DISABLE_WRITE  0x2
+#endif
+
 #ifndef PKEY_DISABLE_ACCESS
 # define PKEY_DISABLE_ACCESS 0x1
 # define PKEY_DISABLE_WRITE  0x2
Signature · 5 lines
2.31.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Re: [LTP] [PATCH 2/2] pkey: correct the PKEY_DISABLE_ACCESS definitions on PowerPC

Quoted 13 lines · Li Wang

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9506394a159

---
 testcases/kernel/syscalls/pkeys/pkey.h | 7 +++++++
 1 file changed, 7 insertions(+)
testcases/kernel/syscalls/pkeys/pkey.h +0 -0
index 6e32326b6..6cda88ff1 100644

testcases/kernel/syscalls/pkeys/pkey.h line 16

Quoted 6 lines
testcases/kernel/syscalls/pkeys/pkey.h +3 -0
@@ -11,6 +11,13 @@
 #include "lapi/syscalls.h"
 #include "lapi/mmap.h"
 
+#if defined(__powerpc__) || defined(__ppc__)
+# undef PKEY_DISABLE_ACCESS
+# define PKEY_DISABLE_ACCESS 0x3

Where does powerpc define PKEY_DISABLE_ACCESS as 0x3?

Comment in tools/testing/selftests/powerpc/include/pkeys.h says it's older glibc that has this problem, but looking at latest glibc it still defines it as 0x1:
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/bits/mman-shared.h;h=00a1f27c0ef51de1ec657071c5744e09299f7ff2;hb=HEAD#l41

Quoted 14 lines
testcases/kernel/syscalls/pkeys/pkey.h +4 -1
+# undef PKEY_DISABLE_WRITE
+# define PKEY_DISABLE_WRITE  0x2
+#endif
+
 #ifndef PKEY_DISABLE_ACCESS
 # define PKEY_DISABLE_ACCESS 0x1
 # define PKEY_DISABLE_WRITE  0x2
--

2.31.1

--
Mailing list info: https://lists.linux.it/listinfo/ltp

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

Re: [LTP] [PATCH 2/2] pkey: correct the PKEY_DISABLE_ACCESS definitions on PowerPC

Quoted 19 lines · Jan Stancek
Quoted 2 lines · Li Wang

Reference:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9506394a159

Review

Quoted 7 lines
---
 testcases/kernel/syscalls/pkeys/pkey.h | 7 +++++++
 1 file changed, 7 insertions(+)
(quoted diff) +0 -0

b/testcases/kernel/syscalls/pkeys/pkey.h

Quoted 7 lines

index 6e32326b6..6cda88ff1 100644

testcases/kernel/syscalls/pkeys/pkey.h +0 -0
@@ -11,6 +11,13 @@
 #include "lapi/syscalls.h"
 #include "lapi/mmap.h"
 
Quoted 6 lines

testcases/kernel/syscalls/pkeys/pkey.h line 16

Quoted 3 lines
testcases/kernel/syscalls/pkeys/pkey.h +3 -0
+#if defined(__powerpc__) || defined(__ppc__)
+# undef PKEY_DISABLE_ACCESS
+# define PKEY_DISABLE_ACCESS 0x3

Where does powerpc define PKEY_DISABLE_ACCESS as 0x3?

Good question, I previously thought that was officially defined as 0x3 on PowerPC (per Ram's patch).

But after looking at 'powerpc/include/uapi/asm/mman.h' it still includes header which define PKEY_DISABLE_ACCESS as 0x1.

    #include <asm-generic/mman-common.h>

@Ram Pai, could you explain why you're using 0x3 in kselftest? Did I miss anything?

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH 2/2] pkey: correct the PKEY_DISABLE_ACCESS definitions on PowerPC

Hello,

Quoted 25 lines · Li Wang

On Mon, Apr 11, 2022 at 6:57 PM Jan Stancek <[email protected]> wrote:

Quoted 13 lines · Li Wang

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e9506394a159

---
 testcases/kernel/syscalls/pkeys/pkey.h | 7 +++++++
 1 file changed, 7 insertions(+)
testcases/kernel/syscalls/pkeys/pkey.h +0 -0
index 6e32326b6..6cda88ff1 100644

testcases/kernel/syscalls/pkeys/pkey.h line 16

Quoted 6 lines
testcases/kernel/syscalls/pkeys/pkey.h +3 -0
@@ -11,6 +11,13 @@
 #include "lapi/syscalls.h"
 #include "lapi/mmap.h"
 
+#if defined(__powerpc__) || defined(__ppc__)
+# undef PKEY_DISABLE_ACCESS
+# define PKEY_DISABLE_ACCESS 0x3

Where does powerpc define PKEY_DISABLE_ACCESS as 0x3?

Quoted 8 lines

Good question, I previously thought that was officially defined as 0x3 on PowerPC (per Ram's patch).

But after looking at 'powerpc/include/uapi/asm/mman.h' it still includes header which define PKEY_DISABLE_ACCESS as 0x1.

    #include <asm-generic/mman-common.h>

@Ram Pai, could you explain why you're using 0x3 in kselftest? Did I miss anything?

No response and I guess pkey01 would fail on some systems if it weren't 0x1. So I'll mark this as rejected in patchwork.

Signature · 5 lines
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#7 lore raw
Quoted 2 lines

This looks good to me, in case you are going to push the patch:

Thanks, I have pushed patch-1/2, hope it helps to catch something useful.

Signature · 2 lines
Regards,
Li Wang
Signature · 2 lines
-- 
Mailing list info: https://lists.linux.it/listinfo/ltp