[llvm] [llvm-exegesis][AArch64] Check for PAC keys before disabling them (PR #138643)
Anatoly Trosinenko via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 4 09:48:04 PDT 2025
================
@@ -151,6 +205,72 @@ class ExegesisAArch64Target : public ExegesisTarget {
// Function return is a pseudo-instruction that needs to be expanded
PM.add(createAArch64ExpandPseudoPass());
}
+
+#if defined(__aarch64__) && defined(__linux__)
+ // Converts variadic arguments to `long` and passes zeros for the unused
+ // arg2-arg5, as tested by the Linux kernel.
+ static long prctl_wrapper(int op, long arg2 = 0, long arg3 = 0) {
+ return prctl(op, arg2, arg3, /*arg4=*/0L, /*arg5=*/0L);
+ }
+#endif
+
+ const char *getIgnoredOpcodeReasonOrNull(const LLVMState &State,
+ unsigned Opcode) const override {
+ if (const char *Reason =
+ ExegesisTarget::getIgnoredOpcodeReasonOrNull(State, Opcode))
+ return Reason;
+
+ if (isPointerAuth(Opcode)) {
+#if defined(__aarch64__) && defined(__linux__)
+ // Only proceed with PAC key control if explicitly requested
+ if (!AArch64DisablePacControl) {
+ // For some systems with existing PAC keys set, it is better to
+ // check the existing state of the key before setting it.
+ // If the CPU implements FEAT_FPAC,
+ // authentication instructions almost certainly crash when being
+ // benchmarked, so disable all the keys by default. On the other hand,
+ // disabling the keys at run-time can probably crash llvm-exegesis at
+ // some later point, depending on how it was built. For that reason, the
+ // user may pass --aarch64-disable-pac-control in case
----------------
atrosinenko wrote:
_If the option is renamed, this line has to be updated as well._
https://github.com/llvm/llvm-project/pull/138643
More information about the llvm-commits
mailing list