powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller
PATCH 1/1 powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller
Commit 7dfbfb87c243 ("powerpc/ftrace: Activate HAVE_DYNAMIC_FTRACE_WITH_REGS on PPC32") made count_relocs() undercount the PLT entries the loader
consumes: module_finalize_ftrace() now creates two trampolines (mod->arch.tramp for ftrace_caller() and mod->arch.tramp_regs for ftrace_regs_caller()), while count_relocs() reserves only one entry for ftrace.
So the core .plt ends up one ppc_plt_entry (16 bytes) short. The walk in do_plt_call() scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last reserved slot is used up, the walk steps past the end of the section and patch_instruction() writes the 4-instruction trampoline into whatever module memory follows the .plt.
Count the second entry, mirroring what module_64.c does for the same pair of stubs.
--- arch/powerpc/kernel/module_32.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/kernel/module_32.c +3 -0
@@ -41,6 +41,9 @@ static unsigned int count_relocs(const Elf32_Rela *rela, unsigned int num)#ifdef CONFIG_DYNAMIC_FTRACE _count_relocs++;/* add one for ftrace_caller */ +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS + _count_relocs++;/* add one for ftrace_regs_caller */ +#endif #endif return _count_relocs; }
Signature · 1 line
2.53.0
Le 23/09/2026 à 19:56, Bradley Morgan a écrit :
Quoted 15 lines
Commit
7dfbfb87c243("powerpc/ftrace: ActivateHAVE_DYNAMIC_FTRACE_WITH_REGSon PPC32") madecount_relocs()undercount the PLT entries the loader
consumes:module_finalize_ftrace()now creates two trampolines (mod->arch.trampforftrace_caller()andmod->arch.tramp_regsforftrace_regs_caller()), whilecount_relocs()reserves only one entry for ftrace.So the core .plt ends up one
ppc_plt_entry(16 bytes) short. The walk indo_plt_call()scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last reserved slot is used up, the walk steps past the end of the section andpatch_instruction()writes the 4-instruction trampoline into whatever module memory follows the .plt.
Quoted 4 lines
Count the second entry, mirroring what
module_64.cdoes for the same pair of stubs.Signed-off-by Bradley Morgan <[email protected]>
I would have had a preference for something similar to commit c12cfe9dee07 ("powerpc/module_64: Convert #ifdef to IS_ENABLED()")
Nevertheless,
Quoted 18 lines
--- arch/powerpc/kernel/module_32.c | 3 +++ 1 file changed, 3 insertions(+)arch/powerpc/kernel/module_32.c +3
-0@@ -41,6 +41,9 @@ static unsigned int count_relocs(const Elf32_Rela *rela, unsigned int num)#ifdef CONFIG_DYNAMIC_FTRACE _count_relocs++;/* add one for ftrace_caller */ +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS + _count_relocs++;/* add one for ftrace_regs_caller */ +#endif #endif return _count_relocs; }
Quoted 21 lines · Christophe Leroy (CS GROUP)
Le 23/09/2026 à 19:56, Bradley Morgan a écrit :
Quoted 18 lines
Commit
7dfbfb87c243("powerpc/ftrace: ActivateHAVE_DYNAMIC_FTRACE_WITH_REGSon PPC32") madecount_relocs()undercount the PLT entries the loader
consumes:module_finalize_ftrace()now creates two trampolines (mod->arch.trampforftrace_caller()andmod->arch.tramp_regsforftrace_regs_caller()), whilecount_relocs()reserves only one entry for ftrace.So the core .plt ends up one
ppc_plt_entry(16 bytes) short. The walk indo_plt_call()scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last reserved slot is used up, the walk steps past the end of the section andpatch_instruction()writes the 4-instruction trampoline into whatever module memory follows the .plt.Count the second entry, mirroring what
module_64.cdoes for the same pair of stubs.
Quoted 8 lines
Quoted 1 line
Signed-off-by Bradley Morgan <[email protected]>I would have had a preference for something similar to commit
c12cfe9dee07("powerpc/module_64: Convert #ifdef toIS_ENABLED()")Nevertheless,
Reviewed-by Christophe Leroy (CS GROUP) <[email protected]>
Thx, now the good question will be, who merges?
Quoted 14 lines
Review
Quoted 8 lines
--- arch/powerpc/kernel/module_32.c | 3 +++ 1 file changed, 3 insertions(+)(quoted diff) +0
-0
b/arch/powerpc/kernel/module_32.carch/powerpc/kernel/module_32.c static unsigned int count_relocs(const Elf32_Rela
Quoted 4 lines
index
f930e3395a7f..61152deffc55100644arch/powerpc/kernel/module_32.c +0
-0@@ -41,6 +41,9 @@ static unsigned int count_relocs(const Elf32_Rela*rela, unsigned int num)
Quoted 9 lines
arch/powerpc/kernel/module_32.c static unsigned int count_relocs(const Elf32_Rela *rela, unsigned int num) · line 49
Quoted 8 lines
arch/powerpc/kernel/module_32.c +3
-0#ifdef CONFIG_DYNAMIC_FTRACE _count_relocs++;/* add one for ftrace_caller */ +#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS + _count_relocs++;/* add one for ftrace_regs_caller */ +#endif #endif return _count_relocs; }
--- Thanks!
Ritesh Harjani (IBM)
reviewerQuoted 15 lines · Bradley Morgan
Commit
7dfbfb87c243("powerpc/ftrace: ActivateHAVE_DYNAMIC_FTRACE_WITH_REGSon PPC32") madecount_relocs()undercount the PLT entries the loader
consumes:module_finalize_ftrace()now creates two trampolines (mod->arch.trampforftrace_caller()andmod->arch.tramp_regsforftrace_regs_caller()), whilecount_relocs()reserves only one entry for ftrace.So the core .plt ends up one
ppc_plt_entry(16 bytes) short. The walk indo_plt_call()scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last reserved slot is used up, the walk steps past the end of the section andpatch_instruction()writes the 4-instruction trampoline into whatever module memory follows the .plt.
Quoted 8 lines
Count the second entry, mirroring what
module_64.cdoes for the same pair of stubs.Signed-off-by Bradley Morgan <[email protected]>--- arch/powerpc/kernel/module_32.c | 3 +++ 1 file changed, 3 insertions(+)
Do we also need fixes and stable tag here?
-ritesh
Quoted 26 lines · Ritesh Harjani
Quoted 15 lines · Bradley Morgan
Commit
7dfbfb87c243("powerpc/ftrace: ActivateHAVE_DYNAMIC_FTRACE_WITH_REGSon PPC32") madecount_relocs()undercount the PLT entries the loader
consumes:module_finalize_ftrace()now creates two trampolines (mod->arch.trampforftrace_caller()andmod->arch.tramp_regsforftrace_regs_caller()), whilecount_relocs()reserves only one entry for ftrace.So the core .plt ends up one
ppc_plt_entry(16 bytes) short. The walk indo_plt_call()scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last reserved slot is used up, the walk steps past the end of the section andpatch_instruction()writes the 4-instruction trampoline into whatever module memory follows the .plt.Quoted 8 lines
Count the second entry, mirroring what
module_64.cdoes for the same pair of stubs.Signed-off-by Bradley Morgan <[email protected]>--- arch/powerpc/kernel/module_32.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 4 lines
Do we also need fixes and stable tag here?
Fixes 7dfbfb87c243 ("powerpc/ftrace: Activate HAVE_DYNAMIC_FTRACE_WITH_REGS on PPC32")
Hmm.. could the merger add that? If anyone merges.. :(
Quoted 4 lines
-ritesh
--- Thanks!
Madhavan Srinivasan
maintainerQuoted 27 lines · Bradley Morgan
Quoted 25 lines · Ritesh Harjani
Quoted 23 lines · Bradley Morgan
Commit
7dfbfb87c243("powerpc/ftrace: ActivateHAVE_DYNAMIC_FTRACE_WITH_REGSon PPC32") madecount_relocs()undercount the PLT entries the loader
consumes:module_finalize_ftrace()now creates two trampolines (mod->arch.trampforftrace_caller()andmod->arch.tramp_regsforftrace_regs_caller()), whilecount_relocs()reserves only one entry for ftrace.So the core .plt ends up one
ppc_plt_entry(16 bytes) short. The walk indo_plt_call()scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last reserved slot is used up, the walk steps past the end of the section andpatch_instruction()writes the 4-instruction trampoline into whatever module memory follows the .plt.Count the second entry, mirroring what
module_64.cdoes for the same pair of stubs.Signed-off-by Bradley Morgan <[email protected]>--- arch/powerpc/kernel/module_32.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 5 lines
Quoted 4 lines
Do we also need fixes and stable tag here?
Fixes 7dfbfb87c243 ("powerpc/ftrace: Activate HAVE_DYNAMIC_FTRACE_WITH_REGS on PPC32")Hmm.. could the merger add that? If anyone merges.. :(
planned to be part of my fixes PR and will add it. Thanks for the fix.
Maddy
Quoted 4 lines
Quoted 3 lines
-ritesh
--- Thanks!
Quoted 29 lines · Madhavan Srinivasan
Quoted 27 lines · Bradley Morgan
Quoted 25 lines · Ritesh Harjani
Quoted 23 lines · Bradley Morgan
Commit
7dfbfb87c243("powerpc/ftrace: ActivateHAVE_DYNAMIC_FTRACE_WITH_REGSon PPC32") madecount_relocs()undercount the PLT entries the loader
consumes:module_finalize_ftrace()now creates two trampolines (mod->arch.trampforftrace_caller()andmod->arch.tramp_regsforftrace_regs_caller()), whilecount_relocs()reserves only one entry for ftrace.So the core .plt ends up one
ppc_plt_entry(16 bytes) short. The walk indo_plt_call()scans for a free slot with
"while (entry->jump[0])" and has no bound check, so once the last reserved slot is used up, the walk steps past the end of the section andpatch_instruction()writes the 4-instruction trampoline into whatever module memory follows the .plt.Count the second entry, mirroring what
module_64.cdoes for the same pair of stubs.Signed-off-by Bradley Morgan <[email protected]>--- arch/powerpc/kernel/module_32.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
Do we also need fixes and stable tag here?
Fixes 7dfbfb87c243 ("powerpc/ftrace: Activate
HAVE_DYNAMIC_FTRACE_WITH_REGSon PPC32")Quoted 2 lines
Quoted 1 line
Hmm.. could the merger add that? If anyone merges.. :(
planned to be part of my fixes PR and will add it. Thanks for the fix.
No worries, mind changing sob to this email?
Quoted 7 lines
Maddy
Quoted 4 lines
Quoted 3 lines
-ritesh
--- Thanks!
--- Thanks!
Quoted 9 lines · Bradley Morgan
Commit
7dfbfb87c243("powerpc/ftrace: ActivateHAVE_DYNAMIC_FTRACE_WITH_REGSon PPC32") madecount_relocs()undercount the PLT entries the loader
consumes:module_finalize_ftrace()now creates two trampolines (mod->arch.trampforftrace_caller()andmod->arch.tramp_regsforftrace_regs_caller()), whilecount_relocs()reserves only one entry for ftrace.[...]
Applied to powerpc/fixes.
[1/1] powerpc32/modules: Reserve a PLT entry for ftrace_regs_caller
https://git.kernel.org/powerpc/c/dc6eb6f08be536223e8289c7a8b1f515b1355721
cheers