From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51111) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWmYZ-0001fS-Qc for qemu-devel@nongnu.org; Mon, 08 Aug 2016 11:33:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWmYW-0005It-T5 for qemu-devel@nongnu.org; Mon, 08 Aug 2016 11:33:35 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:28790 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWmYW-0005IT-Ka for qemu-devel@nongnu.org; Mon, 08 Aug 2016 11:33:32 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u78FOgsW090907 for ; Mon, 8 Aug 2016 11:33:32 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 24nc1pw37e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Aug 2016 11:33:32 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Aug 2016 16:33:30 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4B72117D8024 for ; Mon, 8 Aug 2016 16:35:06 +0100 (BST) Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u78FXRwr24117248 for ; Mon, 8 Aug 2016 15:33:27 GMT Received: from d06av02.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u78FXRJZ000355 for ; Mon, 8 Aug 2016 09:33:27 -0600 From: David Hildenbrand Date: Mon, 8 Aug 2016 17:32:58 +0200 In-Reply-To: <1470670378-53732-1-git-send-email-dahi@linux.vnet.ibm.com> References: <1470670378-53732-1-git-send-email-dahi@linux.vnet.ibm.com> Message-Id: <1470670378-53732-30-git-send-email-dahi@linux.vnet.ibm.com> Subject: [Qemu-devel] [Patch v2 29/29] s390x/cpumodel: implement QMP interface "query-cpu-model-baseline" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 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 Signed-off-by: David Hildenbrand --- 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 ddf921b..6673e89 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 7903f02..16290ba 100644 --- a/target-s390x/cpu_models.c +++ b/target-s390x/cpu_models.c @@ -529,6 +529,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.6.6