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