[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 10/28] s390x/cpumodel: let the CPU model handle featur
From: |
David Hildenbrand |
Subject: |
[Qemu-devel] [RFC 10/28] s390x/cpumodel: let the CPU model handle feature checks |
Date: |
Tue, 21 Jun 2016 15:02:15 +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 93e63cb..7e3f544 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] [RFC 00/28] s390x CPU models: exposing features, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 11/28] s390x/cpumodel: check and apply the CPU model, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 01/28] s390x/cpumodel: "host" and "qemu" as CPU subclasses, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 03/28] s390x/cpumodel: introduce CPU features, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 15/28] s390x/sclp: propagate the ibc val(lowest and unblocked ibc), David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 07/28] s390x/cpumodel: register defined CPU models as subclasses, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 08/28] s390x/cpumodel: store the CPU model in the CPU instance, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 05/28] s390x/cpumodel: generate CPU feature group lists, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 19/28] s390x/kvm: allow runtime-instrumentation for "none" machine, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 10/28] s390x/cpumodel: let the CPU model handle feature checks,
David Hildenbrand <=
- [Qemu-devel] [RFC 14/28] s390x/sclp: indicate sclp features, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 13/28] s390x/sclp: introduce sclp feature blocks, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 04/28] s390x/cpumodel: generate CPU feature lists for CPU models, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 02/28] s390x/cpumodel: expose CPU class properties, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 23/28] qmp: add QMP interface "query-cpu-model-expansion", David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 06/28] s390x/cpumodel: introduce CPU feature group definitions, David Hildenbrand, 2016/06/21
- [Qemu-devel] [RFC 12/28] s390x/sclp: factor out preparation of cpu entries, David Hildenbrand, 2016/06/21