Re: [PATCH 5/7] x86/speculation: Annotate intra-function calls

From: Josh Poimboeuf
Date: Fri Apr 03 2020 - 12:05:50 EST


On Thu, Apr 02, 2020 at 10:22:18AM +0200, Alexandre Chartre wrote:
> .macro RETPOLINE_JMP reg:req
> - call .Ldo_rop_\@
> + INTRA_FUNCTION_CALL .Ldo_rop_\@
> .Lspec_trap_\@:
> pause
> lfence
> @@ -102,7 +116,7 @@
> .Ldo_retpoline_jmp_\@:
> RETPOLINE_JMP \reg
> .Ldo_call_\@:
> - call .Ldo_retpoline_jmp_\@
> + INTRA_FUNCTION_CALL .Ldo_retpoline_jmp_\@
> .endm

There's a catch: this is part of an alternative. Which means if
X86_FEATURE_RETPOLINE isn't set at runtime, then the retpoline won't be
there and the ORC data will be wrong.

In fact objtool should probably be made smart enough to warn about this
situation, when an alternative changes the stack state.

The only way I can think of to fix this is to have ORC alternatives :-/

--
Josh