[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [Patch v1 11/29] s390x/cpumodel: let the CPU model handle f
From: |
David Hildenbrand |
Subject: |
[Qemu-devel] [Patch v1 11/29] s390x/cpumodel: let the CPU model handle feature checks |
Date: |
Tue, 2 Aug 2016 13:58:57 +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 <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
---
target-s390x/cpu_models.c | 24 ++++++++++++++++++++++++
target-s390x/cpu_models.h | 2 ++
target-s390x/machine.c | 14 ++------------
3 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/target-s390x/cpu_models.c b/target-s390x/cpu_models.c
index 9532b46..b698b80 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/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
- [Qemu-devel] [Patch v1 07/29] s390x/cpumodel: introduce CPU feature group definitions, (continued)
- [Qemu-devel] [Patch v1 07/29] s390x/cpumodel: introduce CPU feature group definitions, David Hildenbrand, 2016/08/02
- [Qemu-devel] [Patch v1 14/29] s390x/sclp: introduce sclp feature blocks, David Hildenbrand, 2016/08/02
- [Qemu-devel] [Patch v1 12/29] s390x/cpumodel: check and apply the CPU model, David Hildenbrand, 2016/08/02
- [Qemu-devel] [Patch v1 18/29] s390x/sclp: propagate hmfai, David Hildenbrand, 2016/08/02
- [Qemu-devel] [Patch v1 24/29] qmp: add QMP interface "query-cpu-model-expansion", David Hildenbrand, 2016/08/02
[Qemu-devel] [Patch v1 09/29] s390x/cpumodel: store the CPU model in the CPU instance, David Hildenbrand, 2016/08/02
[Qemu-devel] [Patch v1 11/29] s390x/cpumodel: let the CPU model handle feature checks,
David Hildenbrand <=
[Qemu-devel] [Patch v1 20/29] s390x/kvm: allow runtime-instrumentation for "none" machine, David Hildenbrand, 2016/08/02
[Qemu-devel] [Patch v1 19/29] linux-headers: update against kvm/next, David Hildenbrand, 2016/08/02
[Qemu-devel] [Patch v1 21/29] s390x/kvm: implement CPU model support, David Hildenbrand, 2016/08/02
[Qemu-devel] [Patch v1 22/29] s390x/kvm: disable host model for existing compat machines, David Hildenbrand, 2016/08/02
[Qemu-devel] [Patch v1 25/29] qmp: add QMP interface "query-cpu-model-comparison", David Hildenbrand, 2016/08/02