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: Prepare arch_static_call_transform() for supporting inline static calls

Reorganise arch_static_call_transform() in order to ease the support
of inline static calls in following patch:
- remove 'target' to nhide whether it is a 'return 0' or not.
- Don't bail out if 'tramp' is NULL, just do nothing until next patch.

Note that 'target' was 'tramp + PPC_SCT_RET0', is_short was perforce
true. So in the 'if (func && !is_short)' leg, target was perforce
equal to 'func'.

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

authored by

Christophe Leroy and committed by
Madhavan Srinivasan
6626f98e bb7f054f

+21 -15
+21 -15
arch/powerpc/kernel/static_call.c
··· 8 8 { 9 9 int err; 10 10 bool is_ret0 = (func == __static_call_return0); 11 - unsigned long target = (unsigned long)(is_ret0 ? tramp + PPC_SCT_RET0 : func); 12 - bool is_short = is_offset_in_branch_range((long)target - (long)tramp); 13 - 14 - if (!tramp) 15 - return; 11 + unsigned long _tramp = (unsigned long)tramp; 12 + unsigned long _func = (unsigned long)func; 13 + unsigned long _ret0 = _tramp + PPC_SCT_RET0; 14 + bool is_short = is_offset_in_branch_range((long)func - (long)(site ? : tramp)); 16 15 17 16 mutex_lock(&text_mutex); 18 17 19 - if (func && !is_short) { 20 - err = patch_ulong(tramp + PPC_SCT_DATA, target); 21 - if (err) 22 - goto out; 18 + if (tramp) { 19 + if (func && !is_short) { 20 + err = patch_ulong(tramp + PPC_SCT_DATA, _func); 21 + if (err) 22 + goto out; 23 + } 24 + 25 + if (!func) 26 + err = patch_instruction(tramp, ppc_inst(PPC_RAW_BLR())); 27 + else if (is_ret0) 28 + err = patch_branch(tramp, _ret0, 0); 29 + else if (is_short) 30 + err = patch_branch(tramp, _func, 0); 31 + else 32 + err = patch_instruction(tramp, ppc_inst(PPC_RAW_NOP())); 33 + } else { 34 + err = 0; 23 35 } 24 36 25 - if (!func) 26 - err = patch_instruction(tramp, ppc_inst(PPC_RAW_BLR())); 27 - else if (is_short) 28 - err = patch_branch(tramp, target, 0); 29 - else 30 - err = patch_instruction(tramp, ppc_inst(PPC_RAW_NOP())); 31 37 out: 32 38 mutex_unlock(&text_mutex); 33 39