qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <dahi@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, jdenemar@redhat.com, imammedo@redhat.com,
	cornelia.huck@de.ibm.com, borntraeger@de.ibm.com,
	fiuczy@linux.vnet.ibm.com, mimu@linux.vnet.ibm.com
Subject: [Qemu-devel] [Patch v2 11/29] s390x/cpumodel: let the CPU model handle feature checks
Date: Mon,  8 Aug 2016 17:32:40 +0200	[thread overview]
Message-ID: <1470670378-53732-12-git-send-email-dahi@linux.vnet.ibm.com> (raw)
In-Reply-To: <1470670378-53732-1-git-send-email-dahi@linux.vnet.ibm.com>

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 <cornelia.huck@de.ibm.com>
Signed-off-by: David Hildenbrand <dahi@linux.vnet.ibm.com>
---
 target-s390x/cpu_models.c | 24 ++++++++++++++++++++++++
 target-s390x/cpu_models.h |  2 ++
 target-s390x/kvm.c        |  4 ++--
 target-s390x/machine.c    | 14 ++------------
 4 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/target-s390x/cpu_models.c b/target-s390x/cpu_models.c
index 5f218c2..d135661 100644
--- a/target-s390x/cpu_models.c
+++ b/target-s390x/cpu_models.c
@@ -73,6 +73,30 @@ static const 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;
diff --git a/target-s390x/cpu_models.h b/target-s390x/cpu_models.h
index 244256b..fe988cc 100644
--- a/target-s390x/cpu_models.h
+++ b/target-s390x/cpu_models.h
@@ -43,4 +43,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 */
diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c
index 80ac621..55bf6d7 100644
--- a/target-s390x/kvm.c
+++ b/target-s390x/kvm.c
@@ -1517,7 +1517,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;
     }
@@ -2089,7 +2089,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;
diff --git a/target-s390x/machine.c b/target-s390x/machine.c
index aa39e5d..edc3a47 100644
--- a/target-s390x/machine.c
+++ b/target-s390x/machine.c
@@ -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 = {
-- 
2.6.6

  parent reply	other threads:[~2016-08-08 15:33 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-08 15:32 [Qemu-devel] [Patch v2 00/29] s390x CPU models: exposing features David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 01/29] qmp: details about CPU definitions in query-cpu-definitions David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 02/29] s390x/cpumodel: "host" and "qemu" as CPU subclasses David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 03/29] s390x/cpumodel: expose CPU class properties David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 04/29] s390x/cpumodel: introduce CPU features David Hildenbrand
2016-08-16 14:36   ` Christian Borntraeger
2016-08-16 14:42     ` David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 05/29] s390x/cpumodel: generate CPU feature lists for CPU models David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 06/29] s390x/cpumodel: generate CPU feature group lists David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 07/29] s390x/cpumodel: introduce CPU feature group definitions David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 08/29] s390x/cpumodel: register defined CPU models as subclasses David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 09/29] s390x/cpumodel: store the CPU model in the CPU instance David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 10/29] s390x/cpumodel: expose features and feature groups as properties David Hildenbrand
2016-08-08 15:32 ` David Hildenbrand [this message]
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 12/29] s390x/cpumodel: check and apply the CPU model David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 13/29] s390x/sclp: factor out preparation of cpu entries David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 14/29] s390x/sclp: introduce sclp feature blocks David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 15/29] s390x/sclp: indicate sclp features David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 16/29] s390x/sclp: propagate the ibc val(lowest and unblocked ibc) David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 17/29] s390x/sclp: propagate the mha via sclp David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 18/29] s390x/sclp: propagate hmfai David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 19/29] linux-headers: update against kvm/next David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 20/29] s390x/kvm: allow runtime-instrumentation for "none" machine David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 21/29] s390x/kvm: implement CPU model support David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 22/29] s390x/kvm: disable host model for existing compat machines David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 23/29] s390x/kvm: let the CPU model control CMM(A) David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 24/29] qmp: add QMP interface "query-cpu-model-expansion" David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 25/29] qmp: add QMP interface "query-cpu-model-comparison" David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 26/29] qmp: add QMP interface "query-cpu-model-baseline" David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 27/29] s390x/cpumodel: implement QMP interface "query-cpu-model-expansion" David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 28/29] s390x/cpumodel: implement QMP interface "query-cpu-model-comparison" David Hildenbrand
2016-08-08 15:32 ` [Qemu-devel] [Patch v2 29/29] s390x/cpumodel: implement QMP interface "query-cpu-model-baseline" David Hildenbrand
2016-08-08 16:45 ` [Qemu-devel] [Patch v2 00/29] s390x CPU models: exposing features no-reply
     [not found] ` <201608081645.u78GKFHE092220@mx0b-001b2d01.pphosted.com>
2016-08-08 17:02   ` Cornelia Huck
2016-08-08 17:14     ` David Hildenbrand
     [not found] ` <201608081645.u78GjISN026387@int-mx10.intmail.prod.int.phx2.redhat.com>
2016-08-08 17:27   ` Eduardo Habkost
2016-08-09  1:08     ` Fam Zheng
2016-08-15 14:00 ` David Hildenbrand
2016-08-15 14:03   ` Christian Borntraeger
2016-08-15 14:49     ` Cornelia Huck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1470670378-53732-12-git-send-email-dahi@linux.vnet.ibm.com \
    --to=dahi@linux.vnet.ibm.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=ehabkost@redhat.com \
    --cc=fiuczy@linux.vnet.ibm.com \
    --cc=imammedo@redhat.com \
    --cc=jdenemar@redhat.com \
    --cc=mimu@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).