Skip to content

Commit 50d2f10

Browse files
chleroympe
authored andcommitted
powerpc/32s: Allow disabling KUEP at boot time
PPC64 uses MMU features to enable/disable KUEP at boot time. But feature fixups are applied way too early on PPC32. Now that all KUEP related actions are in C following the conversion of KUEP initial setup and context switch in C, static branches can be used to enable/disable KUEP. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/7745a2c3a08ec46302920a3f48d1cb9b5469dbbb.1622708530.git.christophe.leroy@csgroup.eu
1 parent 86f46f3 commit 50d2f10

File tree

2 files changed

+12
-5
lines changed
  • arch/powerpc

2 files changed

+12
-5
lines changed

arch/powerpc/include/asm/book3s/32/kup.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77

88
#ifndef __ASSEMBLY__
99

10+
#include <linux/jump_label.h>
11+
12+
extern struct static_key_false disable_kuep_key;
13+
1014
static __always_inline bool kuap_is_disabled(void)
1115
{
1216
return !IS_ENABLED(CONFIG_PPC_KUAP);
1317
}
1418

1519
static __always_inline bool kuep_is_disabled(void)
1620
{
17-
return !IS_ENABLED(CONFIG_PPC_KUEP);
21+
return !IS_ENABLED(CONFIG_PPC_KUEP) || static_branch_unlikely(&disable_kuep_key);
1822
}
1923

2024
static inline void kuep_lock(void)

arch/powerpc/mm/book3s32/kuep.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
#include <asm/kup.h>
44
#include <asm/smp.h>
55

6+
struct static_key_false disable_kuep_key;
7+
68
void __init setup_kuep(bool disabled)
79
{
8-
kuep_lock();
10+
if (!disabled)
11+
kuep_lock();
912

1013
if (smp_processor_id() != boot_cpuid)
1114
return;
1215

13-
pr_info("Activating Kernel Userspace Execution Prevention\n");
14-
1516
if (disabled)
16-
pr_warn("KUEP cannot be disabled yet on 6xx when compiled in\n");
17+
static_branch_enable(&disable_kuep_key);
18+
else
19+
pr_info("Activating Kernel Userspace Execution Prevention\n");
1720
}

0 commit comments

Comments
 (0)