summaryrefslogtreecommitdiff
path: root/arch/powerpc/mm
diff options
context:
space:
mode:
authorChristophe Leroy <christophe.leroy@csgroup.eu>2021-06-03 08:41:43 +0000
committerMichael Ellerman <mpe@ellerman.id.au>2021-06-17 00:09:08 +1000
commit6b4d630068b0c5cdd6d8e599182b131448e0cb06 (patch)
tree4a1ceca50d4db3cb5dd4c5e0e0abdd68ff525b71 /arch/powerpc/mm
parent50d2f104cd9572af476579eae9aa1b38de602ec7 (diff)
powerpc/32s: Allow disabling KUAP at boot time
PPC64 uses MMU features to enable/disable KUAP at boot time. But feature fixups are applied way too early on PPC32. Now that all KUAP related actions are in C following the conversion of KUAP initial setup and context switch in C, static branches can be used to enable/disable KUAP. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> [mpe: Export disable_kuap_key to fix build errors] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/cd79e8008455fba5395d099f9bb1305c039b931c.1622708530.git.christophe.leroy@csgroup.eu
Diffstat (limited to 'arch/powerpc/mm')
-rw-r--r--arch/powerpc/mm/book3s32/kuap.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/arch/powerpc/mm/book3s32/kuap.c b/arch/powerpc/mm/book3s32/kuap.c
index 5533ed92ab3d..0e59c8b32c4f 100644
--- a/arch/powerpc/mm/book3s32/kuap.c
+++ b/arch/powerpc/mm/book3s32/kuap.c
@@ -3,15 +3,19 @@
#include <asm/kup.h>
#include <asm/smp.h>
+struct static_key_false disable_kuap_key;
+EXPORT_SYMBOL(disable_kuap_key);
+
void __init setup_kuap(bool disabled)
{
- kuap_update_sr(mfsr(0) | SR_KS, 0, TASK_SIZE);
+ if (!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)
- pr_warn("KUAP cannot be disabled yet on 6xx when compiled in\n");
+ static_branch_enable(&disable_kuap_key);
+ else
+ pr_info("Activating Kernel Userspace Access Protection\n");
}