xref: /openbmc/qemu/tests/tcg/aarch64/pauth.h (revision ed75658a)
1 /*
2  * Helper for pauth test case
3  *
4  * Copyright (c) 2023 Linaro Ltd
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  */
7 
8 #include <assert.h>
9 #include <sys/auxv.h>
10 
11 static int get_pac_feature(void)
12 {
13     unsigned long isar1, isar2;
14 
15     assert(getauxval(AT_HWCAP) & HWCAP_CPUID);
16 
17     asm("mrs %0, id_aa64isar1_el1" : "=r"(isar1));
18     asm("mrs %0, S3_0_C0_C6_2" : "=r"(isar2));     /* id_aa64isar2_el1 */
19 
20     return ((isar1 >> 4) & 0xf)   /* APA */
21          | ((isar1 >> 8) & 0xf)   /* API */
22          | ((isar2 >> 12) & 0xf); /* APA3 */
23 }
24