Skip to content

Commit 01a03a1

Browse files
committed
[llvm-exegesis] [AArch64] Resolve Merge Conflict coming from reverted llvm#136868
1 parent 50c07db commit 01a03a1

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@
2828
#endif // HAVE_LIBPFM
2929
#include <linux/prctl.h> // For PR_PAC_* constants
3030
#include <sys/prctl.h>
31-
#ifndef PR_PAC_SET_ENABLED_KEYS
32-
#define PR_PAC_SET_ENABLED_KEYS 60
33-
#endif
34-
#ifndef PR_PAC_GET_ENABLED_KEYS
35-
#define PR_PAC_GET_ENABLED_KEYS 61
36-
#endif
3731
#ifndef PR_PAC_APIAKEY
3832
#define PR_PAC_APIAKEY (1UL << 0)
3933
#endif
@@ -288,6 +282,35 @@ class ExegesisAArch64Target : public ExegesisTarget {
288282
// Function return is a pseudo-instruction that needs to be expanded
289283
PM.add(createAArch64ExpandPseudoPass());
290284
}
285+
286+
const char *getIgnoredOpcodeReasonOrNull(const LLVMState &State,
287+
unsigned Opcode) const override {
288+
if (const char *Reason =
289+
ExegesisTarget::getIgnoredOpcodeReasonOrNull(State, Opcode))
290+
return Reason;
291+
292+
if (isPointerAuth(Opcode)) {
293+
#if defined(__aarch64__) && defined(__linux__)
294+
// Disable all PAC keys. Note that while we expect the measurements to
295+
// be the same with PAC keys disabled, they could potentially be lower
296+
// since authentication checks are bypassed.
297+
if (prctl(PR_PAC_SET_ENABLED_KEYS,
298+
PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY |
299+
PR_PAC_APDBKEY, // all keys
300+
0, // disable all
301+
0, 0) < 0) {
302+
return "Failed to disable PAC keys";
303+
}
304+
#else
305+
return "Unsupported opcode: isPointerAuth";
306+
#endif
307+
}
308+
309+
if (isLoadTagMultiple(Opcode))
310+
return "Unsupported opcode: load tag multiple";
311+
312+
return nullptr;
313+
}
291314
};
292315

293316
} // namespace

0 commit comments

Comments
 (0)