summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm/book3s64/pkeys.c
diff options
context:
space:
mode:
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>2020-11-27 10:14:07 +0530
committerMichael Ellerman <mpe@ellerman.id.au>2020-12-04 01:01:24 +1100
commit3b47b7549ead0719e94022c6742199333c7c8d9f (patch)
tree664fc66cb58bd24fa1245b32c4b9a26633b1053e /arch/powerpc/mm/book3s64/pkeys.c
parent39df17bc20059c84ddc6f91831fce2e2cc79a6f3 (diff)
downloadlinux-3b47b7549ead0719e94022c6742199333c7c8d9f.tar.bz2
powerpc/book3s64/kuap: Move KUAP related function outside radix
The next set of patches adds support for kuap with hash translation. In preparation for that rename/move kuap related functions to non radix names. 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-6-aneesh.kumar@linux.ibm.com
Diffstat (limited to 'arch/powerpc/mm/book3s64/pkeys.c')
-rw-r--r--arch/powerpc/mm/book3s64/pkeys.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c
index 7dc71f85683d..c75994cf50a7 100644
--- a/arch/powerpc/mm/book3s64/pkeys.c
+++ b/arch/powerpc/mm/book3s64/pkeys.c
@@ -9,9 +9,12 @@
#include <asm/mmu_context.h>
#include <asm/mmu.h>
#include <asm/setup.h>
+#include <asm/smp.h>
+
#include <linux/pkeys.h>
#include <linux/of_fdt.h>
+
int num_pkey; /* Max number of pkeys supported */
/*
* Keys marked in the reservation list cannot be allocated by userspace
@@ -226,6 +229,25 @@ out:
return;
}
+#ifdef CONFIG_PPC_KUAP
+void __init setup_kuap(bool disabled)
+{
+ if (disabled || !early_radix_enabled())
+ return;
+
+ if (smp_processor_id() == boot_cpuid) {
+ pr_info("Activating Kernel Userspace Access Prevention\n");
+ cur_cpu_spec->mmu_features |= MMU_FTR_RADIX_KUAP;
+ }
+
+ /*
+ * Set the default kernel AMR values on all cpus.
+ */
+ mtspr(SPRN_AMR, AMR_KUAP_BLOCKED);
+ isync();
+}
+#endif
+
static inline u64 read_amr(void)
{
return mfspr(SPRN_AMR);