Re: [PATCH] x86/kcfi: Optimize call sequence
From: Peter Zijlstra
Date: Wed Jun 17 2026 - 08:47:38 EST
On Wed, Jun 17, 2026 at 01:36:37PM +0100, David Laight wrote:
> I did have a local change that generated different nop*3 so I could tell
> what was lfence, stac, clac (etc).
> Trying to check the compiler output was hard when there were blocks of
> 6 nop.
You should use objtool more ;-)
$ defconfig-build/tools/objtool/objtool --disas=rseq_update_user_cs --wide defconfig-build/kernel/rseq.o
rseq_update_user_cs:
f00: rseq_update_user_cs+0x0 mov %rdi,%rax
f03: rseq_update_user_cs+0x3 mov 0x80(%rsi),%rdi
f0a: rseq_update_user_cs+0xa mov %gs:0x0(%rip),%rcx # 0xf12 <current_task>
f12: rseq_update_user_cs+0x12 testq $0x8000000,(%rcx)
f19: rseq_update_user_cs+0x19 jne 0xf27 <rseq_update_user_cs+0x27>
f1b: rseq_update_user_cs+0x1b | <alternative.f1b> | X86_FEATURE_LA57
f1b: rseq_update_user_cs+0x1b | movabs $0x7ffffffff000,%r10 | movabs $0xfffffffffff000,%r10
f25: rseq_update_user_cs+0x25 jmp 0xf3f <rseq_update_user_cs+0x3f>
f27: rseq_update_user_cs+0x27 mov $0xc0000000,%r8d
f2d: rseq_update_user_cs+0x2d lea 0x3fffe000(%r8),%r10
f34: rseq_update_user_cs+0x34 testb $0x8,0x5ab(%rcx)
f3b: rseq_update_user_cs+0x3b cmovne %r8,%r10
f3f: rseq_update_user_cs+0x3f cmp %r10,%rdx
f42: rseq_update_user_cs+0x42 jae 0xfda <rseq_update_user_cs+0xda>
f48: rseq_update_user_cs+0x48 | <jump_table.f48> | JUMP
f48: rseq_update_user_cs+0x48 | jmp 0xfe9 <rseq_update_user_cs+0xe9> | nop5
f4d: rseq_update_user_cs+0x4d movabs $0x123456789abcdef,%rcx
f57: rseq_update_user_cs+0x57 cmp %rcx,%rdx
f5a: rseq_update_user_cs+0x5a cmova %rcx,%rdx
f5e: rseq_update_user_cs+0x5e | <alternative.f5e> | X86_FEATURE_SMAP
f5e: rseq_update_user_cs+0x5e | nop*3 | stac
f61: rseq_update_user_cs+0x61 | <ex_table.f61> | EXCEPTION
f61: rseq_update_user_cs+0x61 | mov 0x8(%rdx),%r9 | resume at 0xff1 <rseq_update_user_cs+0xf1>
f65: rseq_update_user_cs+0x65 | <ex_table.f65> | EXCEPTION
f65: rseq_update_user_cs+0x65 | mov 0x10(%rdx),%r8 | resume at 0xff3 <rseq_update_user_cs+0xf3>
f69: rseq_update_user_cs+0x69 add $0x18,%rdx
f6d: rseq_update_user_cs+0x6d | <ex_table.f6d> | EXCEPTION
f6d: rseq_update_user_cs+0x6d | mov (%rdx),%rcx | resume at 0xff5 <rseq_update_user_cs+0xf5>
f70: rseq_update_user_cs+0x70 mov %rdi,%rdx
f73: rseq_update_user_cs+0x73 sub %r9,%rdx
f76: rseq_update_user_cs+0x76 cmp %r8,%rdx
f79: rseq_update_user_cs+0x79 jae 0xfbd <rseq_update_user_cs+0xbd>
f7b: rseq_update_user_cs+0x7b cmp %r10,%rcx
f7e: rseq_update_user_cs+0x7e jae 0xfd7 <rseq_update_user_cs+0xd7>
f80: rseq_update_user_cs+0x80 cmp $0x4,%rcx
f84: rseq_update_user_cs+0x84 jb 0xfd7 <rseq_update_user_cs+0xd7>
f86: rseq_update_user_cs+0x86 | <ex_table.f86> | EXCEPTION
f86: rseq_update_user_cs+0x86 | mov -0x4(%rcx),%edx | resume at 0xff7 <rseq_update_user_cs+0xf7>
f89: rseq_update_user_cs+0x89 cmp %edx,0xa9c(%rax)
f8f: rseq_update_user_cs+0x8f jne 0xfd7 <rseq_update_user_cs+0xd7>
f91: rseq_update_user_cs+0x91 mov 0xa90(%rax),%rax
f98: rseq_update_user_cs+0x98 | <ex_table.f98> | EXCEPTION
f98: rseq_update_user_cs+0x98 | movq $0x0,0x8(%rax) | resume at 0xff7 <rseq_update_user_cs+0xf7>
fa0: rseq_update_user_cs+0xa0 mov %rcx,0x80(%rsi)
fa7: rseq_update_user_cs+0xa7 | <alternative.fa7> | X86_FEATURE_SMAP
fa7: rseq_update_user_cs+0xa7 | nop*3 | clac
faa: rseq_update_user_cs+0xaa mov %r9,%rsi
fad: rseq_update_user_cs+0xad mov %r8,%rdx
fb0: rseq_update_user_cs+0xb0 call 0x150 <rseq_trace_ip_fixup>
fb5: rseq_update_user_cs+0xb5 mov $0x1,%al
fb7: rseq_update_user_cs+0xb7 cs jmp 0xfbd <__x86_return_thunk>
fbd: rseq_update_user_cs+0xbd mov 0xa90(%rax),%rax
fc4: rseq_update_user_cs+0xc4 | <ex_table.fc4> | EXCEPTION
fc4: rseq_update_user_cs+0xc4 | movq $0x0,0x8(%rax) | resume at 0xff7 <rseq_update_user_cs+0xf7>
fcc: rseq_update_user_cs+0xcc | <alternative.fcc> | X86_FEATURE_SMAP
fcc: rseq_update_user_cs+0xcc | nop*3 | clac
fcf: rseq_update_user_cs+0xcf mov $0x1,%al
fd1: rseq_update_user_cs+0xd1 cs jmp 0xfd7 <__x86_return_thunk>
fd7: rseq_update_user_cs+0xd7 | <alternative.fd7> | X86_FEATURE_SMAP
fd7: rseq_update_user_cs+0xd7 | nop*3 | clac
fda: rseq_update_user_cs+0xda movb $0x1,0xaa6(%rax)
fe1: rseq_update_user_cs+0xe1 xor %eax,%eax
fe3: rseq_update_user_cs+0xe3 cs jmp 0xfe9 <__x86_return_thunk>
fe9: rseq_update_user_cs+0xe9 mov %rax,%rdi
fec: rseq_update_user_cs+0xec jmp 0xff1 <rseq_debug_update_user_cs>
ff1: rseq_update_user_cs+0xf1 jmp 0xff7 <rseq_update_user_cs+0xf7>
ff3: rseq_update_user_cs+0xf3 jmp 0xff7 <rseq_update_user_cs+0xf7>
ff5: rseq_update_user_cs+0xf5 jmp 0xff7 <rseq_update_user_cs+0xf7>
ff7: rseq_update_user_cs+0xf7 | <alternative.ff7> | X86_FEATURE_SMAP
ff7: rseq_update_user_cs+0xf7 | nop*3 | clac
ffa: rseq_update_user_cs+0xfa xor %eax,%eax
ffc: rseq_update_user_cs+0xfc cs jmp 0x1002 <__x86_return_thunk>