LLVM 20.0.0git
Classes | Namespaces | Macros | Typedefs | Functions | Variables
X86LoadValueInjectionLoadHardening.cpp File Reference
#include "ImmutableGraph.h"
#include "X86.h"
#include "X86Subtarget.h"
#include "X86TargetMachine.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineDominanceFrontier.h"
#include "llvm/CodeGen/MachineDominators.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineLoopInfo.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RDFGraph.h"
#include "llvm/CodeGen/RDFLiveness.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"

Go to the source code of this file.

Classes

struct  llvm::GraphTraits< MachineGadgetGraph * >
 
struct  llvm::DOTGraphTraits< MachineGadgetGraph * >
 

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 

Macros

#define PASS_KEY   "x86-lvi-load"
 
#define DEBUG_TYPE   PASS_KEY
 

Typedefs

typedef int(* OptimizeCutT) (unsigned int *Nodes, unsigned int NodesSize, unsigned int *Edges, int *EdgeValues, int *CutEdges, unsigned int EdgesSize)
 

Functions

 STATISTIC (NumFences, "Number of LFENCEs inserted for LVI mitigation")
 
 STATISTIC (NumFunctionsConsidered, "Number of functions analyzed")
 
 STATISTIC (NumFunctionsMitigated, "Number of functions for which mitigations " "were deployed")
 
 STATISTIC (NumGadgets, "Number of LVI gadgets detected during analysis")
 
static void writeGadgetGraph (raw_ostream &OS, MachineFunction &MF, MachineGadgetGraph *G)
 
 INITIALIZE_PASS_BEGIN (X86LoadValueInjectionLoadHardeningPass, PASS_KEY, "X86 LVI load hardening", false, false) INITIALIZE_PASS_END(X86LoadValueInjectionLoadHardeningPass
 

Variables

static cl::opt< std::string > OptimizePluginPath (PASS_KEY "-opt-plugin", cl::desc("Specify a plugin to optimize LFENCE insertion"), cl::Hidden)
 
static cl::opt< boolNoConditionalBranches (PASS_KEY "-no-cbranch", cl::desc("Don't treat conditional branches as disclosure gadgets. This " "may improve performance, at the cost of security."), cl::init(false), cl::Hidden)
 
static cl::opt< boolEmitDot (PASS_KEY "-dot", cl::desc("For each function, emit a dot graph depicting potential LVI gadgets"), cl::init(false), cl::Hidden)
 
static cl::opt< boolEmitDotOnly (PASS_KEY "-dot-only", cl::desc("For each function, emit a dot graph depicting potential LVI " "gadgets, and do not insert any fences"), cl::init(false), cl::Hidden)
 
static cl::opt< boolEmitDotVerify (PASS_KEY "-dot-verify", cl::desc("For each function, emit a dot graph to stdout depicting " "potential LVI gadgets, used for testing purposes only"), cl::init(false), cl::Hidden)
 
static llvm::sys::DynamicLibrary OptimizeDL
 
static OptimizeCutT OptimizeCut = nullptr
 
 PASS_KEY
 
X86 LVI load hardening
 
X86 LVI load false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   PASS_KEY

Definition at line 70 of file X86LoadValueInjectionLoadHardening.cpp.

◆ PASS_KEY

#define PASS_KEY   "x86-lvi-load"

Definition at line 69 of file X86LoadValueInjectionLoadHardening.cpp.

Typedef Documentation

◆ OptimizeCutT

typedef int(* OptimizeCutT) (unsigned int *Nodes, unsigned int NodesSize, unsigned int *Edges, int *EdgeValues, int *CutEdges, unsigned int EdgesSize)

Definition at line 107 of file X86LoadValueInjectionLoadHardening.cpp.

Function Documentation

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( X86LoadValueInjectionLoadHardeningPass  ,
PASS_KEY  ,
"X86 LVI load hardening"  ,
false  ,
false   
)

◆ STATISTIC() [1/4]

STATISTIC ( NumFences  ,
"Number of LFENCEs inserted for LVI mitigation"   
)

◆ STATISTIC() [2/4]

STATISTIC ( NumFunctionsConsidered  ,
"Number of functions analyzed"   
)

◆ STATISTIC() [3/4]

STATISTIC ( NumFunctionsMitigated  ,
"Number of functions for which mitigations " "were deployed"   
)

◆ STATISTIC() [4/4]

STATISTIC ( NumGadgets  ,
"Number of LVI gadgets detected during analysis"   
)

◆ writeGadgetGraph()

static void writeGadgetGraph ( raw_ostream OS,
MachineFunction MF,
MachineGadgetGraph *  G 
)
static

Variable Documentation

◆ EmitDot

cl::opt< bool > EmitDot(PASS_KEY "-dot", cl::desc( "For each function, emit a dot graph depicting potential LVI gadgets"), cl::init(false), cl::Hidden) ( PASS_KEY "-dot"  ,
cl::desc( "For each function, emit a dot graph depicting potential LVI gadgets")  ,
cl::init(false)  ,
cl::Hidden   
)
static

◆ EmitDotOnly

cl::opt< bool > EmitDotOnly(PASS_KEY "-dot-only", cl::desc("For each function, emit a dot graph depicting potential LVI " "gadgets, and do not insert any fences"), cl::init(false), cl::Hidden) ( PASS_KEY "-dot-only"  ,
cl::desc("For each function, emit a dot graph depicting potential LVI " "gadgets, and do not insert any fences")  ,
cl::init(false)  ,
cl::Hidden   
)
static

◆ EmitDotVerify

cl::opt< bool > EmitDotVerify(PASS_KEY "-dot-verify", cl::desc("For each function, emit a dot graph to stdout depicting " "potential LVI gadgets, used for testing purposes only"), cl::init(false), cl::Hidden) ( PASS_KEY "-dot-verify"  ,
cl::desc("For each function, emit a dot graph to stdout depicting " "potential LVI gadgets, used for testing purposes only")  ,
cl::init(false)  ,
cl::Hidden   
)
static

◆ false

X86 LVI load false

Definition at line 806 of file X86LoadValueInjectionLoadHardening.cpp.

◆ hardening

X86 LVI load hardening

Definition at line 806 of file X86LoadValueInjectionLoadHardening.cpp.

◆ NoConditionalBranches

cl::opt< bool > NoConditionalBranches(PASS_KEY "-no-cbranch", cl::desc("Don't treat conditional branches as disclosure gadgets. This " "may improve performance, at the cost of security."), cl::init(false), cl::Hidden) ( PASS_KEY "-no-cbranch"  ,
cl::desc("Don't treat conditional branches as disclosure gadgets. This " "may improve performance, at the cost of security.")  ,
cl::init(false)  ,
cl::Hidden   
)
static

◆ OptimizeCut

OptimizeCutT OptimizeCut = nullptr
static

Definition at line 110 of file X86LoadValueInjectionLoadHardening.cpp.

◆ OptimizeDL

llvm::sys::DynamicLibrary OptimizeDL
static

Definition at line 106 of file X86LoadValueInjectionLoadHardening.cpp.

◆ OptimizePluginPath

cl::opt< std::string > OptimizePluginPath(PASS_KEY "-opt-plugin", cl::desc("Specify a plugin to optimize LFENCE insertion"), cl::Hidden) ( PASS_KEY "-opt-plugin"  ,
cl::desc("Specify a plugin to optimize LFENCE insertion")  ,
cl::Hidden   
)
static

◆ PASS_KEY

PASS_KEY

Definition at line 805 of file X86LoadValueInjectionLoadHardening.cpp.