powerpc/kuep: Remove 'nosmep' boot time parameter except for book3s/64
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Tue, 19 Oct 2021 07:29:19 +0000 (09:29 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 9 Dec 2021 11:41:18 +0000 (22:41 +1100)
Deactivating KUEP at boot time is unrelevant for PPC32 and BOOK3E/64.

Remove it.

It allows to refactor setup_kuep() via a __weak function
that only PPC64s will overide for now.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
[mpe: Fix CONFIG_PPC_BOOKS_64 -> CONFIG_PPC_BOOK3S_64 typo]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/4c36df18b41c988c4512f45d96220486adbe4c99.1634627931.git.christophe.leroy@csgroup.eu
Documentation/admin-guide/kernel-parameters.txt
arch/powerpc/include/asm/kup.h
arch/powerpc/mm/book3s32/Makefile
arch/powerpc/mm/book3s32/kuep.c [deleted file]
arch/powerpc/mm/init-common.c
arch/powerpc/mm/nohash/44x.c
arch/powerpc/mm/nohash/8xx.c

index 6248a061788a6898bc9ee470f4d1e5582c380db9..83d558de56d43a6df438b640acf022494389c341 100644 (file)
                        Disable SMAP (Supervisor Mode Access Prevention)
                        even if it is supported by processor.
 
-       nosmep          [X86,PPC]
+       nosmep          [X86,PPC64s]
                        Disable SMEP (Supervisor Mode Execution Prevention)
                        even if it is supported by processor.
 
index 94734a8eb54d3cc66aa28110855e35cf29740a01..fa8513b7accab25d968cb85c14d666ce75ad0b3e 100644 (file)
@@ -33,12 +33,7 @@ extern bool disable_kuap;
 #include <linux/pgtable.h>
 
 void setup_kup(void);
-
-#ifdef CONFIG_PPC_KUEP
 void setup_kuep(bool disabled);
-#else
-static inline void setup_kuep(bool disabled) { }
-#endif /* CONFIG_PPC_KUEP */
 
 #ifdef CONFIG_PPC_KUAP
 void setup_kuap(bool disabled);
index 15f4773643d2198f85757fda5fe653b51473a6ac..50dd8f6bdf46a0517392a0411b0db4c14f5ac4c9 100644 (file)
@@ -9,5 +9,4 @@ endif
 obj-y += mmu.o mmu_context.o
 obj-$(CONFIG_PPC_BOOK3S_603) += nohash_low.o
 obj-$(CONFIG_PPC_BOOK3S_604) += hash_low.o tlb.o
-obj-$(CONFIG_PPC_KUEP) += kuep.o
 obj-$(CONFIG_PPC_KUAP) += kuap.o
diff --git a/arch/powerpc/mm/book3s32/kuep.c b/arch/powerpc/mm/book3s32/kuep.c
deleted file mode 100644 (file)
index 78fc48e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#include <asm/code-patching.h>
-#include <asm/kup.h>
-#include <asm/smp.h>
-
-void setup_kuep(bool disabled)
-{
-       if (smp_processor_id() != boot_cpuid)
-               return;
-
-       pr_info("Activating Kernel Userspace Execution Prevention\n");
-}
index b4f3437aee3812aee97d94ab6c4260859bf600f9..119ef491f79760ca071b5fd22bf6b1e00b9d11d8 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/pgtable.h>
 #include <asm/pgalloc.h>
 #include <asm/kup.h>
+#include <asm/smp.h>
 
 phys_addr_t memstart_addr __ro_after_init = (phys_addr_t)~0ull;
 EXPORT_SYMBOL_GPL(memstart_addr);
@@ -33,6 +34,9 @@ bool disable_kuap = !IS_ENABLED(CONFIG_PPC_KUAP);
 
 static int __init parse_nosmep(char *p)
 {
+       if (!IS_ENABLED(CONFIG_PPC_BOOK3S_64))
+               return 0;
+
        disable_kuep = true;
        pr_warn("Disabling Kernel Userspace Execution Prevention\n");
        return 0;
@@ -47,6 +51,17 @@ static int __init parse_nosmap(char *p)
 }
 early_param("nosmap", parse_nosmap);
 
+void __weak setup_kuep(bool disabled)
+{
+       if (!IS_ENABLED(CONFIG_PPC_KUEP) || disabled)
+               return;
+
+       if (smp_processor_id() != boot_cpuid)
+               return;
+
+       pr_info("Activating Kernel Userspace Execution Prevention\n");
+}
+
 void setup_kup(void)
 {
        setup_kuap(disable_kuap);
index ceb290df1fb562c6d93409b962c5e7a21a94a2ed..796c824acc8cef9e90def637885a5d5070c03b4d 100644 (file)
@@ -240,13 +240,3 @@ void __init mmu_init_secondary(int cpu)
        }
 }
 #endif /* CONFIG_SMP */
-
-#ifdef CONFIG_PPC_KUEP
-void setup_kuep(bool disabled)
-{
-       if (smp_processor_id() != boot_cpuid)
-               return;
-
-       pr_info("Activating Kernel Userspace Execution Prevention\n");
-}
-#endif
index e878e8124ee674dbb91facd36e27cdf786dff72d..36010d1c0bc4cd6269c0518398594032c95d8054 100644 (file)
@@ -212,13 +212,6 @@ void __init setup_initial_memory_limit(phys_addr_t first_memblock_base,
        memblock_set_current_limit(min_t(u64, first_memblock_size, SZ_32M));
 }
 
-#ifdef CONFIG_PPC_KUEP
-void setup_kuep(bool disabled)
-{
-       pr_info("Activating Kernel Userspace Execution Prevention\n");
-}
-#endif
-
 #ifdef CONFIG_PPC_KUAP
 struct static_key_false disable_kuap_key;
 EXPORT_SYMBOL(disable_kuap_key);