x86/alternative: Handle Jcc __x86_indirect_thunk_\reg
authorPeter Zijlstra <peterz@infradead.org>
Tue, 26 Oct 2021 12:01:43 +0000 (14:01 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 28 Oct 2021 21:25:28 +0000 (23:25 +0200)
commit2f0cbb2a8e5bbf101e9de118fc0eb168111a5e1e
treeea3435712f5e8b8a09d1a06e38da15d9b7f126bf
parent7508500900814d14e2e085cdc4e28142721abbdf
x86/alternative: Handle Jcc __x86_indirect_thunk_\reg

Handle the rare cases where the compiler (clang) does an indirect
conditional tail-call using:

  Jcc __x86_indirect_thunk_\reg

For the !RETPOLINE case this can be rewritten to fit the original (6
byte) instruction like:

  Jncc.d8 1f
  JMP *%\reg
  NOP
1:

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Tested-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/r/20211026120310.296470217@infradead.org
arch/x86/kernel/alternative.c