The patch titled Subject: selftests/vm/pkeys: fix assertion in test_pkey_alloc_exhaust() has been added to the -mm tree. Its filename is selftests-vm-pkeys-fix-assertion-in-test_pkey_alloc_exhaust.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/selftests-vm-pkeys-fix-assertion-in-test_pkey_alloc_exhaust.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/selftests-vm-pkeys-fix-assertion-in-test_pkey_alloc_exhaust.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Ram Pai <linuxram@xxxxxxxxxx> Subject: selftests/vm/pkeys: fix assertion in test_pkey_alloc_exhaust() Some pkeys which are valid on the hardware are reserved and not available for application use. These keys cannot be allocated. test_pkey_alloc_exhaust() tries to account for these and has an assertion which validates if all available pkeys have been exahaustively allocated. However, the expression that is currently used is only valid for x86. On powerpc, a pkey is additionally reserved as compared to x86. Hence, the assertion is made to use an arch-specific helper to get the correct count of reserved pkeys. Link: http://lkml.kernel.org/r/38b08d0318820ae46af3aa6048384fd8056c3df7.1585646528.git.sandipan@xxxxxxxxxxxxx Signed-off-by: Ram Pai <linuxram@xxxxxxxxxx> Signed-off-by: Sandipan Das <sandipan@xxxxxxxxxxxxx> Acked-by: Dave Hansen <dave.hansen@xxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxx> Cc: Florian Weimer <fweimer@xxxxxxxxxx> Cc: "Desnes A. Nunes do Rosario" <desnesn@xxxxxxxxxxxxxxxxxx> Cc: Ingo Molnar <mingo@xxxxxxxxxx> Cc: Thiago Jung Bauermann <bauerman@xxxxxxxxxxxxx> Cc: "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxxxx> Cc: Michal Suchanek <msuchanek@xxxxxxx> Cc: Shuah Khan <shuah@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- tools/testing/selftests/vm/protection_keys.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) --- a/tools/testing/selftests/vm/protection_keys.c~selftests-vm-pkeys-fix-assertion-in-test_pkey_alloc_exhaust +++ a/tools/testing/selftests/vm/protection_keys.c @@ -1153,6 +1153,7 @@ void test_pkey_alloc_exhaust(int *ptr, u dprintf3("%s()::%d\n", __func__, __LINE__); /* + * On x86: * There are 16 pkeys supported in hardware. Three are * allocated by the time we get here: * 1. The default key (0) @@ -1160,8 +1161,16 @@ void test_pkey_alloc_exhaust(int *ptr, u * 3. One allocated by the test code and passed in via * 'pkey' to this function. * Ensure that we can allocate at least another 13 (16-3). + * + * On powerpc: + * There are either 5, 28, 29 or 32 pkeys supported in + * hardware depending on the page size (4K or 64K) and + * platform (powernv or powervm). Four are allocated by + * the time we get here. These include pkey-0, pkey-1, + * exec-only pkey and the one allocated by the test code. + * Ensure that we can allocate the remaining. */ - pkey_assert(i >= NR_PKEYS-3); + pkey_assert(i >= (NR_PKEYS - get_arch_reserved_keys() - 1)); for (i = 0; i < nr_allocated_pkeys; i++) { err = sys_pkey_free(allocated_pkeys[i]); _ Patches currently in -mm which might be from linuxram@xxxxxxxxxx are selftests-x86-pkeys-move-selftests-to-arch-neutral-directory.patch selftests-vm-pkeys-rename-all-references-to-pkru-to-a-generic-name.patch selftests-vm-pkeys-move-generic-definitions-to-header-file.patch selftests-vm-pkeys-fix-pkey_disable_clear.patch selftests-vm-pkeys-fix-assertion-in-pkey_disable_set-clear.patch selftests-vm-pkeys-fix-alloc_random_pkey-to-make-it-really-random.patch selftests-vm-pkeys-introduce-generic-pkey-abstractions.patch selftests-vm-pkeys-introduce-powerpc-support.patch selftests-vm-pkeys-fix-assertion-in-test_pkey_alloc_exhaust.patch selftests-vm-pkeys-improve-checks-to-determine-pkey-support.patch selftests-vm-pkeys-associate-key-on-a-mapped-page-and-detect-access-violation.patch selftests-vm-pkeys-associate-key-on-a-mapped-page-and-detect-write-violation.patch selftests-vm-pkeys-detect-write-violation-on-a-mapped-access-denied-key-page.patch selftests-vm-pkeys-introduce-a-sub-page-allocator.patch selftests-vm-pkeys-test-correct-behaviour-of-pkey-0.patch selftests-vm-pkeys-override-access-right-definitions-on-powerpc.patch