powerpc/book3s64/kuep: Add MMU_FTR_KUEP
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Thu, 9 Jul 2020 03:29:37 +0000 (08:59 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 20 Jul 2020 12:57:58 +0000 (22:57 +1000)
This will be used to enable/disable Kernel Userspace Execution
Prevention (KUEP).

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/20200709032946.881753-15-aneesh.kumar@linux.ibm.com
arch/powerpc/include/asm/mmu.h
arch/powerpc/mm/book3s64/radix_pgtable.c

index 17cbaf1..255a183 100644 (file)
  */
 
 /*
+ * Support for KUEP feature.
+ */
+#define MMU_FTR_KUEP                   ASM_CONST(0x00000400)
+
+/*
  * Support for memory protection keys.
  */
 #define MMU_FTR_PKEY                   ASM_CONST(0x00000800)
@@ -189,6 +194,10 @@ enum {
 #ifdef CONFIG_PPC_MEM_KEYS
        MMU_FTR_PKEY |
 #endif
+#ifdef CONFIG_PPC_KUEP
+       MMU_FTR_KUEP |
+#endif /* CONFIG_PPC_KUAP */
+
                0,
 };
 
index c5bf2ef..3536675 100644 (file)
@@ -593,8 +593,10 @@ void setup_kuep(bool disabled)
        if (disabled || !early_radix_enabled())
                return;
 
-       if (smp_processor_id() == boot_cpuid)
+       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