docs/system/gdb.rst: Add some more heading structure
[qemu/ar7.git] / tests / tcg / aarch64 / pauth-5.c
blob67c257918b92c4445fd3422dd7643b96113f21d3
1 #include <assert.h>
3 static int x;
5 int main()
7 int *p0 = &x, *p1, *p2, *p3;
8 unsigned long salt = 0;
11 * With TBI enabled and a 48-bit VA, there are 7 bits of auth, and so
12 * a 1/128 chance of auth = pac(ptr,key,salt) producing zero.
13 * Find a salt that creates auth != 0.
15 do {
16 salt++;
17 asm("pacda %0, %1" : "=r"(p1) : "r"(salt), "0"(p0));
18 } while (p0 == p1);
21 * This pac must fail, because the input pointer bears an encryption,
22 * and so is not properly extended within bits [55:47]. This will
23 * toggle bit 54 in the output...
25 asm("pacda %0, %1" : "=r"(p2) : "r"(salt), "0"(p1));
27 /* ... so that the aut must fail, setting bit 53 in the output ... */
28 asm("autda %0, %1" : "=r"(p3) : "r"(salt), "0"(p2));
30 /* ... which means this equality must not hold. */
31 assert(p3 != p0);
32 return 0;