Hard
Where speculation goes at the `ret` inside a retpoline thunk
A kernel built with retpolines, as a Spectre v2 (branch target injection) mitigation, replaces each indirect call *%r11 with call __x86_indirect_thunk_r11, shown below. When the front end reaches the thunk's ret, before the ret itself has executed, where does it speculatively fetch from, and what does each retpolined indirect call cost?
__x86_indirect_thunk_r11:
call .Lset_target ; pushes .Lcapture (stack and RSB)
.Lcapture:
pause
lfence
jmp .Lcapture
.Lset_target:
mov [rsp], r11 ; overwrite the return address in memory
ret47 of 47 in Computer Architecture