@@ -150,6 +150,8 @@ struct CPUS390XState {
/* currently processed sigp order */
uint8_t sigp_order;
+ /* Using Perform CPU Topology Function*/
+ bool using_ptf;
};
static inline uint64_t *get_freg(CPUS390XState *cs, int nr)
@@ -146,6 +146,7 @@ DEF_FEAT(SIE_CEI, "cei", SCLP_CPU, 43, "SIE: Conditional-external-interception f
DEF_FEAT(DAT_ENH_2, "dateh2", MISC, 0, "DAT-enhancement facility 2")
DEF_FEAT(CMM, "cmm", MISC, 0, "Collaborative-memory-management facility")
DEF_FEAT(AP, "ap", MISC, 0, "AP instructions installed")
+DEF_FEAT(CPU_TOPOLOGY, "cpu_topology", MISC, 0, "CPU Topology available")
/* Features exposed via the PLO instruction. */
DEF_FEAT(PLO_CL, "plo-cl", PLO, 0, "PLO Compare and load (32 bit in general registers)")
@@ -238,6 +238,7 @@ bool s390_has_feat(S390Feat feat)
if (s390_is_pv()) {
switch (feat) {
+ case S390_FEAT_CPU_TOPOLOGY:
case S390_FEAT_DIAG_318:
case S390_FEAT_HPMA2:
case S390_FEAT_SIE_F2:
@@ -467,6 +468,7 @@ static void check_consistency(const S390CPUModel *model)
{ S390_FEAT_DIAG_318, S390_FEAT_EXTENDED_LENGTH_SCCB },
{ S390_FEAT_NNPA, S390_FEAT_VECTOR },
{ S390_FEAT_RDP, S390_FEAT_LOCAL_TLB_CLEARING },
+ { S390_FEAT_CPU_TOPOLOGY, S390_FEAT_CONFIGURATION_TOPOLOGY },
};
int i;
@@ -488,6 +488,7 @@ static uint16_t full_GEN9_GA3[] = {
static uint16_t full_GEN10_GA1[] = {
S390_FEAT_EDAT,
S390_FEAT_CONFIGURATION_TOPOLOGY,
+ S390_FEAT_CPU_TOPOLOGY,
S390_FEAT_GROUP_MSA_EXT_2,
S390_FEAT_ESOP,
S390_FEAT_SIE_PFMFI,
@@ -604,6 +605,8 @@ static uint16_t default_GEN9_GA1[] = {
static uint16_t default_GEN10_GA1[] = {
S390_FEAT_EDAT,
S390_FEAT_GROUP_MSA_EXT_2,
+ S390_FEAT_CONFIGURATION_TOPOLOGY,
+ S390_FEAT_CPU_TOPOLOGY,
};
#define default_GEN10_GA2 EmptyFeat
@@ -612,6 +612,7 @@ int kvm_arch_put_registers(CPUState *cs, int level)
} else {
/* prefix is only supported via sync regs */
}
+
return 0;
}
@@ -2427,6 +2428,10 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model, Error **errp)
clear_bit(S390_FEAT_CMM_NT, model->features);
}
+ if (kvm_check_extension(kvm_state, KVM_CAP_S390_CPU_TOPOLOGY)) {
+ set_bit(S390_FEAT_CPU_TOPOLOGY, model->features);
+ }
+
/* bpb needs kernel support for migration, VSIE and reset */
if (!kvm_check_extension(kvm_state, KVM_CAP_S390_BPB)) {
clear_bit(S390_FEAT_BPB, model->features);
@@ -2535,6 +2540,7 @@ void kvm_s390_apply_cpu_model(const S390CPUModel *model, Error **errp)
error_setg(errp, "KVM: Error configuring CPU subfunctions: %d", rc);
return;
}
+
/* enable CMM via CMMA */
if (test_bit(S390_FEAT_CMM, model->features)) {
kvm_s390_enable_cmma();
@@ -250,6 +250,53 @@ const VMStateDescription vmstate_diag318 = {
}
};
+static int cpu_topology_presave(void *opaque)
+{
+ S390CPU *cpu = opaque;
+
+ cpu->env.using_ptf = s390_has_feat(S390_FEAT_CPU_TOPOLOGY);
+ return 0;
+}
+
+static int cpu_topology_postload(void *opaque, int version_id)
+{
+ S390CPU *cpu = opaque;
+
+ if ((cpu->env.using_ptf == s390_has_feat(S390_FEAT_CPU_TOPOLOGY)) &&
+ (cpu->env.using_ptf == s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY))) {
+ return 0;
+ }
+ if (cpu->env.using_ptf) {
+ error_report("Target needs CPU Topology enabled");
+ } else {
+ if (s390_has_feat(S390_FEAT_CONFIGURATION_TOPOLOGY)) {
+ error_report("Target is not allowed to enable configuration Topology");
+ }
+ if (s390_has_feat(S390_FEAT_CPU_TOPOLOGY)) {
+ error_report("Target is not allowed to enable CPU Topology");
+ }
+ }
+ return -EINVAL;
+}
+
+static bool cpu_topology_needed(void *opaque)
+{
+ return 1;
+}
+
+const VMStateDescription vmstate_cpu_topology = {
+ .name = "cpu/cpu_topology",
+ .version_id = 1,
+ .pre_save = cpu_topology_presave,
+ .post_load = cpu_topology_postload,
+ .minimum_version_id = 1,
+ .needed = cpu_topology_needed,
+ .fields = (VMStateField[]) {
+ VMSTATE_BOOL(env.using_ptf, S390CPU),
+ VMSTATE_END_OF_LIST()
+ }
+};
+
const VMStateDescription vmstate_s390_cpu = {
.name = "cpu",
.post_load = cpu_post_load,
@@ -287,6 +334,7 @@ const VMStateDescription vmstate_s390_cpu = {
&vmstate_bpbc,
&vmstate_etoken,
&vmstate_diag318,
+ &vmstate_cpu_topology,
NULL
},
};
Both source and target must have the same configuration regarding the activation of Perform Topology Function and Store Topology System Information. Signed-off-by: Pierre Morel <pmorel@linux.ibm.com> --- target/s390x/cpu.h | 2 ++ target/s390x/cpu_features_def.h.inc | 1 + target/s390x/cpu_models.c | 2 ++ target/s390x/gen-features.c | 3 ++ target/s390x/kvm/kvm.c | 6 ++++ target/s390x/machine.c | 48 +++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+)