Skip to content

Commit 84ecfe6

Browse files
chleroympe
authored andcommitted
powerpc/code-patching: Remove #ifdef CONFIG_STRICT_KERNEL_RWX
No need to have one implementation of patch_instruction() for CONFIG_STRICT_KERNEL_RWX and one for !CONFIG_STRICT_KERNEL_RWX. In patch_instruction(), call raw_patch_instruction() when !CONFIG_STRICT_KERNEL_RWX. In poking_init(), bail out immediately, it will be equivalent to the weak default implementation. Everything else is declared static and will be discarded by GCC when !CONFIG_STRICT_KERNEL_RWX. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/f67d2a109404d03e8fdf1ea15388c8778337a76b.1669969781.git.christophe.leroy@csgroup.eu
1 parent ad050d2 commit 84ecfe6

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

arch/powerpc/lib/code-patching.c

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ int raw_patch_instruction(u32 *addr, ppc_inst_t instr)
4646
return __patch_instruction(addr, instr, addr);
4747
}
4848

49-
#ifdef CONFIG_STRICT_KERNEL_RWX
50-
5149
struct patch_context {
5250
union {
5351
struct vm_struct *area;
@@ -208,6 +206,9 @@ void __init poking_init(void)
208206
{
209207
int ret;
210208

209+
if (!IS_ENABLED(CONFIG_STRICT_KERNEL_RWX))
210+
return;
211+
211212
if (mm_patch_enabled())
212213
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN,
213214
"powerpc/text_poke_mm:online",
@@ -358,7 +359,8 @@ static int do_patch_instruction(u32 *addr, ppc_inst_t instr)
358359
* when text_poke_area is not ready, but we still need
359360
* to allow patching. We just do the plain old patching
360361
*/
361-
if (!static_branch_likely(&poking_init_done))
362+
if (!IS_ENABLED(CONFIG_STRICT_KERNEL_RWX) ||
363+
!static_branch_likely(&poking_init_done))
362364
return raw_patch_instruction(addr, instr);
363365

364366
local_irq_save(flags);
@@ -370,14 +372,6 @@ static int do_patch_instruction(u32 *addr, ppc_inst_t instr)
370372

371373
return err;
372374
}
373-
#else /* !CONFIG_STRICT_KERNEL_RWX */
374-
375-
static int do_patch_instruction(u32 *addr, ppc_inst_t instr)
376-
{
377-
return raw_patch_instruction(addr, instr);
378-
}
379-
380-
#endif /* CONFIG_STRICT_KERNEL_RWX */
381375

382376
__ro_after_init DEFINE_STATIC_KEY_FALSE(init_mem_is_free);
383377

0 commit comments

Comments
 (0)