[PATCH 5.15 0/5] Support static calls with LLVM-built kernels

Thadeu Lima de Souza Cascardo
2024-03-13T10:43:24Z

Otherwise, we see warnings like this:

[ 0.000000][ T0] ------------[ cut here ]------------
[ 0.000000][ T0] unexpected static_call insn opcode 0xf at kvm_vcpu_reload_apic_access_page+0x17/0x30
[ 0.000000][ T0] WARNING: CPU: 0 PID: 0 at arch/x86/kernel/static_call.c:88 __static_call_validate+0x68/0x70
[ 0.000000][ T0] Modules linked in:
[ 0.000000][ T0] CPU: 0 PID: 0 Comm: swapper Not tainted 5.15.151-00083-gf200c7260296 #68 fe3cb25cf78cb710722bb5acd1cadddd35172924
[ 0.000000][ T0] RIP: 0010:__static_call_validate+0x68/0x70
[ 0.000000][ T0] Code: 0f b6 4a 04 81 f1 c0 00 00 00 09 c1 74 cc 80 3d be 2c 02 02 00 75 c3 c6 05 b5 2c 02 02 01 48 c7 c7 38 4f c3 82 e8 e8 c8 09 00 <0f> 0b c3 00 00 cc cc 00 53 48 89 fb 48 63 15 31 71 06 02 e8 b0 b8
[ 0.000000][ T0] RSP: 0000:ffffffff82e03e70 EFLAGS: 00010046 ORIG_RAX: 0000000000000000
[ 0.000000][ T0] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000002
[ 0.000000][ T0] RDX: 0000000000000000 RSI: ffffffff82e03ce0 RDI: 0000000000000001
[ 0.000000][ T0] RBP: 0000000000000001 R08: 00000000ffffffff R09: ffffffff82eaab70
[ 0.000000][ T0] R10: ffffffff82e2e900 R11: 205d305420202020 R12: ffffffff82e51960
[ 0.000000][ T0] R13: ffffffff81038987 R14: ffffffff81038987 R15: 0000000000000001
[ 0.000000][ T0] FS: 0000000000000000(0000) GS:ffffffff83726000(0000) knlGS:0000000000000000
[ 0.000000][ T0] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 0.000000][ T0] CR2: ffff888000014be8 CR3: 00000000037b2000 CR4: 00000000000000a0
[ 0.000000][ T0] Call Trace:
[ 0.000000][ T0] <TASK>
[ 0.000000][ T0] ? __warn+0x75/0xe0
[ 0.000000][ T0] ? report_bug+0x81/0xe0
[ 0.000000][ T0] ? kvm_vcpu_reload_apic_access_page+0x17/0x30
[ 0.000000][ T0] ? kvm_vcpu_reload_apic_access_page+0x17/0x30
[ 0.000000][ T0] ? early_fixup_exception+0x44/0xa0
[ 0.000000][ T0] ? early_idt_handler_common+0x2f/0x40
[ 0.000000][ T0] ? kvm_vcpu_reload_apic_access_page+0x17/0x30
[ 0.000000][ T0] ? kvm_vcpu_reload_apic_access_page+0x17/0x30
[ 0.000000][ T0] ? __static_call_validate+0x68/0x70
[ 0.000000][ T0] ? arch_static_call_transform+0x5c/0x90
[ 0.000000][ T0] ? __static_call_init+0x1ec/0x230
[ 0.000000][ T0] ? static_call_init+0x32/0x70
[ 0.000000][ T0] ? setup_arch+0x36/0x4f0
[ 0.000000][ T0] ? start_kernel+0x67/0x400
[ 0.000000][ T0] ? secondary_startup_64_no_verify+0xb1/0xbb
[ 0.000000][ T0] </TASK>
[ 0.000000][ T0] ---[ end trace 8c8589c01f370686 ]---

Peter Zijlstra (4):
arch: Introduce CONFIG_FUNCTION_ALIGNMENT
x86/alternatives: Introduce int3_emulate_jcc()
x86/alternatives: Teach text_poke_bp() to patch Jcc.d32 instructions
x86/static_call: Add support for Jcc tail-calls

Thomas Gleixner (1):
x86/asm: Differentiate between code and function alignment

Makefile | 4 +-
arch/Kconfig | 24 ++++++++++++
arch/ia64/Kconfig | 1 +
arch/ia64/Makefile | 2 +-
arch/x86/Kconfig | 2 +
arch/x86/boot/compressed/head_64.S | 8 ++++
arch/x86/include/asm/linkage.h | 12 +++---
arch/x86/include/asm/text-patching.h | 31 +++++++++++++++
arch/x86/kernel/alternative.c | 56 +++++++++++++++++++++++-----
arch/x86/kernel/kprobes/core.c | 38 ++++---------------
arch/x86/kernel/static_call.c | 50 +++++++++++++++++++++++--
include/asm-generic/vmlinux.lds.h | 4 +-
include/linux/linkage.h | 4 +-
lib/Kconfig.debug | 1 +
14 files changed, 183 insertions(+), 54 deletions(-)

--
2.34.1