12 void *base
= malloc(TESTS
);
14 for (i
= 0; i
< TESTS
; i
++) {
17 in
= i
+ (uintptr_t) base
;
19 asm("mov %0, %[in]\n\t"
20 "pacia %0, sp\n\t" /* sigill if pauth not supported */
21 "eor %0, %0, #4\n\t" /* corrupt single bit */
23 "autia %1, sp\n\t" /* validate corrupted pointer */
24 "xpaci %0\n\t" /* strip pac from corrupted pointer */
25 : /* out */ "=r"(x
), "=r"(y
)
26 : /* in */ [in
] "r" (in
)
30 * Once stripped, the corrupted pointer is of the form 0x0000...wxyz.
31 * We expect the autia to indicate failure, producing a pointer of the
32 * form 0x000e....wxyz. Use xpaci and != for the test, rather than
33 * extracting explicit bits from the top, because the location of the
34 * error code "e" depends on the configuration of virtual memory.
41 perc
= (float) count
/ (float) TESTS
;
42 printf("Checks Passed: %0.2f%%", perc
* 100.0);