diff options
author | Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> | 2020-11-27 05:44:08 +0100 |
---|---|---|
committer | Michael Ellerman <mpe@ellerman.id.au> | 2020-12-03 15:01:24 +0100 |
commit | 57b7505aa8ba13eb18ffabeb689ac64343c53aaa (patch) | |
tree | 107805b2c152309361de9fc692e004fdeac90ee8 /arch/powerpc/mm/book3s64/pkeys.c | |
parent | powerpc/book3s64/kuap: Move KUAP related function outside radix (diff) | |
download | linux-57b7505aa8ba13eb18ffabeb689ac64343c53aaa.tar.xz linux-57b7505aa8ba13eb18ffabeb689ac64343c53aaa.zip |
powerpc/book3s64/kuep: Move KUEP related function outside radix
The next set of patches adds support for kuep with hash translation.
In preparation for that rename/move kuap related functions to
non radix names.
Also set MMU_FTR_KUEP and add the missing isync().
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20201127044424.40686-7-aneesh.kumar@linux.ibm.com
Diffstat (limited to 'arch/powerpc/mm/book3s64/pkeys.c')
-rw-r--r-- | arch/powerpc/mm/book3s64/pkeys.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c index c75994cf50a7..82c722fbce52 100644 --- a/arch/powerpc/mm/book3s64/pkeys.c +++ b/arch/powerpc/mm/book3s64/pkeys.c @@ -229,6 +229,27 @@ out: return; } +#ifdef CONFIG_PPC_KUEP +void __init setup_kuep(bool disabled) +{ + if (disabled || !early_radix_enabled()) + return; + + if (smp_processor_id() == boot_cpuid) { + pr_info("Activating Kernel Userspace Execution Prevention\n"); + cur_cpu_spec->mmu_features |= MMU_FTR_KUEP; + } + + /* + * Radix always uses key0 of the IAMR to determine if an access is + * allowed. We set bit 0 (IBM bit 1) of key0, to prevent instruction + * fetch. + */ + mtspr(SPRN_IAMR, AMR_KUEP_BLOCKED); + isync(); +} +#endif + #ifdef CONFIG_PPC_KUAP void __init setup_kuap(bool disabled) { |