blob: 8816e1869cc49a8e3e12acd055cf2c557493280c [file] [log] [blame]
Alexei Fedorov719714f2019-10-03 10:57:53 +01001/*
Shruti Gupta9d0cfe82023-04-17 10:57:26 +01002 * Copyright (c) 2019-2023, Arm Limited. All rights reserved.
Alexei Fedorov719714f2019-10-03 10:57:53 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef PAUTH_H
8#define PAUTH_H
9
Shruti Gupta9d0cfe82023-04-17 10:57:26 +010010#include <stdbool.h>
Alexei Fedorov719714f2019-10-03 10:57:53 +010011#include <stdint.h>
12
13#ifdef __aarch64__
Shruti Gupta21a30ed2024-01-13 23:07:43 +000014/* Number of ARMv8.3-PAuth keys */
15#define NUM_KEYS 5U
16
17static const char * const key_name[] = {"IA", "IB", "DA", "DB", "GA"};
18
Alexei Fedorov719714f2019-10-03 10:57:53 +010019/* Initialize 128-bit ARMv8.3-PAuth key */
20uint128_t init_apkey(void);
21
22/* Program APIAKey_EL1 key and enable ARMv8.3-PAuth */
23void pauth_init_enable(void);
Alexei Fedorov52fd7332020-01-08 14:02:18 +000024
25/* Disable ARMv8.3-PAuth */
26void pauth_disable(void);
Shruti Gupta9d0cfe82023-04-17 10:57:26 +010027
28/*
29 * Fill Pauth Keys and template with random values if keys werenot initialized earlier,
30 * Else Copy PAuth key registers to template.
31 */
Shruti Gupta21a30ed2024-01-13 23:07:43 +000032void pauth_test_lib_fill_regs_and_template(uint128_t *pauth_keys_arr);
Shruti Gupta9d0cfe82023-04-17 10:57:26 +010033
34/* Read and Compare PAuth registers with provided template values. */
Shruti Gupta21a30ed2024-01-13 23:07:43 +000035bool pauth_test_lib_compare_template(uint128_t *pauth_keys_before, uint128_t *pauth_keys_after);
Shruti Gupta9d0cfe82023-04-17 10:57:26 +010036
37/* Read and Store PAuth registers in template. */
Shruti Gupta21a30ed2024-01-13 23:07:43 +000038void pauth_test_lib_read_keys(uint128_t *pauth_keys_arr);
Shruti Gupta9d0cfe82023-04-17 10:57:26 +010039
40/* Test PAuth instructions. */
41void pauth_test_lib_test_intrs(void);
42
Alexei Fedorov719714f2019-10-03 10:57:53 +010043#endif /* __aarch64__ */
44
45#endif /* PAUTH_H */