diff options
Diffstat (limited to 'target-s390x/cpu_models.h')
-rw-r--r-- | target-s390x/cpu_models.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/target-s390x/cpu_models.h b/target-s390x/cpu_models.h index 87de0fb12b..136a602313 100644 --- a/target-s390x/cpu_models.h +++ b/target-s390x/cpu_models.h @@ -49,7 +49,25 @@ typedef struct S390CPUModel { uint8_t cpu_ver; /* CPU version, usually "ff" for kvm */ } S390CPUModel; +/* + * CPU ID + * + * bits 0-7: Zeroes (ff for kvm) + * bits 8-31: CPU ID (serial number) + * bits 32-48: Machine type + * bits 48-63: Zeroes + */ +#define cpuid_type(x) (((x) >> 16) & 0xffff) +#define cpuid_id(x) (((x) >> 32) & 0xffffff) +#define cpuid_ver(x) (((x) >> 56) & 0xff) + +#define lowest_ibc(x) (((uint32_t)(x) >> 16) & 0xfff) +#define unblocked_ibc(x) ((uint32_t)(x) & 0xfff) +#define has_ibc(x) (lowest_ibc(x) != 0) + #define S390_GEN_Z10 0xa +#define ibc_gen(x) (x == 0 ? 0 : ((x >> 4) + S390_GEN_Z10)) +#define ibc_ec_ga(x) (x & 0xf) uint32_t s390_get_hmfai(void); uint8_t s390_get_mha_pow(void); @@ -65,5 +83,37 @@ static inline uint16_t s390_ibc_from_cpu_model(const S390CPUModel *model) } void s390_get_feat_block(S390FeatType type, uint8_t *data); bool s390_has_feat(S390Feat feat); +uint8_t s390_get_gen_for_cpu_type(uint16_t type); +static inline bool s390_known_cpu_type(uint16_t type) +{ + return s390_get_gen_for_cpu_type(type) != 0; +} +static inline uint64_t s390_cpuid_from_cpu_model(const S390CPUModel *model) +{ + return ((uint64_t)model->cpu_ver << 56) | + ((uint64_t)model->cpu_id << 32) | + ((uint64_t)model->def->type << 16); +} +S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga, + S390FeatBitmap features); + +#ifdef CONFIG_KVM +bool kvm_s390_cpu_models_supported(void); +void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp); +void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp); +#else +static inline void kvm_s390_get_host_cpu_model(S390CPUModel *model, + Error **errp) +{ +} +static inline void kvm_s390_apply_cpu_model(const S390CPUModel *model, + Error **errp) +{ +} +static inline bool kvm_s390_cpu_models_supported(void) +{ + return false; +} +#endif #endif /* TARGET_S390X_CPU_MODELS_H */ |