aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/aarch64/pauth-1.c
blob: ae6dc05c2b11bc391b9b4f6edad351cce9ee34e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <assert.h>
#include <sys/prctl.h>

asm(".arch armv8.4-a");

#ifndef PR_PAC_RESET_KEYS
#define PR_PAC_RESET_KEYS  54
#define PR_PAC_APDAKEY     (1 << 2)
#endif

int main()
{
    int x;
    void *p0 = &x, *p1, *p2;

    asm volatile("pacdza %0" : "=r"(p1) : "0"(p0));
    prctl(PR_PAC_RESET_KEYS, PR_PAC_APDAKEY, 0, 0, 0);
    asm volatile("pacdza %0" : "=r"(p2) : "0"(p0));

    assert(p1 != p0);
    assert(p1 != p2);
    return 0;
}