Skip to content

Commit a88910d

Browse files
committed
fix pac/pag
1 parent cd6c4b6 commit a88910d

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,26 @@ class ExegesisAArch64Target : public ExegesisTarget {
207207

208208
if (isPointerAuth(Opcode)) {
209209
#if defined(__aarch64__) && defined(__linux__)
210+
211+
// Fix for some systems where PAC/PAG keys are present but is
212+
// explicitly getting disabled
213+
unsigned long pac_keys = 0;
214+
if (prctl(PR_PAC_GET_ENABLED_KEYS, &pac_keys, 0, 0, 0) < 0) {
215+
return "Failed to get PAC key status";
216+
}
217+
210218
// Disable all PAC keys. Note that while we expect the measurements to
211219
// be the same with PAC keys disabled, they could potentially be lower
212220
// since authentication checks are bypassed.
213-
if (prctl(PR_PAC_SET_ENABLED_KEYS,
214-
PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY |
215-
PR_PAC_APDBKEY, // all keys
216-
0, // disable all
217-
0, 0) < 0) {
218-
return "Failed to disable PAC keys";
219-
}
221+
if (pac_keys != 0) {
222+
if (prctl(PR_PAC_SET_ENABLED_KEYS,
223+
PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY |
224+
PR_PAC_APDBKEY, // all keys
225+
0, // disable all
226+
0, 0) < 0) {
227+
return "Failed to disable PAC keys";
228+
}
229+
}
220230
#else
221231
return "Unsupported opcode: isPointerAuth";
222232
#endif

0 commit comments

Comments
 (0)