Skip to content

Commit 389ba77

Browse files
Merge branch 'llvm:main' into gh-101657
2 parents 8f90e19 + 96ab74b commit 389ba77

File tree

663 files changed

+17063
-6731
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

663 files changed

+17063
-6731
lines changed

bolt/include/bolt/Passes/PAuthGadgetScanner.h

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ namespace PAuthGadgetScanner {
199199
// to distinguish intermediate and final results at the type level.
200200
//
201201
// Here is an overview of issue life-cycle:
202-
// * an analysis (SrcSafetyAnalysis at now, DstSafetyAnalysis will be added
203-
// later to support the detection of authentication oracles) computes register
202+
// * an analysis (SrcSafetyAnalysis or DstSafetyAnalysis) computes register
204203
// state for each instruction in the function.
205204
// * for each instruction, it is checked whether it is a gadget of some kind,
206205
// taking the computed state into account. If a gadget is found, its kind
@@ -273,6 +272,11 @@ class ExtraInfo {
273272
virtual ~ExtraInfo() {}
274273
};
275274

275+
/// The set of instructions writing to the affected register in an unsafe
276+
/// manner.
277+
///
278+
/// This is a hint to be printed alongside the report. It should be further
279+
/// analyzed by the user.
276280
class ClobberingInfo : public ExtraInfo {
277281
SmallVector<MCInstReference> ClobberingInstrs;
278282

@@ -282,6 +286,20 @@ class ClobberingInfo : public ExtraInfo {
282286
void print(raw_ostream &OS, const MCInstReference Location) const override;
283287
};
284288

289+
/// The set of instructions leaking the authenticated pointer before the
290+
/// result of authentication was checked.
291+
///
292+
/// This is a hint to be printed alongside the report. It should be further
293+
/// analyzed by the user.
294+
class LeakageInfo : public ExtraInfo {
295+
SmallVector<MCInstReference> LeakingInstrs;
296+
297+
public:
298+
LeakageInfo(ArrayRef<MCInstReference> Instrs) : LeakingInstrs(Instrs) {}
299+
300+
void print(raw_ostream &OS, const MCInstReference Location) const override;
301+
};
302+
285303
/// A brief version of a report that can be further augmented with the details.
286304
///
287305
/// A half-baked report produced on the first run of the analysis. An extra,
@@ -322,6 +340,9 @@ class FunctionAnalysisContext {
322340
void findUnsafeUses(SmallVector<PartialReport<MCPhysReg>> &Reports);
323341
void augmentUnsafeUseReports(ArrayRef<PartialReport<MCPhysReg>> Reports);
324342

343+
void findUnsafeDefs(SmallVector<PartialReport<MCPhysReg>> &Reports);
344+
void augmentUnsafeDefReports(ArrayRef<PartialReport<MCPhysReg>> Reports);
345+
325346
/// Process the reports which do not have to be augmented, and remove them
326347
/// from Reports.
327348
void handleSimpleReports(SmallVector<PartialReport<MCPhysReg>> &Reports);

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ class DataAggregator : public DataReader {
8585
};
8686
friend raw_ostream &operator<<(raw_ostream &OS, const LBREntry &);
8787

88+
friend struct PerfSpeEventsTestHelper;
89+
8890
struct PerfBranchSample {
8991
SmallVector<LBREntry, 32> LBR;
9092
};
@@ -99,16 +101,17 @@ class DataAggregator : public DataReader {
99101
uint64_t Addr;
100102
};
101103

102-
/// Container for the unit of branch data.
103-
/// Backwards compatible with legacy use for branches and fall-throughs:
104-
/// - if \p Branch is FT_ONLY or FT_EXTERNAL_ORIGIN, the trace only
105-
/// contains fall-through data,
106-
/// - if \p To is BR_ONLY, the trace only contains branch data.
104+
/// Container for the unit of branch data, matching pre-aggregated trace type.
105+
/// Backwards compatible with branch and fall-through types:
106+
/// - if \p To is < 0, the trace only contains branch data (BR_ONLY),
107+
/// - if \p Branch is < 0, the trace only contains fall-through data
108+
/// (FT_ONLY, FT_EXTERNAL_ORIGIN, or FT_EXTERNAL_RETURN).
107109
struct Trace {
108110
static constexpr const uint64_t EXTERNAL = 0ULL;
109111
static constexpr const uint64_t BR_ONLY = -1ULL;
110112
static constexpr const uint64_t FT_ONLY = -1ULL;
111113
static constexpr const uint64_t FT_EXTERNAL_ORIGIN = -2ULL;
114+
static constexpr const uint64_t FT_EXTERNAL_RETURN = -3ULL;
112115

113116
uint64_t Branch;
114117
uint64_t From;
@@ -388,9 +391,9 @@ class DataAggregator : public DataReader {
388391
/// File format syntax:
389392
/// E <event>
390393
/// S <start> <count>
391-
/// T <start> <end> <ft_end> <count>
394+
/// [TR] <start> <end> <ft_end> <count>
392395
/// B <start> <end> <count> <mispred_count>
393-
/// [Ff] <start> <end> <count>
396+
/// [Ffr] <start> <end> <count>
394397
///
395398
/// where <start>, <end>, <ft_end> have the format [<id>:]<offset>
396399
///
@@ -401,8 +404,11 @@ class DataAggregator : public DataReader {
401404
/// f - an aggregated fall-through with external origin - used to disambiguate
402405
/// between a return hitting a basic block head and a regular internal
403406
/// jump to the block
407+
/// r - an aggregated fall-through originating at an external return, no
408+
/// checks are performed for a fallthrough start
404409
/// T - an aggregated trace: branch from <start> to <end> with a fall-through
405410
/// to <ft_end>
411+
/// R - an aggregated trace originating at a return
406412
///
407413
/// <id> - build id of the object containing the address. We can skip it for
408414
/// the main binary and use "X" for an unknown object. This will save some
@@ -530,7 +536,12 @@ inline raw_ostream &operator<<(raw_ostream &OS,
530536
const DataAggregator::Trace &T) {
531537
switch (T.Branch) {
532538
case DataAggregator::Trace::FT_ONLY:
539+
break;
533540
case DataAggregator::Trace::FT_EXTERNAL_ORIGIN:
541+
OS << "X:0 -> ";
542+
break;
543+
case DataAggregator::Trace::FT_EXTERNAL_RETURN:
544+
OS << "X:R -> ";
534545
break;
535546
default:
536547
OS << Twine::utohexstr(T.Branch) << " -> ";

bolt/include/bolt/Utils/CommandLineOpts.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern llvm::cl::OptionCategory BinaryAnalysisCategory;
4848
extern llvm::cl::opt<unsigned> AlignText;
4949
extern llvm::cl::opt<unsigned> AlignFunctions;
5050
extern llvm::cl::opt<bool> AggregateOnly;
51+
extern llvm::cl::opt<bool> ArmSPE;
5152
extern llvm::cl::opt<unsigned> BucketsPerLine;
5253
extern llvm::cl::opt<bool> CompactCodeModel;
5354
extern llvm::cl::opt<bool> DiffOnly;

0 commit comments

Comments
 (0)