WSL2-Linux-Kernel/arch
Peter Zijlstra 764929accf x86/static_call: Add support for Jcc tail-calls
commit 923510c88d upstream.

Clang likes to create conditional tail calls like:

  0000000000000350 <amd_pmu_add_event>:
  350:       0f 1f 44 00 00          nopl   0x0(%rax,%rax,1) 351: R_X86_64_NONE      __fentry__-0x4
  355:       48 83 bf 20 01 00 00 00         cmpq   $0x0,0x120(%rdi)
  35d:       0f 85 00 00 00 00       jne    363 <amd_pmu_add_event+0x13>     35f: R_X86_64_PLT32     __SCT__amd_pmu_branch_add-0x4
  363:       e9 00 00 00 00          jmp    368 <amd_pmu_add_event+0x18>     364: R_X86_64_PLT32     __x86_return_thunk-0x4

Where 0x35d is a static call site that's turned into a conditional
tail-call using the Jcc class of instructions.

Teach the in-line static call text patching about this.

Notably, since there is no conditional-ret, in that case patch the Jcc
to point at an empty stub function that does the ret -- or the return
thunk when needed.

Reported-by: "Erhard F." <erhard_f@mailbox.org>
Change-Id: I99c8fc3f721e5d1c74f06710b38d4bac5230303a
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/Y9Kdg9QjHkr9G5b5@hirez.programming.kicks-ass.net
[cascardo: __static_call_validate didn't have the bool tramp argument]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-04-10 16:18:49 +02:00
..
alpha alpha: remove __init annotation from exported page_is_ram() 2023-08-16 18:22:03 +02:00
arc ARC: fix spare error 2024-01-25 14:52:30 -08:00
arm arm: dts: marvell: Fix maxium->maxim typo in brownstone dts 2024-04-10 16:18:34 +02:00
arm64 KVM: arm64: Limit stage2_apply_range() batch size to largest block 2024-04-10 16:18:47 +02:00
csky arch: consolidate arch_irq_work_raise prototypes 2024-02-23 08:54:39 +01:00
h8300
hexagon
ia64 arch: Introduce CONFIG_FUNCTION_ALIGNMENT 2024-04-10 16:18:49 +02:00
m68k memblock: allow to specify flags with memblock_add_node() 2023-12-20 15:17:33 +01:00
microblaze
mips MIPS: Clear Cause.BD in instruction_pointer_set 2024-03-26 18:21:12 -04:00
nds32
nios2 nios2: dts: Fix tse_mac "max-frame-size" property 2023-06-21 15:59:14 +02:00
openrisc openrisc: Properly store r31 to pt_regs on unhandled exceptions 2023-05-11 23:00:37 +09:00
parisc parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds 2024-04-10 16:18:36 +02:00
powerpc powerpc/fsl: Fix mfpmr build errors with newer binutils 2024-04-10 16:18:37 +02:00
riscv riscv: dts: sifive: add missing #interrupt-cells to pmic 2024-03-26 18:21:12 -04:00
s390 s390/vtime: fix average steal time calculation 2024-03-26 18:21:35 -04:00
sh sh: bios: Revive earlyprintk support 2023-11-20 11:08:23 +01:00
sparc sparc: vDSO: fix return value of __setup handler 2024-04-10 16:18:34 +02:00
um um: time-travel: fix time corruption 2024-02-23 08:54:50 +01:00
x86 x86/static_call: Add support for Jcc tail-calls 2024-04-10 16:18:49 +02:00
xtensa xtensa: boot/lib: fix function prototypes 2023-10-06 13:18:14 +02:00
.gitignore
Kconfig arch: Introduce CONFIG_FUNCTION_ALIGNMENT 2024-04-10 16:18:49 +02:00