[v18,23/24] selftests: vm: pkeys: Use the correct page size on powerpc
diff mbox series

Message ID ff2f307f4087edda4aa4b3158f3bc7df4cbd0f21.1580365432.git.sandipan@linux.ibm.com
State New
Headers show
  • selftests, powerpc, x86: Memory Protection Keys
Related show

Commit Message

Sandipan Das Jan. 30, 2020, 6:37 a.m. UTC
Both 4K and 64K pages are supported on powerpc. Parts of
the selftest code perform alignment computations based on
the PAGE_SIZE macro which is currently hardcoded to 64K
for powerpc. This causes some test failures on kernels
configured with 4K page size.

In some cases, we need to enforce function alignment on
page size. Since this can only be done at build time,
64K is used as the alignment factor as that also ensures
4K alignment.

Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
 tools/testing/selftests/vm/pkey-powerpc.h    | 2 +-
 tools/testing/selftests/vm/protection_keys.c | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff mbox series

diff --git a/tools/testing/selftests/vm/pkey-powerpc.h b/tools/testing/selftests/vm/pkey-powerpc.h
index 02bd4dd7d467..3a761e51a587 100644
--- a/tools/testing/selftests/vm/pkey-powerpc.h
+++ b/tools/testing/selftests/vm/pkey-powerpc.h
@@ -36,7 +36,7 @@ 
 					     pkey-31 and exec-only key */
 #define HPAGE_SIZE		(1UL << 24)
-#define PAGE_SIZE		(1UL << 16)
+#define PAGE_SIZE		sysconf(_SC_PAGESIZE)
 static inline u32 pkey_bit_position(int pkey)
diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c
index a1cb9a71e77c..fc19addcb5c8 100644
--- a/tools/testing/selftests/vm/protection_keys.c
+++ b/tools/testing/selftests/vm/protection_keys.c
@@ -146,7 +146,12 @@  void abort_hooks(void)
  * will then fault, which makes sure that the fault code handles
  * execute-only memory properly.
+#ifdef __powerpc64__
+/* This way, both 4K and 64K alignment are maintained */
 void lots_o_noops_around_write(int *write_to_me)
 	dprintf3("running %s()\n", __func__);