|
28 | 28 | #endif // HAVE_LIBPFM |
29 | 29 | #include <linux/prctl.h> // For PR_PAC_* constants |
30 | 30 | #include <sys/prctl.h> |
31 | | -#ifndef PR_PAC_SET_ENABLED_KEYS |
32 | | -#define PR_PAC_SET_ENABLED_KEYS 60 |
33 | | -#endif |
34 | | -#ifndef PR_PAC_GET_ENABLED_KEYS |
35 | | -#define PR_PAC_GET_ENABLED_KEYS 61 |
36 | | -#endif |
37 | 31 | #ifndef PR_PAC_APIAKEY |
38 | 32 | #define PR_PAC_APIAKEY (1UL << 0) |
39 | 33 | #endif |
@@ -288,6 +282,35 @@ class ExegesisAArch64Target : public ExegesisTarget { |
288 | 282 | // Function return is a pseudo-instruction that needs to be expanded |
289 | 283 | PM.add(createAArch64ExpandPseudoPass()); |
290 | 284 | } |
| 285 | + |
| 286 | + const char *getIgnoredOpcodeReasonOrNull(const LLVMState &State, |
| 287 | + unsigned Opcode) const override { |
| 288 | + if (const char *Reason = |
| 289 | + ExegesisTarget::getIgnoredOpcodeReasonOrNull(State, Opcode)) |
| 290 | + return Reason; |
| 291 | + |
| 292 | + if (isPointerAuth(Opcode)) { |
| 293 | +#if defined(__aarch64__) && defined(__linux__) |
| 294 | + // Disable all PAC keys. Note that while we expect the measurements to |
| 295 | + // be the same with PAC keys disabled, they could potentially be lower |
| 296 | + // since authentication checks are bypassed. |
| 297 | + if (prctl(PR_PAC_SET_ENABLED_KEYS, |
| 298 | + PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY | |
| 299 | + PR_PAC_APDBKEY, // all keys |
| 300 | + 0, // disable all |
| 301 | + 0, 0) < 0) { |
| 302 | + return "Failed to disable PAC keys"; |
| 303 | + } |
| 304 | +#else |
| 305 | + return "Unsupported opcode: isPointerAuth"; |
| 306 | +#endif |
| 307 | + } |
| 308 | + |
| 309 | + if (isLoadTagMultiple(Opcode)) |
| 310 | + return "Unsupported opcode: load tag multiple"; |
| 311 | + |
| 312 | + return nullptr; |
| 313 | + } |
291 | 314 | }; |
292 | 315 |
|
293 | 316 | } // namespace |
|
0 commit comments