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

via llvm-commits llvm-commits at lists.llvm.org
Tue May 6 00:16:11 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tools-llvm-exegesis

Author: Abhilash Majumder (abhilash1910)

<details>
<summary>Changes</summary>

[llvm-exegesis][AArch64] Check for PAC keys before disabling them.

Tries to resolve aarch64 error arising from accessible PAC keys from PR: [Disable pauth and ldgm as unsupported instructions fixed](https://github.com/llvm/llvm-project/pull/136868). The suspected reason is in some systems, the pac keys are present and need to be checked before setting them.

This is followup to merge the changes with following changes to attempt to fixup the arch64 failure.

Changes:

Apply checks to verify if PAC is enabled in some systems and disabling them . 

@<!-- -->lakshayk-nv  please help to verify and review. 
cc  @<!-- -->sjoerdmeijer @<!-- -->davemgreen 

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


1 Files Affected:

- (modified) llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp (+17-7) 


``````````diff
diff --git a/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp b/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
index a1eb5a46f21fc..d1da6f41461a7 100644
--- a/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp
@@ -207,16 +207,26 @@ class ExegesisAArch64Target : public ExegesisTarget {
 
     if (isPointerAuth(Opcode)) {
 #if defined(__aarch64__) && defined(__linux__)
+      
+      // Fix for some systems where PAC/PAG keys are present but is 
+      // explicitly getting disabled
+      unsigned long pac_keys = 0;
+      if (prctl(PR_PAC_GET_ENABLED_KEYS, &pac_keys, 0, 0, 0) < 0) {
+        return "Failed to get PAC key status";
+      }
+      
       // Disable all PAC keys. Note that while we expect the measurements to
       // be the same with PAC keys disabled, they could potentially be lower
       // since authentication checks are bypassed.
-      if (prctl(PR_PAC_SET_ENABLED_KEYS,
-                PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY |
-                    PR_PAC_APDBKEY, // all keys
-                0,                  // disable all
-                0, 0) < 0) {
-        return "Failed to disable PAC keys";
-      }
+      if (pac_keys != 0) {
+        if (prctl(PR_PAC_SET_ENABLED_KEYS,
+                  PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY |
+                      PR_PAC_APDBKEY, // all keys
+                  0,                  // disable all
+                  0, 0) < 0) {
+          return "Failed to disable PAC keys";
+        }
+      } 
 #else
       return "Unsupported opcode: isPointerAuth";
 #endif

``````````

</details>


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


More information about the llvm-commits mailing list