[PATCH RFC v9 09/25] arm64: Enable kpkeys
Linu Cherian
linu.cherian at arm.com
Thu Sep 3 02:14:01 PDT 2026
Kevin,
On Tue, Aug 18, 2026 at 03:08:51PM +0100, Kevin Brodsky wrote:
> This is the final step to enable kpkeys on arm64. We enable
> POE at EL1 by setting TCR2_EL1.POE, and initialise POR_EL1 to the
> default value, enabling access to the default pkey/POIndex (0).
> An ISB is added so that POE restrictions are enforced immediately.
>
> Having done this, we can now select ARCH_HAS_KPKEYS if ARM64_POE is
> enabled.
>
> Signed-off-by: Kevin Brodsky <kevin.brodsky at arm.com>
> ---
> arch/arm64/Kconfig | 1 +
> arch/arm64/kernel/cpufeature.c | 5 ++++-
> 2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
> index b3afe0688919..0afa085c66be 100644
> --- a/arch/arm64/Kconfig
> +++ b/arch/arm64/Kconfig
> @@ -2202,6 +2202,7 @@ config ARM64_POE
> def_bool y
> select ARCH_USES_HIGH_VMA_FLAGS
> select ARCH_HAS_PKEYS
> + select ARCH_HAS_KPKEYS
> help
> The Permission Overlay Extension is used to implement Memory
> Protection Keys. Memory Protection Keys provides a mechanism for
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 9a22df0c5120..4f2f54007ed6 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -76,6 +76,7 @@
> #include <linux/kasan.h>
> #include <linux/percpu.h>
> #include <linux/sched/isolation.h>
> +#include <linux/kpkeys.h>
>
> #include <asm/arm_pmuv3.h>
> #include <asm/cpu.h>
> @@ -2463,8 +2464,10 @@ static void cpu_enable_mops(const struct arm64_cpu_capabilities *__unused)
> #ifdef CONFIG_ARM64_POE
> static void cpu_enable_poe(const struct arm64_cpu_capabilities *__unused)
> {
> - sysreg_clear_set(REG_TCR2_EL1, 0, TCR2_EL1_E0POE);
> + write_sysreg_s(POR_EL1_INIT, SYS_POR_EL1);
May be we could move this to __cpu_setup. Please see comments on Patch 8.
--
Linu Cherian
More information about the linux-arm-kernel
mailing list