From d23869897606b8e31c73d9c35bc87b8dc53e8483 Mon Sep 17 00:00:00 2001 From: mortimer Date: Wed, 1 Sep 2021 13:37:14 +0000 Subject: [PATCH] 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@ --- gnu/llvm/llvm/lib/Target/X86/X86IndirectThunks.cpp | 1 + 1 file changed, 1 insertion(+) 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() { -- 2.20.1