From patchwork Tue Jan 17 17:43:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 716331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v2yD402kVz9sDF for ; Wed, 18 Jan 2017 04:44:52 +1100 (AEDT) Received: from localhost ([::1]:36797 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTXoP-0002GH-Kb for incoming@patchwork.ozlabs.org; Tue, 17 Jan 2017 12:44:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cTXnN-0001Yj-Un for qemu-devel@nongnu.org; Tue, 17 Jan 2017 12:43:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cTXnM-00037e-Kh for qemu-devel@nongnu.org; Tue, 17 Jan 2017 12:43:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40378) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cTXnM-00037N-C8 for qemu-devel@nongnu.org; Tue, 17 Jan 2017 12:43:44 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 669EC61BA2; Tue, 17 Jan 2017 17:43:44 +0000 (UTC) Received: from [10.36.116.195] (ovpn-116-195.ams2.redhat.com [10.36.116.195]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0HHhfeh019377; Tue, 17 Jan 2017 12:43:42 -0500 To: Eduardo Habkost , qemu-devel@nongnu.org References: <20170116195452.23532-1-ehabkost@redhat.com> From: David Hildenbrand Organization: Red Hat GmbH Message-ID: <0503ac26-e660-325c-8257-59227c41021d@redhat.com> Date: Tue, 17 Jan 2017 18:43:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170116195452.23532-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 17 Jan 2017 17:43:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH] i386: Support "-cpu host" on TCG too X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , "Jason J. Herne" , Cornelia Huck , Igor Mammedov , Jiri Denemark , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Am 16.01.2017 um 20:54 schrieb Eduardo Habkost: > Change the meaning of "-cpu host" to "enable all features > supported by the accelerator in the current host", so that it can > be used to enable/query all features supported by TCG. > > To make sure "host" is still at the end of the list in "-cpu > help", add a "ordering" field that will be used when sorting the > CPU model list. > > Cc: Richard Henderson > Signed-off-by: Eduardo Habkost I also had the same thing in mind when working on s390x models but decided to do it like x86. Now that x86 changes ... Something like that should work for s390x (and I don't think it will break any concept). Most probably cleaner to handle this the same way on all architectures and to not disable tests for s390x. Uncompiled and untested. @Conny and Christian, feel free to pick up and modify if this makes sense From 4a2af1ca47421b68eb7677cd91af350dd9be4e0e Mon Sep 17 00:00:00 2001 From: David Hildenbrand Date: Tue, 17 Jan 2017 18:34:45 +0100 Subject: [PATCH] s390x/cpumodel: allow the "host" model also for tcg Let's also allow the host model for tcg, therefore meaning "enable all features supported by the selected accelerator in the current host". Signed-off-by: David Hildenbrand --- qapi-schema.json | 4 ++-- target/s390x/cpu-qom.h | 1 - target/s390x/cpu_models.c | 34 ++++++++-------------------------- 3 files changed, 10 insertions(+), 29 deletions(-) obj = object_new(object_class_get_name(oc)); cpu = S390_CPU(obj); @@ -718,15 +714,9 @@ static inline void apply_cpu_model(const S390CPUModel *model, Error **errp) void s390_realize_cpu_model(CPUState *cs, Error **errp) { - S390CPUClass *xcc = S390_CPU_GET_CLASS(cs); S390CPU *cpu = S390_CPU(cs); const S390CPUModel *max_model; - if (xcc->kvm_required && !kvm_enabled()) { - error_setg(errp, "CPU definition requires KVM"); - return; - } - if (!cpu->model) { /* no host model support -> perform compatibility stuff */ apply_cpu_model(NULL, errp); @@ -904,26 +894,25 @@ static void s390_cpu_model_initfn(Object *obj) } } -#ifdef CONFIG_KVM static void s390_host_cpu_model_initfn(Object *obj) { + S390CPUModel *max_model; S390CPU *cpu = S390_CPU(obj); Error *err = NULL; - if (!kvm_enabled() || !kvm_s390_cpu_models_supported()) { + if (kvm_enabled() && !kvm_s390_cpu_models_supported()) { return; } - cpu->model = g_malloc0(sizeof(*cpu->model)); - kvm_s390_get_host_cpu_model(cpu->model, &err); - if (err) { + max_model = get_max_cpu_model(&err); + if (err || !max_model) { error_report_err(err); - g_free(cpu->model); /* fallback to unsupported cpu models */ - cpu->model = NULL; + return; } + /* copy the host model so it can be modified */ + cpu->model = g_memdup(max_model, sizeof(*cpu->model)); } -#endif static void s390_qemu_cpu_model_initfn(Object *obj) { @@ -969,15 +958,12 @@ void s390_cpu_model_class_register_props(ObjectClass *oc) NULL); } -#ifdef CONFIG_KVM static void s390_host_cpu_model_class_init(ObjectClass *oc, void *data) { S390CPUClass *xcc = S390_CPU_CLASS(oc); - xcc->kvm_required = true; - xcc->desc = "KVM only: All recognized features"; + xcc->desc = "All supported and available features"; } -#endif static void s390_base_cpu_model_class_init(ObjectClass *oc, void *data) { @@ -1042,7 +1028,6 @@ static const TypeInfo qemu_s390_cpu_type_info = { .class_init = s390_qemu_cpu_model_class_init, }; -#ifdef CONFIG_KVM static const TypeInfo host_s390_cpu_type_info = { .name = S390_CPU_TYPE_NAME("host"), .parent = TYPE_S390_CPU, @@ -1050,7 +1035,6 @@ static const TypeInfo host_s390_cpu_type_info = { .instance_finalize = s390_cpu_model_finalize, .class_init = s390_host_cpu_model_class_init, }; -#endif static void register_types(void) { @@ -1093,9 +1077,7 @@ static void register_types(void) } type_register_static(&qemu_s390_cpu_type_info); -#ifdef CONFIG_KVM type_register_static(&host_s390_cpu_type_info); -#endif } type_init(register_types) diff --git a/qapi-schema.json b/qapi-schema.json index ddc8783..f14d343 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -4334,8 +4334,8 @@ # CPU model has to be created by baselining. # # Usually, a CPU model is compared against the maximum possible CPU model -# of a certain configuration (e.g. the "host" model for KVM). If that CPU -# model is identical or a subset, it will run in that configuration. +# of a certain configuration (the "host" model). If that CPU model is +# identical or a subset, it will run in that configuration. # # The result returned by this command may be affected by: # diff --git a/target/s390x/cpu-qom.h b/target/s390x/cpu-qom.h index 4e936e7..71322a5 100644 --- a/target/s390x/cpu-qom.h +++ b/target/s390x/cpu-qom.h @@ -47,7 +47,6 @@ typedef struct S390CPUClass { CPUClass parent_class; /*< public >*/ const S390CPUDef *cpu_def; - bool kvm_required; bool is_static; bool is_migration_safe; const char *desc; diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 5b66d33..2994a7b 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -331,10 +331,6 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, error_setg(errp, "The CPU definition \'%s\' is unknown.", info->name); return; } - if (S390_CPU_CLASS(oc)->kvm_required && !kvm_enabled()) { - error_setg(errp, "The CPU definition '%s' requires KVM", info->name); - return; - }