xref: /linux/tools/testing/selftests/powerpc/dexcr/dexcr.h (revision fd7d598270724cc787982ea48bbe17ad383a8b7f)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * POWER Dynamic Execution Control Facility (DEXCR)
4  *
5  * This header file contains helper functions and macros
6  * required for all the DEXCR related test cases.
7  */
8 #ifndef _SELFTESTS_POWERPC_DEXCR_DEXCR_H
9 #define _SELFTESTS_POWERPC_DEXCR_DEXCR_H
10 
11 #include <stdbool.h>
12 #include <sys/types.h>
13 
14 #include "reg.h"
15 
16 #define DEXCR_PR_BIT(aspect)	__MASK(63 - (32 + (aspect)))
17 #define DEXCR_PR_SBHE		DEXCR_PR_BIT(0)
18 #define DEXCR_PR_IBRTPD		DEXCR_PR_BIT(3)
19 #define DEXCR_PR_SRAPD		DEXCR_PR_BIT(4)
20 #define DEXCR_PR_NPHIE		DEXCR_PR_BIT(5)
21 
22 #define PPC_RAW_HASH_ARGS(b, i, a) \
23 	((((i) >> 3) & 0x1F) << 21 | (a) << 16 | (b) << 11 | (((i) >> 8) & 0x1))
24 #define PPC_RAW_HASHST(b, i, a) \
25 	str(.long (0x7C0005A4 | PPC_RAW_HASH_ARGS(b, i, a));)
26 #define PPC_RAW_HASHCHK(b, i, a) \
27 	str(.long (0x7C0005E4 | PPC_RAW_HASH_ARGS(b, i, a));)
28 
29 bool dexcr_exists(void);
30 
31 bool hashchk_triggers(void);
32 
33 enum dexcr_source {
34 	DEXCR,		/* Userspace DEXCR value */
35 	HDEXCR,		/* Hypervisor enforced DEXCR value */
36 	EFFECTIVE,	/* Bitwise OR of UDEXCR and ENFORCED DEXCR bits */
37 };
38 
39 unsigned int get_dexcr(enum dexcr_source source);
40 
41 void await_child_success(pid_t pid);
42 
43 void hashst(unsigned long lr, void *sp);
44 
45 void hashchk(unsigned long lr, void *sp);
46 
47 void do_bad_hashchk(void);
48 
49 #endif  /* _SELFTESTS_POWERPC_DEXCR_DEXCR_H */
50