[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-2.8 38/38] s390x/cpumodel: implement QMP interfa
From: |
Cornelia Huck |
Subject: |
[Qemu-devel] [PATCH for-2.8 38/38] s390x/cpumodel: implement QMP interface "query-cpu-model-baseline" |
Date: |
Mon, 29 Aug 2016 13:45:30 +0200 |
From: David Hildenbrand <address@hidden>
Let's implement that interface by reusing our conversion code and
lookup code for CPU definitions.
In order to find a compatible CPU model, we first detect the maximum
possible CPU generation and then try to find a maximum model, satisfying
all base features (not exceeding the maximum generation).
Acked-by: Cornelia Huck <address@hidden>
Signed-off-by: David Hildenbrand <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Cornelia Huck <address@hidden>
---
qapi-schema.json | 3 ++-
target-s390x/cpu_models.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/qapi-schema.json b/qapi-schema.json
index 955a2b9..c4f3674 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -3283,7 +3283,8 @@
# global properties may affect expansion of CPU models. Using
# query-cpu-model-expansion while using these is not advised.
#
-# Some architectures may not support baselining CPU models.
+# Some architectures may not support baselining CPU models. s390x supports
+# baselining CPU models.
#
# Returns: a CpuModelBaselineInfo. Returns an error if baselining CPU models is
# not supported, if a model cannot be used, if a model contains
diff --git a/target-s390x/cpu_models.c b/target-s390x/cpu_models.c
index cd37bb1..755d35a 100644
--- a/target-s390x/cpu_models.c
+++ b/target-s390x/cpu_models.c
@@ -534,6 +534,61 @@ CpuModelCompareInfo
*arch_query_cpu_model_comparison(CpuModelInfo *infoa,
}
return compare_info;
}
+
+CpuModelBaselineInfo *arch_query_cpu_model_baseline(CpuModelInfo *infoa,
+ CpuModelInfo *infob,
+ Error **errp)
+{
+ CpuModelBaselineInfo *baseline_info;
+ S390CPUModel modela, modelb, model;
+ uint16_t cpu_type;
+ uint8_t max_gen_ga;
+ uint8_t max_gen;
+
+ /* convert both models to our internal representation */
+ cpu_model_from_info(&modela, infoa, errp);
+ if (*errp) {
+ return NULL;
+ }
+
+ cpu_model_from_info(&modelb, infob, errp);
+ if (*errp) {
+ return NULL;
+ }
+
+ /* features both models support */
+ bitmap_and(model.features, modela.features, modelb.features,
S390_FEAT_MAX);
+
+ /* detect the maximum model not regarding features */
+ if (modela.def->gen == modelb.def->gen) {
+ if (modela.def->type == modelb.def->type) {
+ cpu_type = modela.def->type;
+ } else {
+ cpu_type = 0;
+ }
+ max_gen = modela.def->gen;
+ max_gen_ga = MIN(modela.def->ec_ga, modelb.def->ec_ga);
+ } else if (modela.def->gen > modelb.def->gen) {
+ cpu_type = modelb.def->type;
+ max_gen = modelb.def->gen;
+ max_gen_ga = modelb.def->ec_ga;
+ } else {
+ cpu_type = modela.def->type;
+ max_gen = modela.def->gen;
+ max_gen_ga = modela.def->ec_ga;
+ }
+
+ model.def = s390_find_cpu_def(cpu_type, max_gen, max_gen_ga,
+ model.features);
+ /* strip off features not part of the max model */
+ bitmap_and(model.features, model.features, model.def->full_feat,
+ S390_FEAT_MAX);
+
+ baseline_info = g_malloc0(sizeof(*baseline_info));
+ baseline_info->model = g_malloc0(sizeof(*baseline_info->model));
+ cpu_info_from_model(baseline_info->model, &model, true);
+ return baseline_info;
+}
#endif
static void check_consistency(const S390CPUModel *model)
--
2.9.3
- [Qemu-devel] [PATCH for-2.8 04/38] s390/sclp: cache the sclp device, (continued)
- [Qemu-devel] [PATCH for-2.8 04/38] s390/sclp: cache the sclp device, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 05/38] s390x: wrap flic savevm calls into vmstate, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 07/38] s390x/css: handle cssid 255 correctly, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 16/38] s390x/cpumodel: introduce CPU feature group definitions, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 01/38] s390x: add compat machine for 2.8, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 26/38] s390x/sclp: propagate the mha via sclp, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 17/38] s390x/cpumodel: register defined CPU models as subclasses, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 25/38] s390x/sclp: propagate the ibc val (lowest and unblocked ibc), Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 21/38] s390x/cpumodel: check and apply the CPU model, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 06/38] s390x/ioinst: advertise fcs facility, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 38/38] s390x/cpumodel: implement QMP interface "query-cpu-model-baseline",
Cornelia Huck <=
- [Qemu-devel] [PATCH for-2.8 12/38] s390x/cpumodel: expose CPU class properties, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 20/38] s390x/cpumodel: let the CPU model handle feature checks, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 31/38] s390x/kvm: let the CPU model control CMM(A), Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 09/38] s390x/kvm: 2 byte software breakpoint support, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 28/38] s390x/kvm: allow runtime-instrumentation for "none" machine, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 24/38] s390x/sclp: indicate sclp features, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 18/38] s390x/cpumodel: store the CPU model in the CPU instance, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 35/38] qmp: add QMP interface "query-cpu-model-baseline", Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 27/38] s390x/sclp: propagate hmfai, Cornelia Huck, 2016/08/29
- [Qemu-devel] [PATCH for-2.8 36/38] s390x/cpumodel: implement QMP interface "query-cpu-model-expansion", Cornelia Huck, 2016/08/29