aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg/aarch64/pauth.h
blob: 543b234437f5fd2b0d486f8b1921c9746219e34b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
 * Helper for pauth test case
 *
 * Copyright (c) 2023 Linaro Ltd
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include <assert.h>
#include <sys/auxv.h>

static int get_pac_feature(void)
{
    unsigned long isar1, isar2;

    assert(getauxval(AT_HWCAP) & HWCAP_CPUID);

    asm("mrs %0, id_aa64isar1_el1" : "=r"(isar1));
    asm("mrs %0, S3_0_C0_C6_2" : "=r"(isar2));     /* id_aa64isar2_el1 */

    return ((isar1 >> 4) & 0xf)   /* APA */
         | ((isar1 >> 8) & 0xf)   /* API */
         | ((isar2 >> 12) & 0xf); /* APA3 */
}