Add lfence after ret in retpoline thunk.
authormortimer <mortimer@openbsd.org>
Wed, 1 Sep 2021 13:37:14 +0000 (13:37 +0000)
committermortimer <mortimer@openbsd.org>
Wed, 1 Sep 2021 13:37:14 +0000 (13:37 +0000)
Recommended by AMD white paper Software Techniques for Managing
Speculation on AMD Processors (9.17.20) mitigation V2-1.

Pointed out by bluhm@. ok bluhm@ kettenis@

gnu/llvm/llvm/lib/Target/X86/X86IndirectThunks.cpp

index 828887d..ae26ed4 100644 (file)
@@ -250,6 +250,7 @@ void RetpolineThunkInserter::populateThunk(MachineFunction &MF) {
 
   CallTarget->back().setPreInstrSymbol(MF, TargetSym);
   BuildMI(CallTarget, DebugLoc(), TII->get(RetOpc));
+  BuildMI(CallTarget, DebugLoc(), TII->get(X86::LFENCE));
 }
 
 FunctionPass *llvm::createX86IndirectThunksPass() {