]> Git Repo - qemu.git/commitdiff
s390x/cpumodel: let the CPU model handle feature checks
authorDavid Hildenbrand <[email protected]>
Mon, 5 Sep 2016 08:52:25 +0000 (10:52 +0200)
committerCornelia Huck <[email protected]>
Tue, 6 Sep 2016 15:06:50 +0000 (17:06 +0200)
If we have certain features enabled, we have to migrate additional state
(e.g. vector registers or runtime-instrumentation registers). Let the
CPU model control that unless we have no "host" CPU model in the KVM
case. This will later on be the case for compatibility machines, so
migration from QEMU versions without the CPU model will still work.

Acked-by: Cornelia Huck <[email protected]>
Signed-off-by: David Hildenbrand <[email protected]>
Message-Id: <20160905085244[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
target-s390x/cpu_models.c
target-s390x/cpu_models.h
target-s390x/kvm.c
target-s390x/machine.c

index 57e3bd0a595627b3b5b759b8722a40f392c8379b..3545bad4d6885bcdb89bd77afe53e8fb5cabcbbe 100644 (file)
@@ -73,6 +73,31 @@ static S390CPUDef s390_cpu_defs[] = {
     CPUDEF_INIT(0x2965, 13, 2, 47, 0x08000000U, "z13s", "IBM z13s GA1"),
 };
 
+bool s390_has_feat(S390Feat feat)
+{
+    static S390CPU *cpu;
+
+    if (!cpu) {
+        cpu = S390_CPU(qemu_get_cpu(0));
+    }
+
+    if (!cpu || !cpu->model) {
+#ifdef CONFIG_KVM
+        if (kvm_enabled()) {
+            if (feat == S390_FEAT_VECTOR) {
+                return kvm_check_extension(kvm_state,
+                                           KVM_CAP_S390_VECTOR_REGISTERS);
+            }
+            if (feat == S390_FEAT_RUNTIME_INSTRUMENTATION) {
+                return kvm_s390_get_ri();
+            }
+        }
+#endif
+        return 0;
+    }
+    return test_bit(feat, cpu->model->features);
+}
+
 struct S390PrintCpuListInfo {
     FILE *f;
     fprintf_function print;
index f3f3f3c32b6c3cf9a495d2872365f998cafb4c5b..cca865d3b8f57de1f176a942c73cc5ba6f320fbb 100644 (file)
@@ -49,4 +49,6 @@ typedef struct S390CPUModel {
     uint8_t cpu_ver;        /* CPU version, usually "ff" for kvm */
 } S390CPUModel;
 
+bool s390_has_feat(S390Feat feat);
+
 #endif /* TARGET_S390X_CPU_MODELS_H */
index 4341d5496957793b5fffea0628e6bd88a4624166..4f32a6b4a0e3922e7484eee67e7e16e74f814ccc 100644 (file)
@@ -1539,7 +1539,7 @@ static void sigp_store_adtl_status(void *arg)
 {
     SigpInfo *si = arg;
 
-    if (!kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS)) {
+    if (!s390_has_feat(S390_FEAT_VECTOR)) {
         set_sigp_status(si, SIGP_STAT_INVALID_ORDER);
         return;
     }
@@ -2119,7 +2119,7 @@ static uint64_t build_channel_report_mcic(void)
         MCIC_VB_WP | MCIC_VB_MS | MCIC_VB_PM | MCIC_VB_IA | MCIC_VB_FP |
         MCIC_VB_GR | MCIC_VB_CR | MCIC_VB_ST | MCIC_VB_AR | MCIC_VB_PR |
         MCIC_VB_FC | MCIC_VB_CT | MCIC_VB_CC;
-    if (kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS)) {
+    if (s390_has_feat(S390_FEAT_VECTOR)) {
         mcic |= MCIC_VB_VR;
     }
     return mcic;
index aa39e5daa4998e6c05bb7bc5fd17b08bbf6fe72d..edc3a4717bd24b66fe008393f699bb7721f5f07a 100644 (file)
@@ -78,12 +78,7 @@ static const VMStateDescription vmstate_fpu = {
 
 static bool vregs_needed(void *opaque)
 {
-#ifdef CONFIG_KVM
-    if (kvm_enabled()) {
-        return kvm_check_extension(kvm_state, KVM_CAP_S390_VECTOR_REGISTERS);
-    }
-#endif
-    return 0;
+    return s390_has_feat(S390_FEAT_VECTOR);
 }
 
 static const VMStateDescription vmstate_vregs = {
@@ -147,12 +142,7 @@ static const VMStateDescription vmstate_vregs = {
 
 static bool riccb_needed(void *opaque)
 {
-#ifdef CONFIG_KVM
-    if (kvm_enabled()) {
-        return kvm_s390_get_ri();
-    }
-#endif
-    return 0;
+    return s390_has_feat(S390_FEAT_RUNTIME_INSTRUMENTATION);
 }
 
 const VMStateDescription vmstate_riccb = {
This page took 0.034111 seconds and 4 git commands to generate.