misc/tst-pkeys fails on POWER if they kernel implements memory protection keys because pkey_set and pkey_get are the stub implementations. I have implementations for these functions on POWER (translating them into AMR register accesses), but the kernel support has issues: https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-May/173157.html
Another problem (currently not covered by tst-pkeys): https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-May/173160.html
To fix this, we need an implement of pkey_set and pkey_get for POWER: https://sourceware.org/ml/libc-alpha/2018-05/msg00760.html We need some kernel fixes, especially for fork and execve: https://lists.ozlabs.org/pipermail/linuxppc-dev/2018-June/174612.html And then there are some incorrect assumptions encoded in tst-pkeys itself (I have a patch).
*** Bug 23885 has been marked as a duplicate of this bug. ***
Ideally, we'd get a PKEY_DISABLE_READ flag to support POWER better for pkey_get: From: Florian Weimer <fweimer@redhat.com> Subject: pkeys: Reserve PKEY_DISABLE_READ To: linux-api@vger.kernel.org, linux-mm@kvack.org Cc: dave.hansen@intel.com, linuxram@us.ibm.com Date: Thu, 08 Nov 2018 13:05:09 +0100 https://marc.info/?l=linux-mm&m=154167872212711 I haven't seen a kernel patch for this yet.
The master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a803367bab167f5ec4fde1f0d0ec447707c29520 commit a803367bab167f5ec4fde1f0d0ec447707c29520 Author: Florian Weimer <fweimer@redhat.com> Date: Fri Feb 14 20:55:39 2020 +0100 powerpc64: Add memory protection key support [BZ #23202] The 32-bit protection key behavior is somewhat unclear on 32-bit powerpc, so this change is restricted to the 64-bit variants. Flag translation is needed because of hardware differences between the POWER implementation (read and write flags) and the Intel implementation (write and read+write flags).
misc/tst-pkeys still needs to be updated with different test expectations.
The master branch has been updated by Tulio Magno Quites Machado Filho <tuliom@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8d42bf859a289944749d9f978c076cd318119867 commit 8d42bf859a289944749d9f978c076cd318119867 Author: Lucas A. M. Magalhaes <lamm@linux.ibm.com> Date: Mon Feb 17 09:09:52 2020 -0300 Fix tst-pkey expectations on pkey_get [BZ #23202] From the GNU C Library manual, the pkey_set can receive a combination of PKEY_DISABLE_WRITE and PKEY_DISABLE_ACCESS. However PKEY_DISABLE_ACCESS is more restrictive than PKEY_DISABLE_WRITE and includes its behavior. The test expects that after setting (PKEY_DISABLE_WRITE|PKEY_DISABLE_ACCESS) pkey_get should return the same. This may not be true as PKEY_DISABLE_ACCESS will succeed in describing the state of the key in this case. The pkey behavior during signal handling is different between x86 and POWER. This change make the test compatible with both architectures. Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
There is still a scenario where tst-pkeys fail on POWER: when Linux <= 4.18. More information here: https://www.sourceware.org/ml/libc-alpha/2020-02/msg00819.html The support for pkeys on POWER was enabled on Linux 4.16. However, it had issues that have been fixed on Linux 4.19. Calls to pkey_alloc() succeed in that scenario, making it hard to detect the support for pkeys.
Fixed in 2.32.