Some fixes for the powerpc bits w.r.t to the way the pkey access rights are defined and how the permission register is updated.
Sandipan Das (2): selftests: vm: pkeys: Fix powerpc access right definitions selftests: vm: pkeys: Fix powerpc access right updates
tools/testing/selftests/vm/pkey-powerpc.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
For powerpc, PKEY_DISABLE_WRITE and PKEY_DISABLE_ACCESS are redefined only if the system headers already define them. Otherwise, the test fails to compile due to their absence. This makes sure that they are always defined irrespective of them being present in the system headers.
Fixes: 130f573c2a79 ("selftests/vm/pkeys: introduce powerpc support") Reported-by: Aneesh Kumar K.V aneesh.kumar@linux.ibm.com Signed-off-by: Sandipan Das sandipan@linux.ibm.com --- tools/testing/selftests/vm/pkey-powerpc.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/vm/pkey-powerpc.h b/tools/testing/selftests/vm/pkey-powerpc.h index 3a761e51a587..eb5077de8f1e 100644 --- a/tools/testing/selftests/vm/pkey-powerpc.h +++ b/tools/testing/selftests/vm/pkey-powerpc.h @@ -16,15 +16,11 @@ #define fpregs fp_regs #define si_pkey_offset 0x20
-#ifdef PKEY_DISABLE_ACCESS #undef PKEY_DISABLE_ACCESS -# define PKEY_DISABLE_ACCESS 0x3 /* disable read and write */ -#endif +#define PKEY_DISABLE_ACCESS 0x3 /* disable read and write */
-#ifdef PKEY_DISABLE_WRITE #undef PKEY_DISABLE_WRITE -# define PKEY_DISABLE_WRITE 0x2 -#endif +#define PKEY_DISABLE_WRITE 0x2
#define NR_PKEYS 32 #define NR_RESERVED_PKEYS_4K 27 /* pkey-0, pkey-1, exec-only-pkey
The Power ISA mandates that all writes to the Authority Mask Register (AMR) must always be preceded as well as succeeded by a context-synchronizing instruction. This applies to both the privileged and unprivileged variants of the Move To AMR instruction.
Fixes: 130f573c2a79 ("selftests/vm/pkeys: introduce powerpc support") Reported-by: Aneesh Kumar K.V aneesh.kumar@linux.ibm.com Suggested-by: Aneesh Kumar K.V aneesh.kumar@linux.ibm.com Signed-off-by: Sandipan Das sandipan@linux.ibm.com --- tools/testing/selftests/vm/pkey-powerpc.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/vm/pkey-powerpc.h b/tools/testing/selftests/vm/pkey-powerpc.h index eb5077de8f1e..1ebb586b2fbc 100644 --- a/tools/testing/selftests/vm/pkey-powerpc.h +++ b/tools/testing/selftests/vm/pkey-powerpc.h @@ -55,7 +55,8 @@ static inline void __write_pkey_reg(u64 pkey_reg) dprintf4("%s() changing %016llx to %016llx\n", __func__, __read_pkey_reg(), pkey_reg);
- asm volatile("mtspr 0xd, %0" : : "r" ((unsigned long)(amr)) : "memory"); + asm volatile("isync; mtspr 0xd, %0; isync" + : : "r" ((unsigned long)(amr)) : "memory");
dprintf4("%s() pkey register after changing %016llx to %016llx\n", __func__, __read_pkey_reg(), pkey_reg);
* Sandipan Das:
The Power ISA mandates that all writes to the Authority Mask Register (AMR) must always be preceded as well as succeeded by a context-synchronizing instruction. This applies to both the privileged and unprivileged variants of the Move To AMR instruction.
Ugh. Do you have a reference for that?
We need to fix this in glibc.
Thanks, Florian
Hi Florian,
On 08/05/20 11:31 pm, Florian Weimer wrote:
- Sandipan Das:
The Power ISA mandates that all writes to the Authority Mask Register (AMR) must always be preceded as well as succeeded by a context-synchronizing instruction. This applies to both the privileged and unprivileged variants of the Move To AMR instruction.
Ugh. Do you have a reference for that?
We need to fix this in glibc.
This is from Table 6 of Chapter 11 in page 1134 of Power ISA 3.0B. The document can be found here: https://ibm.ent.box.com/s/1hzcwkwf8rbju5h9iyf44wm94amnlcrv
- Sandipan
* Sandipan Das:
Hi Florian,
On 08/05/20 11:31 pm, Florian Weimer wrote:
- Sandipan Das:
The Power ISA mandates that all writes to the Authority Mask Register (AMR) must always be preceded as well as succeeded by a context-synchronizing instruction. This applies to both the privileged and unprivileged variants of the Move To AMR instruction.
Ugh. Do you have a reference for that?
We need to fix this in glibc.
This is from Table 6 of Chapter 11 in page 1134 of Power ISA 3.0B. The document can be found here: https://ibm.ent.box.com/s/1hzcwkwf8rbju5h9iyf44wm94amnlcrv
Thanks a lot! I filed:
https://sourceware.org/bugzilla/show_bug.cgi?id=25954
Florian
linux-kselftest-mirror@lists.linaro.org