* [PATCH v4 0/4] Implement inline static calls on PPC32 - v4
@ 2024-12-03 19:44 Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 1/4] static_call_inline: Provide trampoline address when updating sites Christophe Leroy
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Christophe Leroy @ 2024-12-03 19:44 UTC (permalink / raw)
To: Shrikanth Hegde, Peter Zijlstra, Josh Poimboeuf, Jason Baron,
Steven Rostedt, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Michael Ellerman, Nicholas Piggin, Naveen N Rao,
Madhavan Srinivasan
Cc: Christophe Leroy, linux-kernel, linuxppc-dev
This series implements inline static calls on PPC32.
First patch adds to static_call core the ability to pass the
trampoline address at the same time as the site address to
arch_static_call_transform() so that it can fallback on branching to
the trampoline when the site is too far (Max distance for direct
branch is 32 Mbytes on powerpc).
Second patch adds support for decoding all types of uncond branches.
Third patch rearranges function arch_static_call_transform() to ease
implementation of inline static call in following patch.
Last patch implements inline static calls on PPC32: This is done by:
- 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 thanks to patch 1.
Christophe Leroy (4):
static_call_inline: Provide trampoline address when updating sites
objtool/powerpc: Add support for decoding all types of uncond branches
powerpc: Prepare arch_static_call_transform() for supporting inline
static calls
powerpc/static_call: Implement inline static calls
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/static_call.h | 2 +
arch/powerpc/kernel/static_call.c | 58 +++++++++++++++++++-------
arch/x86/kernel/static_call.c | 2 +-
kernel/static_call_inline.c | 2 +-
tools/objtool/arch/powerpc/decode.c | 8 +++-
6 files changed, 55 insertions(+), 18 deletions(-)
--
2.47.0
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4 1/4] static_call_inline: Provide trampoline address when updating sites
2024-12-03 19:44 [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Christophe Leroy
@ 2024-12-03 19:44 ` Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 2/4] objtool/powerpc: Add support for decoding all types of uncond branches Christophe Leroy
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Christophe Leroy @ 2024-12-03 19:44 UTC (permalink / raw)
To: Shrikanth Hegde, Peter Zijlstra, Josh Poimboeuf, Jason Baron,
Steven Rostedt, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Michael Ellerman, Nicholas Piggin, Naveen N Rao,
Madhavan Srinivasan
Cc: Christophe Leroy, linux-kernel, linuxppc-dev
In preparation of support of inline static calls on powerpc, provide
trampoline address when updating sites, so that when the destination
function is too far for a direct function call, the call site is
patched with a call to the trampoline.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/x86/kernel/static_call.c | 2 +-
kernel/static_call_inline.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/static_call.c b/arch/x86/kernel/static_call.c
index 4eefaac64c6c..00b2ea40cbef 100644
--- a/arch/x86/kernel/static_call.c
+++ b/arch/x86/kernel/static_call.c
@@ -158,7 +158,7 @@ void arch_static_call_transform(void *site, void *tramp, void *func, bool tail)
{
mutex_lock(&text_mutex);
- if (tramp) {
+ if (tramp && !site) {
__static_call_validate(tramp, true, true);
__static_call_transform(tramp, __sc_insn(!func, true), func, false);
}
diff --git a/kernel/static_call_inline.c b/kernel/static_call_inline.c
index 5259cda486d0..7fefbb3d8074 100644
--- a/kernel/static_call_inline.c
+++ b/kernel/static_call_inline.c
@@ -206,7 +206,7 @@ void __static_call_update(struct static_call_key *key, void *tramp, void *func)
continue;
}
- arch_static_call_transform(site_addr, NULL, func,
+ arch_static_call_transform(site_addr, tramp, func,
static_call_is_tail(site));
}
}
--
2.47.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 2/4] objtool/powerpc: Add support for decoding all types of uncond branches
2024-12-03 19:44 [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 1/4] static_call_inline: Provide trampoline address when updating sites Christophe Leroy
@ 2024-12-03 19:44 ` Christophe Leroy
2024-12-04 14:09 ` Segher Boessenkool
2025-02-25 8:05 ` [PATCH v5 " Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 3/4] powerpc: Prepare arch_static_call_transform() for supporting inline static calls Christophe Leroy
` (2 subsequent siblings)
4 siblings, 2 replies; 9+ messages in thread
From: Christophe Leroy @ 2024-12-03 19:44 UTC (permalink / raw)
To: Shrikanth Hegde, Peter Zijlstra, Josh Poimboeuf, Jason Baron,
Steven Rostedt, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Michael Ellerman, Nicholas Piggin, Naveen N Rao,
Madhavan Srinivasan
Cc: Christophe Leroy, linux-kernel, linuxppc-dev
Add support for 'bla' instruction.
This is done by 'flagging' the address as an absolute address so that
arch_jump_destination() can calculate it as expected. Because code is
_always_ 4 bytes aligned, use bit 30 as flag.
Also add support for 'b' and 'ba' instructions. Objtool call them jumps.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
tools/objtool/arch/powerpc/decode.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
index 53b55690f320..c1228fef3dec 100644
--- a/tools/objtool/arch/powerpc/decode.c
+++ b/tools/objtool/arch/powerpc/decode.c
@@ -55,12 +55,15 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
switch (opcode) {
case 18: /* b[l][a] */
- if ((ins & 3) == 1) /* bl */
+ if (ins & 1) /* bl[a] */
typ = INSN_CALL;
+ else /* b[a] */
+ typ = INSN_JUMP_UNCONDITIONAL;
imm = ins & 0x3fffffc;
if (imm & 0x2000000)
imm -= 0x4000000;
+ imm |= ins & 2; /* AA flag */
break;
}
@@ -77,6 +80,9 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
unsigned long arch_jump_destination(struct instruction *insn)
{
+ if (insn->immediate & 2)
+ return insn->immediate & ~2;
+
return insn->offset + insn->immediate;
}
--
2.47.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 3/4] powerpc: Prepare arch_static_call_transform() for supporting inline static calls
2024-12-03 19:44 [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 1/4] static_call_inline: Provide trampoline address when updating sites Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 2/4] objtool/powerpc: Add support for decoding all types of uncond branches Christophe Leroy
@ 2024-12-03 19:44 ` Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 4/4] powerpc/static_call: Implement " Christophe Leroy
2025-03-02 4:40 ` [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Madhavan Srinivasan
4 siblings, 0 replies; 9+ messages in thread
From: Christophe Leroy @ 2024-12-03 19:44 UTC (permalink / raw)
To: Shrikanth Hegde, Peter Zijlstra, Josh Poimboeuf, Jason Baron,
Steven Rostedt, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Michael Ellerman, Nicholas Piggin, Naveen N Rao,
Madhavan Srinivasan
Cc: Christophe Leroy, linux-kernel, linuxppc-dev
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>
---
arch/powerpc/kernel/static_call.c | 36 ++++++++++++++++++-------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/arch/powerpc/kernel/static_call.c b/arch/powerpc/kernel/static_call.c
index 7cfd0710e757..1b106fbcc567 100644
--- a/arch/powerpc/kernel/static_call.c
+++ b/arch/powerpc/kernel/static_call.c
@@ -8,26 +8,32 @@ void arch_static_call_transform(void *site, void *tramp, void *func, bool tail)
{
int err;
bool is_ret0 = (func == __static_call_return0);
- unsigned long target = (unsigned long)(is_ret0 ? tramp + PPC_SCT_RET0 : func);
- bool is_short = is_offset_in_branch_range((long)target - (long)tramp);
-
- if (!tramp)
- return;
+ unsigned long _tramp = (unsigned long)tramp;
+ unsigned long _func = (unsigned long)func;
+ unsigned long _ret0 = _tramp + PPC_SCT_RET0;
+ bool is_short = is_offset_in_branch_range((long)func - (long)(site ? : tramp));
mutex_lock(&text_mutex);
- if (func && !is_short) {
- err = patch_ulong(tramp + PPC_SCT_DATA, target);
- if (err)
- goto out;
+ if (tramp) {
+ if (func && !is_short) {
+ err = patch_ulong(tramp + PPC_SCT_DATA, _func);
+ if (err)
+ goto out;
+ }
+
+ if (!func)
+ err = patch_instruction(tramp, ppc_inst(PPC_RAW_BLR()));
+ else if (is_ret0)
+ err = patch_branch(tramp, _ret0, 0);
+ else if (is_short)
+ err = patch_branch(tramp, _func, 0);
+ else
+ err = patch_instruction(tramp, ppc_inst(PPC_RAW_NOP()));
+ } else {
+ err = 0;
}
- if (!func)
- err = patch_instruction(tramp, ppc_inst(PPC_RAW_BLR()));
- else if (is_short)
- err = patch_branch(tramp, target, 0);
- else
- err = patch_instruction(tramp, ppc_inst(PPC_RAW_NOP()));
out:
mutex_unlock(&text_mutex);
--
2.47.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v4 4/4] powerpc/static_call: Implement inline static calls
2024-12-03 19:44 [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Christophe Leroy
` (2 preceding siblings ...)
2024-12-03 19:44 ` [PATCH v4 3/4] powerpc: Prepare arch_static_call_transform() for supporting inline static calls Christophe Leroy
@ 2024-12-03 19:44 ` Christophe Leroy
2024-12-04 20:09 ` kernel test robot
2025-03-02 4:40 ` [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Madhavan Srinivasan
4 siblings, 1 reply; 9+ messages in thread
From: Christophe Leroy @ 2024-12-03 19:44 UTC (permalink / raw)
To: Shrikanth Hegde, Peter Zijlstra, Josh Poimboeuf, Jason Baron,
Steven Rostedt, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Michael Ellerman, Nicholas Piggin, Naveen N Rao,
Madhavan Srinivasan
Cc: Christophe Leroy, linux-kernel, linuxppc-dev
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>
---
arch/powerpc/Kconfig | 1 +
arch/powerpc/include/asm/static_call.h | 2 ++
arch/powerpc/kernel/static_call.c | 24 +++++++++++++++++++++++-
3 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index a0ce777f9706..285bc1ae17dd 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -282,6 +282,7 @@ config PPC
select HAVE_STACKPROTECTOR if PPC32 && $(cc-option,$(m32-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r2 -mstack-protector-guard-offset=0)
select HAVE_STACKPROTECTOR if PPC64 && $(cc-option,$(m64-flag) -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -mstack-protector-guard-offset=0)
select HAVE_STATIC_CALL if PPC32
+ select HAVE_STATIC_CALL_INLINE if PPC32
select HAVE_SYSCALL_TRACEPOINTS
select HAVE_VIRT_CPU_ACCOUNTING
select HAVE_VIRT_CPU_ACCOUNTING_GEN
diff --git a/arch/powerpc/include/asm/static_call.h b/arch/powerpc/include/asm/static_call.h
index de1018cc522b..e3d5d3823dac 100644
--- a/arch/powerpc/include/asm/static_call.h
+++ b/arch/powerpc/include/asm/static_call.h
@@ -26,4 +26,6 @@
#define ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name) __PPC_SCT(name, "blr")
#define ARCH_DEFINE_STATIC_CALL_RET0_TRAMP(name) __PPC_SCT(name, "b .+20")
+#define CALL_INSN_SIZE 4
+
#endif /* _ASM_POWERPC_STATIC_CALL_H */
diff --git a/arch/powerpc/kernel/static_call.c b/arch/powerpc/kernel/static_call.c
index 1b106fbcc567..ec3101f95e53 100644
--- a/arch/powerpc/kernel/static_call.c
+++ b/arch/powerpc/kernel/static_call.c
@@ -15,7 +15,29 @@ void arch_static_call_transform(void *site, void *tramp, void *func, bool tail)
mutex_lock(&text_mutex);
- if (tramp) {
+ if (site && tail) {
+ if (!func)
+ err = patch_instruction(site, ppc_inst(PPC_RAW_BLR()));
+ else if (is_ret0)
+ err = patch_branch(site, _ret0, 0);
+ else if (is_short)
+ err = patch_branch(site, _func, 0);
+ else if (tramp)
+ err = patch_branch(site, _tramp, 0);
+ else
+ err = 0;
+ } else if (site) {
+ if (!func)
+ err = patch_instruction(site, ppc_inst(PPC_RAW_NOP()));
+ else if (is_ret0)
+ err = patch_instruction(site, ppc_inst(PPC_RAW_LI(_R3, 0)));
+ else if (is_short)
+ err = patch_branch(site, _func, BRANCH_SET_LINK);
+ else if (tramp)
+ err = patch_branch(site, _tramp, BRANCH_SET_LINK);
+ else
+ err = 0;
+ } else if (tramp) {
if (func && !is_short) {
err = patch_ulong(tramp + PPC_SCT_DATA, _func);
if (err)
--
2.47.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 2/4] objtool/powerpc: Add support for decoding all types of uncond branches
2024-12-03 19:44 ` [PATCH v4 2/4] objtool/powerpc: Add support for decoding all types of uncond branches Christophe Leroy
@ 2024-12-04 14:09 ` Segher Boessenkool
2025-02-25 8:05 ` [PATCH v5 " Christophe Leroy
1 sibling, 0 replies; 9+ messages in thread
From: Segher Boessenkool @ 2024-12-04 14:09 UTC (permalink / raw)
To: Christophe Leroy
Cc: Shrikanth Hegde, Peter Zijlstra, Josh Poimboeuf, Jason Baron,
Steven Rostedt, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Michael Ellerman, Nicholas Piggin, Naveen N Rao,
Madhavan Srinivasan, linux-kernel, linuxppc-dev
On Tue, Dec 03, 2024 at 08:44:50PM +0100, Christophe Leroy wrote:
> Add support for 'bla' instruction.
>
> This is done by 'flagging' the address as an absolute address so that
> arch_jump_destination() can calculate it as expected. Because code is
> _always_ 4 bytes aligned, use bit 30 as flag.
The AA field already is there, so why not, eh :-)
> Also add support for 'b' and 'ba' instructions. Objtool call them jumps.
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Segher Boessenkool <segher@kewrnel.crashing.org>
> --- a/tools/objtool/arch/powerpc/decode.c
> +++ b/tools/objtool/arch/powerpc/decode.c
> @@ -55,12 +55,15 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
>
> switch (opcode) {
> case 18: /* b[l][a] */
> - if ((ins & 3) == 1) /* bl */
> + if (ins & 1) /* bl[a] */
> typ = INSN_CALL;
> + else /* b[a] */
> + typ = INSN_JUMP_UNCONDITIONAL;
>
> imm = ins & 0x3fffffc;
> if (imm & 0x2000000)
> imm -= 0x4000000;
> + imm |= ins & 2; /* AA flag */
You could of course put that together with the 3fffffc thing, but you
can leave that to the compiler as well :-)
Segher
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v4 4/4] powerpc/static_call: Implement inline static calls
2024-12-03 19:44 ` [PATCH v4 4/4] powerpc/static_call: Implement " Christophe Leroy
@ 2024-12-04 20:09 ` kernel test robot
0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2024-12-04 20:09 UTC (permalink / raw)
To: Christophe Leroy, Shrikanth Hegde, Peter Zijlstra, Josh Poimboeuf,
Jason Baron, Steven Rostedt, Ard Biesheuvel, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Michael Ellerman, Nicholas Piggin, Naveen N Rao,
Madhavan Srinivasan
Cc: oe-kbuild-all, Christophe Leroy, linux-kernel, linuxppc-dev
Hi Christophe,
kernel test robot noticed the following build warnings:
[auto build test WARNING on powerpc/next]
[also build test WARNING on powerpc/fixes linus/master v6.13-rc1 next-20241204]
[cannot apply to tip/x86/core]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Christophe-Leroy/static_call_inline-Provide-trampoline-address-when-updating-sites/20241204-120612
base: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
patch link: https://lore.kernel.org/r/3dbd0b2ba577c942729235d0211d04a406653d81.1733245362.git.christophe.leroy%40csgroup.eu
patch subject: [PATCH v4 4/4] powerpc/static_call: Implement inline static calls
config: powerpc-randconfig-r062-20241204 (https://download.01.org/0day-ci/archive/20241205/202412050317.rQGggDIb-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 592c0fe55f6d9a811028b5f3507be91458ab2713)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241205/202412050317.rQGggDIb-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412050317.rQGggDIb-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from arch/powerpc/platforms/powermac/bootx_init.c:18:
In file included from arch/powerpc/include/asm/io.h:24:
In file included from include/linux/mm.h:2223:
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
1 warning generated.
>> arch/powerpc/platforms/powermac/bootx_init.o: warning: objtool: bootx_init+0x28: unannotated intra-function call
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v5 2/4] objtool/powerpc: Add support for decoding all types of uncond branches
2024-12-03 19:44 ` [PATCH v4 2/4] objtool/powerpc: Add support for decoding all types of uncond branches Christophe Leroy
2024-12-04 14:09 ` Segher Boessenkool
@ 2025-02-25 8:05 ` Christophe Leroy
1 sibling, 0 replies; 9+ messages in thread
From: Christophe Leroy @ 2025-02-25 8:05 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, Naveen N Rao,
Madhavan Srinivasan
Cc: Christophe Leroy, linux-kernel, linuxppc-dev, Segher Boessenkool
Add support for 'bla' instruction.
This is done by 'flagging' the address as an absolute address so that
arch_jump_destination() can calculate it as expected. Because code is
_always_ 4 bytes aligned, use bit 30 as flag.
Also add support for 'b' and 'ba' instructions. Objtool call them jumps.
And make sure the special 'bl .+4' used by clang in relocatable code is
not seen as an 'unannotated intra-function call'. clang should use the
special 'bcl 20,31,.+4' form like gcc but for the time being it does not
so lets work around that.
Link: https://github.com/llvm/llvm-project/issues/128644
Reviewed-by: Segher Boessenkool <segher@kewrnel.crashing.org>
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
v5: Add a special case for clang to ignore 'bl .+4' form.
---
tools/objtool/arch/powerpc/decode.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/arch/powerpc/decode.c b/tools/objtool/arch/powerpc/decode.c
index 53b55690f320..26d5050424a9 100644
--- a/tools/objtool/arch/powerpc/decode.c
+++ b/tools/objtool/arch/powerpc/decode.c
@@ -55,12 +55,17 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
switch (opcode) {
case 18: /* b[l][a] */
- if ((ins & 3) == 1) /* bl */
+ if (ins == 0x48000005) /* bl .+4 */
+ typ = INSN_OTHER;
+ else if (ins & 1) /* bl[a] */
typ = INSN_CALL;
+ else /* b[a] */
+ typ = INSN_JUMP_UNCONDITIONAL;
imm = ins & 0x3fffffc;
if (imm & 0x2000000)
imm -= 0x4000000;
+ imm |= ins & 2; /* AA flag */
break;
}
@@ -77,6 +82,9 @@ int arch_decode_instruction(struct objtool_file *file, const struct section *sec
unsigned long arch_jump_destination(struct instruction *insn)
{
+ if (insn->immediate & 2)
+ return insn->immediate & ~2;
+
return insn->offset + insn->immediate;
}
--
2.47.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4 0/4] Implement inline static calls on PPC32 - v4
2024-12-03 19:44 [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Christophe Leroy
` (3 preceding siblings ...)
2024-12-03 19:44 ` [PATCH v4 4/4] powerpc/static_call: Implement " Christophe Leroy
@ 2025-03-02 4:40 ` Madhavan Srinivasan
4 siblings, 0 replies; 9+ messages in thread
From: Madhavan Srinivasan @ 2025-03-02 4:40 UTC (permalink / raw)
To: Shrikanth Hegde, Peter Zijlstra, Josh Poimboeuf, Jason Baron,
Steven Rostedt, Ard Biesheuvel, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, x86, H. Peter Anvin,
Michael Ellerman, Nicholas Piggin, Naveen N Rao, Christophe Leroy
Cc: linux-kernel, linuxppc-dev
On Tue, 03 Dec 2024 20:44:48 +0100, Christophe Leroy wrote:
> This series implements inline static calls on PPC32.
>
> First patch adds to static_call core the ability to pass the
> trampoline address at the same time as the site address to
> arch_static_call_transform() so that it can fallback on branching to
> the trampoline when the site is too far (Max distance for direct
> branch is 32 Mbytes on powerpc).
>
> [...]
Applied to powerpc/next.
[1/4] static_call_inline: Provide trampoline address when updating sites
https://git.kernel.org/powerpc/c/d856bc3ac7d9ca88b3f52d8e08e58ce892dc3ce1
[2/4] objtool/powerpc: Add support for decoding all types of uncond branches
https://git.kernel.org/powerpc/c/bb7f054f4de260dc14813230cfe4ca7299647b6e
[3/4] powerpc: Prepare arch_static_call_transform() for supporting inline static calls
https://git.kernel.org/powerpc/c/6626f98ed55a7a20b1852e7d263a96d8f5a1b59f
[4/4] powerpc/static_call: Implement inline static calls
https://git.kernel.org/powerpc/c/f50b45626e053dc10792c680cabbbadbf8c001e7
Thanks
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-03-02 4:41 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 19:44 [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 1/4] static_call_inline: Provide trampoline address when updating sites Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 2/4] objtool/powerpc: Add support for decoding all types of uncond branches Christophe Leroy
2024-12-04 14:09 ` Segher Boessenkool
2025-02-25 8:05 ` [PATCH v5 " Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 3/4] powerpc: Prepare arch_static_call_transform() for supporting inline static calls Christophe Leroy
2024-12-03 19:44 ` [PATCH v4 4/4] powerpc/static_call: Implement " Christophe Leroy
2024-12-04 20:09 ` kernel test robot
2025-03-02 4:40 ` [PATCH v4 0/4] Implement inline static calls on PPC32 - v4 Madhavan Srinivasan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).