aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/vm/protection_keys.c
diff options
context:
space:
mode:
authorRam Pai <linuxram@us.ibm.com>2020-06-04 16:52:25 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2020-06-04 19:06:27 -0700
commit94c8a223ded59918536387a9c33fee29ca54fc7e (patch)
treec4296d7b938df36594ae2b503c8e0cfdf8f8c056 /tools/testing/selftests/vm/protection_keys.c
parentselftests/vm/pkeys: fix assertion in test_pkey_alloc_exhaust() (diff)
downloadwireguard-linux-94c8a223ded59918536387a9c33fee29ca54fc7e.tar.xz
wireguard-linux-94c8a223ded59918536387a9c33fee29ca54fc7e.zip
selftests/vm/pkeys: improve checks to determine pkey support
For the pkeys subsystem to work, both the CPU and the kernel need to have support. So, additionally check if the kernel supports pkeys apart from the CPU feature checks. Signed-off-by: Ram Pai <linuxram@us.ibm.com> Signed-off-by: Sandipan Das <sandipan@linux.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: Dave Hansen <dave.hansen@intel.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Florian Weimer <fweimer@redhat.com> Cc: "Desnes A. Nunes do Rosario" <desnesn@linux.vnet.ibm.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Thiago Jung Bauermann <bauerman@linux.ibm.com> Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Michal Hocko <mhocko@kernel.org> Cc: Michal Suchanek <msuchanek@suse.de> Cc: Shuah Khan <shuah@kernel.org> Link: http://lkml.kernel.org/r/8fb76c63ebdadcf068ecd2d23731032e195cd364.1585646528.git.sandipan@linux.ibm.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'tools/testing/selftests/vm/protection_keys.c')
-rw-r--r--tools/testing/selftests/vm/protection_keys.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/testing/selftests/vm/protection_keys.c b/tools/testing/selftests/vm/protection_keys.c
index 5fcbbc525364..95f173049f43 100644
--- a/tools/testing/selftests/vm/protection_keys.c
+++ b/tools/testing/selftests/vm/protection_keys.c
@@ -1378,7 +1378,7 @@ void test_mprotect_pkey_on_unsupported_cpu(int *ptr, u16 pkey)
int size = PAGE_SIZE;
int sret;
- if (cpu_has_pku()) {
+ if (cpu_has_pkeys()) {
dprintf1("SKIP: %s: no CPU support\n", __func__);
return;
}
@@ -1447,12 +1447,13 @@ void pkey_setup_shadow(void)
int main(void)
{
int nr_iterations = 22;
+ int pkeys_supported = is_pkeys_supported();
setup_handlers();
- printf("has pku: %d\n", cpu_has_pku());
+ printf("has pkeys: %d\n", pkeys_supported);
- if (!cpu_has_pku()) {
+ if (!pkeys_supported) {
int size = PAGE_SIZE;
int *ptr;