From nobody Mon Nov 3 14:20:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1505991298537622.5796748788969; Thu, 21 Sep 2017 03:54:58 -0700 (PDT) Received: from localhost ([::1]:52879 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duz8C-0006gx-Uu for importer@patchew.org; Thu, 21 Sep 2017 06:54:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duz7J-0006NZ-Q5 for qemu-devel@nongnu.org; Thu, 21 Sep 2017 06:54:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duz7G-0008QL-Mm for qemu-devel@nongnu.org; Thu, 21 Sep 2017 06:54:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53432) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1duz7G-0008P0-DL for qemu-devel@nongnu.org; Thu, 21 Sep 2017 06:53:58 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2BE5981DF3; Thu, 21 Sep 2017 10:53:57 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 026A9600C2; Thu, 21 Sep 2017 10:53:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2BE5981DF3 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 21 Sep 2017 12:53:54 +0200 Message-Id: <1505991234-246759-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 21 Sep 2017 10:53:57 +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: [Qemu-devel] [PATCH] s390x: use generic cpu_model parsing 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 , Cornelia Huck , Alexander Graf , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" define default CPU type in generic way in machine class_init and let common machine code to handle cpu_model parsing. Signed-off-by: Igor Mammedov Reviewed-by: David Hildenbrand --- tested under TCG booting debian kernel, and compile tested on s390 host CC: Cornelia Huck CC: Christian Borntraeger CC: Alexander Graf CC: Richard Henderson --- target/s390x/cpu.h | 6 ++++-- hw/s390x/s390-virtio-ccw.c | 29 ++++------------------------- target/s390x/cpu_models.c | 11 ----------- target/s390x/kvm.c | 3 +++ 4 files changed, 11 insertions(+), 38 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 9b549dc..6cc96ae 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -684,12 +684,14 @@ static inline unsigned int s390_cpu_set_state(uint8_t= cpu_state, S390CPU *cpu) /* cpu_models.c */ void s390_cpu_list(FILE *f, fprintf_function cpu_fprintf); #define cpu_list s390_cpu_list -const char *s390_default_cpu_model_name(void); - =20 /* helper.c */ #define cpu_init(cpu_model) cpu_generic_init(TYPE_S390_CPU, cpu_model) S390CPU *s390x_new_cpu(const char *typename, uint32_t core_id, Error **err= p); + +#define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU +#define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX) + /* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */ diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index fafbc6d..5546d6a 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -55,15 +55,8 @@ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr) static void s390_init_cpus(MachineState *machine) { MachineClass *mc =3D MACHINE_GET_CLASS(machine); - const char *typename; - gchar **model_pieces; - ObjectClass *oc; - CPUClass *cc; int i; =20 - if (machine->cpu_model =3D=3D NULL) { - machine->cpu_model =3D s390_default_cpu_model_name(); - } if (tcg_enabled() && max_cpus > 1) { error_report("Number of SMP CPUs requested (%d) exceeds max CPUs " "supported by TCG (1) on s390x", max_cpus); @@ -73,25 +66,8 @@ static void s390_init_cpus(MachineState *machine) /* initialize possible_cpus */ mc->possible_cpu_arch_ids(machine); =20 - model_pieces =3D g_strsplit(machine->cpu_model, ",", 2); - if (!model_pieces[0]) { - error_report("Invalid/empty CPU model name"); - exit(1); - } - - oc =3D cpu_class_by_name(TYPE_S390_CPU, model_pieces[0]); - if (!oc) { - error_report("Unable to find CPU definition: %s", model_pieces[0]); - exit(1); - } - typename =3D object_class_get_name(oc); - cc =3D CPU_CLASS(oc); - /* after parsing, properties will be applied to all *typename* instanc= es */ - cc->parse_features(typename, model_pieces[1], &error_fatal); - g_strfreev(model_pieces); - for (i =3D 0; i < smp_cpus; i++) { - s390x_new_cpu(typename, i, &error_fatal); + s390x_new_cpu(machine->cpu_type, i, &error_fatal); } } =20 @@ -446,6 +422,9 @@ static void ccw_machine_class_init(ObjectClass *oc, voi= d *data) mc->get_hotplug_handler =3D s390_get_hotplug_handler; mc->cpu_index_to_instance_props =3D s390_cpu_index_to_props; mc->possible_cpu_arch_ids =3D s390_possible_cpu_arch_ids; + /* it is overrriden with 'host' cpu type when accel=3Dkvm + * i.e. when kvm_arch_init() is executed */ + mc->default_cpu_type =3D S390_CPU_TYPE_NAME("qemu"); hc->plug =3D s390_machine_device_plug; hc->unplug_request =3D s390_machine_device_unplug_request; nc->nmi_monitor_handler =3D s390_nmi; diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 5169379..0bf7e14 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -1207,9 +1207,6 @@ static void s390_qemu_cpu_model_class_init(ObjectClas= s *oc, void *data) qemu_hw_version()); } =20 -#define S390_CPU_TYPE_SUFFIX "-" TYPE_S390_CPU -#define S390_CPU_TYPE_NAME(name) (name S390_CPU_TYPE_SUFFIX) - /* Generate type name for a cpu model. Caller has to free the string. */ static char *s390_cpu_type_name(const char *model_name) { @@ -1232,14 +1229,6 @@ ObjectClass *s390_cpu_class_by_name(const char *name) return oc; } =20 -const char *s390_default_cpu_model_name(void) -{ - if (kvm_enabled()) { - return "host"; - } - return "qemu"; -} - static const TypeInfo qemu_s390_cpu_type_info =3D { .name =3D S390_CPU_TYPE_NAME("qemu"), .parent =3D TYPE_S390_CPU, diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index 720cb1d..5dfdd96 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -287,6 +287,9 @@ void kvm_s390_crypto_reset(void) =20 int kvm_arch_init(MachineState *ms, KVMState *s) { + MachineClass *mc =3D MACHINE_GET_CLASS(ms); + + mc->default_cpu_type =3D S390_CPU_TYPE_NAME("host"); cap_sync_regs =3D kvm_check_extension(s, KVM_CAP_SYNC_REGS); cap_async_pf =3D kvm_check_extension(s, KVM_CAP_ASYNC_PF); cap_mem_op =3D kvm_check_extension(s, KVM_CAP_S390_MEM_OP); --=20 2.7.4