x86/alternative: Handle Jcc __x86_indirect_thunk_\reg
authorPeter Zijlstra <peterz@infradead.org>
Tue, 26 Oct 2021 12:01:43 +0000 (14:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Jul 2022 10:53:54 +0000 (12:53 +0200)
commita40925e2efd80d22d3ba8b4477caece062764e4d
treea6ee56dc9aa8fb68395817e4fea058c786327c36
parent86900f95fb060ca8ad9062f1905d3ffaf3bac707
x86/alternative: Handle Jcc __x86_indirect_thunk_\reg

commit 2f0cbb2a8e5bbf101e9de118fc0eb168111a5e1e upstream.

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
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kernel/alternative.c