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

David Green via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 06:43:58 PDT 2025


davemgreen wrote:

[surprised]     David Green reacted to your message:
________________________________
From: David Green ***@***.***>
Sent: Monday, May 12, 2025 1:26:41 PM
To: llvm/llvm-project ***@***.***>
Cc: David Green ***@***.***>; Your activity ***@***.***>
Subject: Re: [llvm/llvm-project] [llvm-exegesis][AArch64] Check for PAC keys before disabling them (PR #138643)


@davemgreen commented on this pull request.

________________________________

In llvm/tools/llvm-exegesis/lib/AArch64/Target.cpp<https://github.com/llvm/llvm-project/pull/138643#discussion_r2084674919>:

> @@ -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";


I have a system where pacbti is not enabled at the system level (the linux distro does not support it yet), but it is fine to check the latency/throughput of the instructions - they are just already disabled. Trying this patch leads to a "AUTDA: PAuth not supported on this system" but we might as well allow people to try and test the instructions if they are available.

—
Reply to this email directly, view it on GitHub<https://github.com/llvm/llvm-project/pull/138643#discussion_r2084674919>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AC7SPQTYKIBP7KERVL6HKN326CORDAVCNFSM6AAAAAB4QMN4BWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDQMZTGIZDGNJWGU>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


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


More information about the llvm-commits mailing list