Re: [patch 00/38] x86/retbleed: Call depth tracking mitigation

From: Thomas Gleixner
Date: Mon Jul 18 2022 - 18:22:33 EST


On Mon, Jul 18 2022 at 23:18, Peter Zijlstra wrote:
> On Mon, Jul 18, 2022 at 10:44:14PM +0200, Thomas Gleixner wrote:
>> And we need input from the Clang folks because their CFI work also puts
>> stuff in front of the function entry, which nicely collides.
>
> Right, I need to go look at the latest kCFI patches, that sorta got
> side-tracked for working on all the retbleed muck :/
>
> Basically kCFI wants to preface every (indirect callable) function with:
>
> __cfi_\func:
> int3
> movl $0x12345678, %rax
> int3
> int3
> \func:
> endbr
> \func_direct:
>
> Ofc, we can still put the whole:
>
> sarq $5, PER_CPU_VAR(__x86_call_depth);
> jmp \func_direct
>
> thing in front of that. But it does somewhat destroy the version I had
> that only needs the 10 bytes padding for the sarq.

Right, because it needs the jump. I was just chatting with Jaoa about
that over IRC.

The jump slow things down. Jaoa has ideas and will reply soonish.

Thanks,

tglx