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 165bf29e09SClaudio Imbrenda #define MACHINE_Z15 0x8561 175bf29e09SClaudio Imbrenda #define MACHINE_Z15T02 0x8562 185bf29e09SClaudio 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 get_machine_id(void)2895da193aSClaudio Imbrendastatic inline uint16_t get_machine_id(void) 2995da193aSClaudio Imbrenda { 3095da193aSClaudio Imbrenda return stidp() >> 16; 3195da193aSClaudio Imbrenda } 3295da193aSClaudio Imbrenda host_is_tcg(void)33f489dfa5SClaudio Imbrendastatic inline bool host_is_tcg(void) 34f489dfa5SClaudio Imbrenda { 35f489dfa5SClaudio Imbrenda return detect_host() == HOST_IS_TCG; 36f489dfa5SClaudio Imbrenda } 37f489dfa5SClaudio Imbrenda host_is_kvm(void)38f489dfa5SClaudio Imbrendastatic inline bool host_is_kvm(void) 39f489dfa5SClaudio Imbrenda { 40f489dfa5SClaudio Imbrenda return detect_host() == HOST_IS_KVM; 41f489dfa5SClaudio Imbrenda } 42f489dfa5SClaudio Imbrenda host_is_lpar(void)43f489dfa5SClaudio Imbrendastatic inline bool host_is_lpar(void) 44f489dfa5SClaudio Imbrenda { 45f489dfa5SClaudio Imbrenda return detect_host() == HOST_IS_LPAR; 46f489dfa5SClaudio Imbrenda } 47f489dfa5SClaudio Imbrenda host_is_qemu(void)48*fde06419SJanosch Frankstatic inline bool host_is_qemu(void) 49*fde06419SJanosch Frank { 50*fde06419SJanosch Frank return host_is_tcg() || host_is_kvm(); 51*fde06419SJanosch Frank } 52*fde06419SJanosch Frank machine_is_z15(void)535bf29e09SClaudio Imbrendastatic inline bool machine_is_z15(void) 545bf29e09SClaudio Imbrenda { 555bf29e09SClaudio Imbrenda uint16_t machine = get_machine_id(); 565bf29e09SClaudio Imbrenda 575bf29e09SClaudio Imbrenda return machine == MACHINE_Z15 || machine == MACHINE_Z15T02; 585bf29e09SClaudio Imbrenda } 595bf29e09SClaudio Imbrenda 60f489dfa5SClaudio Imbrenda #endif /* _S390X_HARDWARE_H_ */ 61