Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

powerpc/static_call: Implement inline static calls

Implement inline static calls:
- Put a 'bl' to the destination function ('b' if tail call)
- Put a 'nop' when the destination function is NULL ('blr' if tail call)
- Put a 'li r3,0' when the destination is the RET0 function and not
a tail call.

If the destination is too far (over the 32Mb limit), go via the
trampoline.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/3dbd0b2ba577c942729235d0211d04a406653d81.1733245362.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Madhavan Srinivasan
f50b4562 6626f98e

+26 -1
+1
arch/powerpc/Kconfig
··· 286 286 select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,$(m32-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0) 287 287 select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,$(m64-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -mstack-protector-guard-offset=0) 288 288 select HAVE_STATIC_CALL if PPC32 289 + select HAVE_STATIC_CALL_INLINE if PPC32 289 290 select HAVE_SYSCALL_TRACEPOINTS 290 291 select HAVE_VIRT_CPU_ACCOUNTING 291 292 select HAVE_VIRT_CPU_ACCOUNTING_GEN
+2
arch/powerpc/include/asm/static_call.h
··· 26 26 #define ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) __PPC_SCT(name, "blr") 27 27 #define ARCH_DEFINE_STATIC_CALL_RET0_TRAMP(name) __PPC_SCT(name, "b .+20") 28 28 29 + #define CALL_INSN_SIZE 4 30 + 29 31 #endif /* _ASM_POWERPC_STATIC_CALL_H */
+23 -1
arch/powerpc/kernel/static_call.c
··· 15 15 16 16 mutex_lock(&text_mutex); 17 17 18 - if (tramp) { 18 + if (site && tail) { 19 + if (!func) 20 + err = patch_instruction(site, ppc_inst(PPC_RAW_BLR())); 21 + else if (is_ret0) 22 + err = patch_branch(site, _ret0, 0); 23 + else if (is_short) 24 + err = patch_branch(site, _func, 0); 25 + else if (tramp) 26 + err = patch_branch(site, _tramp, 0); 27 + else 28 + err = 0; 29 + } else if (site) { 30 + if (!func) 31 + err = patch_instruction(site, ppc_inst(PPC_RAW_NOP())); 32 + else if (is_ret0) 33 + err = patch_instruction(site, ppc_inst(PPC_RAW_LI(_R3, 0))); 34 + else if (is_short) 35 + err = patch_branch(site, _func, BRANCH_SET_LINK); 36 + else if (tramp) 37 + err = patch_branch(site, _tramp, BRANCH_SET_LINK); 38 + else 39 + err = 0; 40 + } else if (tramp) { 19 41 if (func && !is_short) { 20 42 err = patch_ulong(tramp + PPC_SCT_DATA, _func); 21 43 if (err)