From: mortimer Date: Wed, 1 Sep 2021 13:37:14 +0000 (+0000) Subject: Add lfence after ret in retpoline thunk. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d23869897606b8e31c73d9c35bc87b8dc53e8483;p=openbsd Add lfence after ret in retpoline thunk. 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@ --- diff --git a/gnu/llvm/llvm/lib/Target/X86/X86IndirectThunks.cpp b/gnu/llvm/llvm/lib/Target/X86/X86IndirectThunks.cpp index 828887d9612..ae26ed481c2 100644 --- a/gnu/llvm/llvm/lib/Target/X86/X86IndirectThunks.cpp +++ b/gnu/llvm/llvm/lib/Target/X86/X86IndirectThunks.cpp @@ -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() {