xref: /kvm-unit-tests/lib/s390x/fault.h (revision 2c96b77ec9d3b1fcec7525174e23a6240ee05949)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Headers for fault.c
4  *
5  * Copyright 2021 IBM Corp.
6  *
7  * Authors:
8  *    Janosch Frank <frankja@linux.ibm.com>
9  */
10 #ifndef _S390X_FAULT_H_
11 #define _S390X_FAULT_H_
12 
13 #include <bitops.h>
14 
15 /* Instruction execution prevention, i.e. no-execute, 101 */
16 static inline bool prot_is_iep(uint64_t teid)
17 {
18 	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && test_bit_inv(61, &teid))
19 		return true;
20 
21 	return false;
22 }
23 
24 /* Standard DAT exception, 001 */
25 static inline bool prot_is_datp(uint64_t teid)
26 {
27 	if (!test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && test_bit_inv(61, &teid))
28 		return true;
29 
30 	return false;
31 }
32 
33 /* Low-address protection exception, 100 */
34 static inline bool prot_is_lap(uint64_t teid)
35 {
36 	if (test_bit_inv(56, &teid) && !test_bit_inv(60, &teid) && !test_bit_inv(61, &teid))
37 		return true;
38 
39 	return false;
40 }
41 
42 void print_decode_teid(uint64_t teid);
43 
44 #endif /* _S390X_FAULT_H_ */
45