2016-09-05 11:52:22 +03:00
|
|
|
/*
|
|
|
|
* CPU models for s390x
|
|
|
|
*
|
|
|
|
* Copyright 2016 IBM Corp.
|
|
|
|
*
|
|
|
|
* Author(s): David Hildenbrand <dahi@linux.vnet.ibm.com>
|
|
|
|
*
|
|
|
|
* This work is licensed under the terms of the GNU GPL, version 2 or (at
|
|
|
|
* your option) any later version. See the COPYING file in the top-level
|
|
|
|
* directory.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TARGET_S390X_CPU_MODELS_H
|
|
|
|
#define TARGET_S390X_CPU_MODELS_H
|
|
|
|
|
|
|
|
#include "cpu_features.h"
|
2019-08-17 13:55:32 +03:00
|
|
|
#include "target/s390x/gen-features.h"
|
2019-07-09 18:20:52 +03:00
|
|
|
#include "hw/core/cpu.h"
|
2016-09-05 11:52:22 +03:00
|
|
|
|
|
|
|
/* static CPU definition */
|
2023-10-13 12:35:04 +03:00
|
|
|
typedef struct S390CPUDef {
|
2016-09-05 11:52:22 +03:00
|
|
|
const char *name; /* name exposed to the user */
|
|
|
|
const char *desc; /* description exposed to the user */
|
|
|
|
uint8_t gen; /* hw generation identification */
|
|
|
|
uint16_t type; /* cpu type identification */
|
|
|
|
uint8_t ec_ga; /* EC GA version (on which also the BC is based) */
|
2022-11-11 21:17:33 +03:00
|
|
|
uint8_t mha_pow; /* maximum host address power, mha = 2^pow-1 */
|
2016-09-05 11:52:22 +03:00
|
|
|
uint32_t hmfai; /* hypervisor-managed facilities */
|
|
|
|
/* base/min features, must never be changed between QEMU versions */
|
|
|
|
S390FeatBitmap base_feat;
|
|
|
|
/* used to init base_feat from generated data */
|
|
|
|
S390FeatInit base_init;
|
2022-11-11 21:17:33 +03:00
|
|
|
/* default features, QEMU version specific */
|
2016-09-05 11:52:22 +03:00
|
|
|
S390FeatBitmap default_feat;
|
|
|
|
/* used to init default_feat from generated data */
|
|
|
|
S390FeatInit default_init;
|
|
|
|
/* max allowed features, QEMU version specific */
|
|
|
|
S390FeatBitmap full_feat;
|
|
|
|
/* used to init full_feat from generated data */
|
|
|
|
S390FeatInit full_init;
|
2023-10-13 12:35:04 +03:00
|
|
|
} S390CPUDef;
|
2016-09-05 11:52:22 +03:00
|
|
|
|
2016-09-05 11:52:23 +03:00
|
|
|
/* CPU model based on a CPU definition */
|
2023-10-13 12:35:04 +03:00
|
|
|
typedef struct S390CPUModel {
|
2016-09-05 11:52:23 +03:00
|
|
|
const S390CPUDef *def;
|
|
|
|
S390FeatBitmap features;
|
|
|
|
/* values copied from the "host" model, can change during migration */
|
|
|
|
uint16_t lowest_ibc; /* lowest IBC that the hardware supports */
|
|
|
|
uint32_t cpu_id; /* CPU id */
|
2017-05-31 22:34:33 +03:00
|
|
|
uint8_t cpu_id_format; /* CPU id format bit */
|
2016-09-05 11:52:23 +03:00
|
|
|
uint8_t cpu_ver; /* CPU version, usually "ff" for kvm */
|
2023-10-13 12:35:04 +03:00
|
|
|
} S390CPUModel;
|
2016-09-05 11:52:23 +03:00
|
|
|
|
2016-09-05 11:52:35 +03:00
|
|
|
/*
|
|
|
|
* CPU ID
|
|
|
|
*
|
|
|
|
* bits 0-7: Zeroes (ff for kvm)
|
|
|
|
* bits 8-31: CPU ID (serial number)
|
2017-05-31 22:34:33 +03:00
|
|
|
* bits 32-47: Machine type
|
|
|
|
* bit 48: CPU ID format
|
|
|
|
* bits 49-63: Zeroes
|
2016-09-05 11:52:35 +03:00
|
|
|
*/
|
|
|
|
#define cpuid_type(x) (((x) >> 16) & 0xffff)
|
|
|
|
#define cpuid_id(x) (((x) >> 32) & 0xffffff)
|
|
|
|
#define cpuid_ver(x) (((x) >> 56) & 0xff)
|
2017-05-31 22:34:33 +03:00
|
|
|
#define cpuid_format(x) (((x) >> 15) & 0x1)
|
2016-09-05 11:52:35 +03:00
|
|
|
|
|
|
|
#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)
|
|
|
|
|
2016-09-05 11:52:30 +03:00
|
|
|
#define S390_GEN_Z10 0xa
|
2016-09-05 11:52:35 +03:00
|
|
|
#define ibc_gen(x) (x == 0 ? 0 : ((x >> 4) + S390_GEN_Z10))
|
|
|
|
#define ibc_ec_ga(x) (x & 0xf)
|
2016-09-05 11:52:30 +03:00
|
|
|
|
2017-04-10 16:39:00 +03:00
|
|
|
void s390_cpudef_featoff(uint8_t gen, uint8_t ec_ga, S390Feat feat);
|
|
|
|
void s390_cpudef_featoff_greater(uint8_t gen, uint8_t ec_ga, S390Feat feat);
|
2019-02-12 04:16:56 +03:00
|
|
|
void s390_cpudef_group_featoff_greater(uint8_t gen, uint8_t ec_ga,
|
|
|
|
S390FeatGroup group);
|
2016-09-05 11:52:32 +03:00
|
|
|
uint32_t s390_get_hmfai(void);
|
2016-09-05 11:52:31 +03:00
|
|
|
uint8_t s390_get_mha_pow(void);
|
2016-09-05 11:52:30 +03:00
|
|
|
uint32_t s390_get_ibc_val(void);
|
|
|
|
static inline uint16_t s390_ibc_from_cpu_model(const S390CPUModel *model)
|
|
|
|
{
|
|
|
|
uint16_t ibc = 0;
|
|
|
|
|
|
|
|
if (model->def->gen >= S390_GEN_Z10) {
|
|
|
|
ibc = ((model->def->gen - S390_GEN_Z10) << 4) + model->def->ec_ga;
|
|
|
|
}
|
|
|
|
return ibc;
|
|
|
|
}
|
2016-09-05 11:52:29 +03:00
|
|
|
void s390_get_feat_block(S390FeatType type, uint8_t *data);
|
2016-09-05 11:52:25 +03:00
|
|
|
bool s390_has_feat(S390Feat feat);
|
2016-09-05 11:52:35 +03:00
|
|
|
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;
|
|
|
|
}
|
s390x/tcg: Fix CPU address returned by STIDP
In qemu-user-s390x, /proc/cpuinfo contains:
processor 0: version = 00, identification = 000000, machine = 8561
processor 1: version = 00, identification = 400000, machine = 8561
The highest nibble is supposed to contain the CPU address, but it's off
by 2 bits. Fix the shift value and provide a symbolic constant for it.
With the fix we get:
processor 0: version = 00, identification = 000000, machine = 8561
processor 1: version = 00, identification = 100000, machine = 8561
Fixes: 076d4d39b65f ("s390x/cpumodel: wire up cpu type + id for TCG")
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20230605113950.1169228-2-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2023-06-05 14:39:47 +03:00
|
|
|
#define CPU_ID_SHIFT 32
|
|
|
|
#define CPU_ID_BITS 24
|
|
|
|
/*
|
|
|
|
* When cpu_id_format is 0 (basic mode), the leftmost 4 bits of cpu_id contain
|
|
|
|
* the rightmost 4 bits of the physical CPU address.
|
|
|
|
*/
|
|
|
|
#define CPU_PHYS_ADDR_BITS 4
|
|
|
|
#define CPU_PHYS_ADDR_SHIFT (CPU_ID_SHIFT + CPU_ID_BITS - CPU_PHYS_ADDR_BITS)
|
2016-09-05 11:52:35 +03:00
|
|
|
static inline uint64_t s390_cpuid_from_cpu_model(const S390CPUModel *model)
|
|
|
|
{
|
|
|
|
return ((uint64_t)model->cpu_ver << 56) |
|
s390x/tcg: Fix CPU address returned by STIDP
In qemu-user-s390x, /proc/cpuinfo contains:
processor 0: version = 00, identification = 000000, machine = 8561
processor 1: version = 00, identification = 400000, machine = 8561
The highest nibble is supposed to contain the CPU address, but it's off
by 2 bits. Fix the shift value and provide a symbolic constant for it.
With the fix we get:
processor 0: version = 00, identification = 000000, machine = 8561
processor 1: version = 00, identification = 100000, machine = 8561
Fixes: 076d4d39b65f ("s390x/cpumodel: wire up cpu type + id for TCG")
Reviewed-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Message-Id: <20230605113950.1169228-2-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2023-06-05 14:39:47 +03:00
|
|
|
((uint64_t)model->cpu_id << CPU_ID_SHIFT) |
|
2017-05-31 22:34:33 +03:00
|
|
|
((uint64_t)model->def->type << 16) |
|
|
|
|
(model->def->gen == 7 ? 0 : (uint64_t)model->cpu_id_format << 15);
|
2016-09-05 11:52:35 +03:00
|
|
|
}
|
|
|
|
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
|
2016-09-05 11:52:25 +03:00
|
|
|
|
2016-09-05 11:52:22 +03:00
|
|
|
#endif /* TARGET_S390X_CPU_MODELS_H */
|