Skip to content

Commit 6f3a81b

Browse files
chleroympe
authored andcommitted
powerpc/code-patching: Remove protection against patching init addresses after init
Once init section is freed, attempting to patch init code ends up in the weed. Commit 51c3c62 ("powerpc: Avoid code patching freed init sections") protected patch_instruction() against that, but it is the responsibility of the caller to ensure that the patched memory is valid. All callers have now been verified and fixed so the check can be removed. This improves ftrace activation by about 2% on 8xx. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/504310828f473d424e2ed229eff57bf075f52796.1669969781.git.christophe.leroy@csgroup.eu
1 parent b988e77 commit 6f3a81b

File tree

3 files changed

+1
-15
lines changed

3 files changed

+1
-15
lines changed

arch/powerpc/include/asm/code-patching.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#define BRANCH_SET_LINK 0x1
2323
#define BRANCH_ABSOLUTE 0x2
2424

25-
DECLARE_STATIC_KEY_FALSE(init_mem_is_free);
26-
2725
/*
2826
* Powerpc branch instruction is :
2927
*

arch/powerpc/lib/code-patching.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static int __do_patch_instruction(u32 *addr, ppc_inst_t instr)
349349
return err;
350350
}
351351

352-
static int do_patch_instruction(u32 *addr, ppc_inst_t instr)
352+
int patch_instruction(u32 *addr, ppc_inst_t instr)
353353
{
354354
int err;
355355
unsigned long flags;
@@ -372,17 +372,6 @@ static int do_patch_instruction(u32 *addr, ppc_inst_t instr)
372372

373373
return err;
374374
}
375-
376-
__ro_after_init DEFINE_STATIC_KEY_FALSE(init_mem_is_free);
377-
378-
int patch_instruction(u32 *addr, ppc_inst_t instr)
379-
{
380-
/* Make sure we aren't patching a freed init section */
381-
if (static_branch_likely(&init_mem_is_free) && init_section_contains(addr, 4))
382-
return 0;
383-
384-
return do_patch_instruction(addr, instr);
385-
}
386375
NOKPROBE_SYMBOL(patch_instruction);
387376

388377
int patch_branch(u32 *addr, unsigned long target, int flags)

arch/powerpc/mm/mem.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,6 @@ void free_initmem(void)
344344
{
345345
ppc_md.progress = ppc_printk_progress;
346346
mark_initmem_nx();
347-
static_branch_enable(&init_mem_is_free);
348347
free_initmem_default(POISON_FREE_INITMEM);
349348
ftrace_free_init_tramp();
350349
}

0 commit comments

Comments
 (0)