On 27/10/2024 18:00, Yury Khrustalev wrote: > Replace literal 0 with macro PKEY_UNRESTRICTED where pkey_*() functions > are used in mm selftests for memory protection keys. > > Signed-off-by: Yury Khrustalev <yury.khrustalev@xxxxxxx> > Suggested-by: Joey Gouly <joey.gouly@xxxxxxx> Reviewed-by: Kevin Brodsky <kevin.brodsky@xxxxxxx> > --- > tools/testing/selftests/mm/mseal_test.c | 4 ++-- > tools/testing/selftests/mm/pkey-helpers.h | 3 ++- > tools/testing/selftests/mm/pkey_sighandler_tests.c | 4 ++-- > tools/testing/selftests/mm/protection_keys.c | 2 +- > 4 files changed, 7 insertions(+), 6 deletions(-) > > diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c > index 01675c412b2a..eab214997de0 100644 > --- a/tools/testing/selftests/mm/mseal_test.c > +++ b/tools/testing/selftests/mm/mseal_test.c > @@ -218,7 +218,7 @@ bool seal_support(void) > bool pkey_supported(void) > { > #if defined(__i386__) || defined(__x86_64__) /* arch */ > - int pkey = sys_pkey_alloc(0, 0); > + int pkey = sys_pkey_alloc(0, PKEY_UNRESTRICTED); > > if (pkey > 0) > return true; > @@ -1671,7 +1671,7 @@ static void test_seal_discard_ro_anon_on_pkey(bool seal) > setup_single_address_rw(size, &ptr); > FAIL_TEST_IF_FALSE(ptr != (void *)-1); > > - pkey = sys_pkey_alloc(0, 0); > + pkey = sys_pkey_alloc(0, PKEY_UNRESTRICTED); > FAIL_TEST_IF_FALSE(pkey > 0); > > ret = sys_mprotect_pkey((void *)ptr, size, PROT_READ | PROT_WRITE, pkey); Found one more case just below: diff --git a/tools/testing/selftests/mm/mseal_test.c b/tools/testing/selftests/mm/mseal_test.c index 01675c412b2a..cb0671de1299 100644 --- a/tools/testing/selftests/mm/mseal_test.c +++ b/tools/testing/selftests/mm/mseal_test.c @@ -1683,7 +1683,7 @@ static void test_seal_discard_ro_anon_on_pkey(bool seal) } /* sealing doesn't take effect if PKRU allow write. */ - set_pkey(pkey, 0); + set_pkey(pkey, PKEY_UNRESTRICTED); ret = sys_madvise(ptr, size, MADV_DONTNEED); FAIL_TEST_IF_FALSE(!ret); - Kevin > [...]