xref: /kvm-unit-tests/lib/s390x/hardware.h (revision 5bf29e09122e18160c19230b4ab635e25676b6d6)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Functions to retrieve information about the host system.
4  *
5  * Copyright (c) 2020 Red Hat Inc
6  * Copyright 2022 IBM Corp.
7  *
8  * Authors:
9  *  Claudio Imbrenda <imbrenda@linux.ibm.com>
10  */
11 
12 #ifndef _S390X_HARDWARE_H_
13 #define _S390X_HARDWARE_H_
14 #include <asm/arch_def.h>
15 
16 #define MACHINE_Z15	0x8561
17 #define MACHINE_Z15T02	0x8562
18 
19 enum s390_host {
20 	HOST_IS_UNKNOWN,
21 	HOST_IS_LPAR,
22 	HOST_IS_KVM,
23 	HOST_IS_TCG
24 };
25 
26 enum s390_host detect_host(void);
27 
28 static inline bool host_is_tcg(void)
29 {
30 	return detect_host() == HOST_IS_TCG;
31 }
32 
33 static inline bool host_is_kvm(void)
34 {
35 	return detect_host() == HOST_IS_KVM;
36 }
37 
38 static inline bool host_is_lpar(void)
39 {
40 	return detect_host() == HOST_IS_LPAR;
41 }
42 
43 static inline bool machine_is_z15(void)
44 {
45 	uint16_t machine = get_machine_id();
46 
47 	return machine == MACHINE_Z15 || machine == MACHINE_Z15T02;
48 }
49 
50 #endif  /* _S390X_HARDWARE_H_ */
51