summaryrefslogtreecommitdiff
path: root/arch/powerpc/mm/book3s32
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2021-06-03 11:41:41 +0300
committerMichael Ellerman <mpe@ellerman.id.au>2021-06-16 17:09:08 +0300
commit86f46f3432727933be82f64b739712a6edb9d704 (patch)
tree4797bb3b570922ef556c49f012a72d1aaff8c033 /arch/powerpc/mm/book3s32
parent882136fb2f5208a35ddad9205b20e5791edd4782 (diff)
downloadlinux-86f46f3432727933be82f64b739712a6edb9d704.tar.xz
powerpc/32s: Initialise KUAP and KUEP in C
In order to selectively activate KUAP and KUEP in a following patch, perform KUAP and KUEP initialisation in C. Unlike PPC64, PPC32 doesn't have an early_setup_secondary(), so do it in start_secondary(). Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/87be72023448dd4e476744ed279b8c04b8d08a1c.1622708530.git.christophe.leroy@csgroup.eu
Diffstat (limited to 'arch/powerpc/mm/book3s32')
-rw-r--r--arch/powerpc/mm/book3s32/kuap.c6
-rw-r--r--arch/powerpc/mm/book3s32/kuep.c6
2 files changed, 12 insertions, 0 deletions
diff --git a/arch/powerpc/mm/book3s32/kuap.c b/arch/powerpc/mm/book3s32/kuap.c
index 1df55392878e..5533ed92ab3d 100644
--- a/arch/powerpc/mm/book3s32/kuap.c
+++ b/arch/powerpc/mm/book3s32/kuap.c
@@ -1,9 +1,15 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <asm/kup.h>
+#include <asm/smp.h>
void __init setup_kuap(bool disabled)
{
+ kuap_update_sr(mfsr(0) | SR_KS, 0, TASK_SIZE);
+
+ if (smp_processor_id() != boot_cpuid)
+ return;
+
pr_info("Activating Kernel Userspace Access Protection\n");
if (disabled)
diff --git a/arch/powerpc/mm/book3s32/kuep.c b/arch/powerpc/mm/book3s32/kuep.c
index 919595f47e25..3147e2edcf63 100644
--- a/arch/powerpc/mm/book3s32/kuep.c
+++ b/arch/powerpc/mm/book3s32/kuep.c
@@ -1,9 +1,15 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <asm/kup.h>
+#include <asm/smp.h>
void __init setup_kuep(bool disabled)
{
+ kuep_lock();
+
+ if (smp_processor_id() != boot_cpuid)
+ return;
+
pr_info("Activating Kernel Userspace Execution Prevention\n");
if (disabled)