summary refs log tree commit diff
path: root/arch/powerpc/mm
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2021-06-02 06:42:10 +0000
committerMichael Ellerman <mpe@ellerman.id.au>2021-06-17 00:09:07 +1000
commit10248dcba1205042a3a0ea65eb441030702d97cd (patch)
tree47e29ca6d4f4828409d3c64d9a4f5493d13608fa /arch/powerpc/mm
parentc0ca0fe08c9213a5187e4513b5506667f249030f (diff)
downloadlinux-10248dcba1205042a3a0ea65eb441030702d97cd.tar.gz
powerpc/44x: Implement Kernel Userspace Exec Protection (KUEP)
Powerpc 44x has two bits for exec protection in TLBs: one
for user (UX) and one for superviser (SX).

Clear SX on user pages in TLB miss handlers to provide KUEP.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/169310e08152aa1d96c979770291d165ec6896ae.1622616032.git.christophe.leroy@csgroup.eu

Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r--arch/powerpc/mm/nohash/44x.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/powerpc/mm/nohash/44x.c b/arch/powerpc/mm/nohash/44x.c
index 3d6ae7c72412..7da6d1e9fc9b 100644
--- a/arch/powerpc/mm/nohash/44x.c
+++ b/arch/powerpc/mm/nohash/44x.c
@@ -239,3 +239,16 @@ void __init mmu_init_secondary(int cpu)
 	}
 }
 #endif /* CONFIG_SMP */
+
+#ifdef CONFIG_PPC_KUEP
+void __init setup_kuep(bool disabled)
+{
+	if (disabled)
+		patch_instruction_site(&patch__tlb_44x_kuep, ppc_inst(PPC_RAW_NOP()));
+	else
+		pr_info("Activating Kernel Userspace Execution Prevention\n");
+
+	if (IS_ENABLED(CONFIG_PPC_47x) && disabled)
+		patch_instruction_site(&patch__tlb_47x_kuep, ppc_inst(PPC_RAW_NOP()));
+}
+#endif