[llvm] [llvm-exegesis][AArch64] Check for PAC keys before disabling them (PR #138643)

Abhilash Majumder via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 05:36:43 PDT 2025


================
@@ -207,15 +213,38 @@ class ExegesisAArch64Target : public ExegesisTarget {
 
     if (isPointerAuth(Opcode)) {
 #if defined(__aarch64__) && defined(__linux__)
+
+      // For some systems with existing PAC keys set, it is better to
+      // check the existing state of the key before setting it.
+      // For systems without PAC, this is a No-op but with PAC, it is
+      // safer to check the existing key state and then disable/enable them.
+      // Hence the guard for switching.
+      errno = 0;
+      unsigned long PacKeys = prctl_wrapper(PR_PAC_GET_ENABLED_KEYS,
+                                            0,  // unused
+                                            0,  // unused
+                                            0,  // unused
+                                            0); // unused
+      if ((long)PacKeys < 0) {
+        if (errno == EINVAL) {
+          return "PAuth not supported on this system";
----------------
abhilash1910 wrote:

I was thinking of having nullptr check as well ; it rather differentiates between :
- PAuth is not supported and we stop (or) -> nullptr can be returned (?)
- PAuth is not supported but  we can continue 


https://github.com/llvm/llvm-project/pull/138643


More information about the llvm-commits mailing list