]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
powerpc/book3s64/kuap: Move KUAP related function outside radix
authorAneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Fri, 27 Nov 2020 04:44:07 +0000 (10:14 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 3 Dec 2020 14:01:24 +0000 (01:01 +1100)
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
arch/powerpc/include/asm/book3s/64/kup.h [moved from arch/powerpc/include/asm/book3s/64/kup-radix.h with 97% similarity]
arch/powerpc/include/asm/kup.h
arch/powerpc/mm/book3s64/pkeys.c
arch/powerpc/mm/book3s64/radix_pgtable.c

similarity index 97%
rename from arch/powerpc/include/asm/book3s/64/kup-radix.h
rename to arch/powerpc/include/asm/book3s/64/kup.h
index 2fb8ee7b1e2af3fee6bfb25ceeb0454226595bcf..8735d2dede94a2f349ca1c4e05670f868209fa0c 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H
-#define _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H
+#ifndef _ASM_POWERPC_BOOK3S_64_KUP_H
+#define _ASM_POWERPC_BOOK3S_64_KUP_H
 
 #include <linux/const.h>
 #include <asm/reg.h>
@@ -202,4 +202,4 @@ static inline void restore_user_access(unsigned long flags)
 }
 #endif /* __ASSEMBLY__ */
 
-#endif /* _ASM_POWERPC_BOOK3S_64_KUP_RADIX_H */
+#endif /* _ASM_POWERPC_BOOK3S_64_KUP_H */
index 0d93331d0fabbefb07d414d1bec39bcc10014834..a06e50b68d40aaab8feb835b8ab477830a16638b 100644 (file)
 #define KUAP_CURRENT           (KUAP_CURRENT_READ | KUAP_CURRENT_WRITE)
 
 #ifdef CONFIG_PPC_BOOK3S_64
-#include <asm/book3s/64/kup-radix.h>
+#include <asm/book3s/64/kup.h>
 #endif
+
 #ifdef CONFIG_PPC_8xx
 #include <asm/nohash/32/kup-8xx.h>
 #endif
+
 #ifdef CONFIG_PPC_BOOK3S_32
 #include <asm/book3s/32/kup.h>
 #endif
index 7dc71f85683dede1c20c645ccf2e1a556ebdd502..c75994cf50a7f2137102519dcd129f9e5c4d806a 100644 (file)
@@ -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);
index f5f248d44d5c4ca8ed029c4bf84ad16375468564..fe2c26dbcb285fadd0661a32f2179b38cff6805b 100644 (file)
@@ -609,25 +609,6 @@ void setup_kuep(bool disabled)
 }
 #endif
 
-#ifdef CONFIG_PPC_KUAP
-void 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
-
 void __init radix__early_init_mmu(void)
 {
        unsigned long lpcr;