From patchwork Wed Oct 2 11:33:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Mueller X-Patchwork-Id: 279695 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0B31D2C008E for ; Wed, 2 Oct 2013 21:34:50 +1000 (EST) Received: from localhost ([::1]:35403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKhb-0000bE-Bq for incoming@patchwork.ozlabs.org; Wed, 02 Oct 2013 07:34:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKgu-0000Yq-4R for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:34:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VRKgl-00027P-6S for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:34:04 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:49495) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VRKgk-00026f-US for qemu-devel@nongnu.org; Wed, 02 Oct 2013 07:33:55 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 2 Oct 2013 12:33:53 +0100 Received: from d06dlp02.portsmouth.uk.ibm.com (9.149.20.14) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 2 Oct 2013 12:33:52 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp02.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4F2AC219005A for ; Wed, 2 Oct 2013 12:33:52 +0100 (BST) Received: from d06av04.portsmouth.uk.ibm.com (d06av04.portsmouth.uk.ibm.com [9.149.37.216]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r92BXd4352691126 for ; Wed, 2 Oct 2013 11:33:39 GMT Received: from d06av04.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r92BXpo8023015 for ; Wed, 2 Oct 2013 05:33:51 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av04.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r92BXkea022802; Wed, 2 Oct 2013 05:33:51 -0600 From: Michael Mueller To: qemu-devel@nongnu.org Date: Wed, 2 Oct 2013 13:33:42 +0200 Message-Id: <1380713622-22325-12-git-send-email-mimu@linux.vnet.ibm.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1380713622-22325-1-git-send-email-mimu@linux.vnet.ibm.com> References: <1380713622-22325-1-git-send-email-mimu@linux.vnet.ibm.com> X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13100211-1948-0000-0000-000006782DB4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 195.75.94.110 Cc: Michael Mueller Subject: [Qemu-devel] [PATCH RFC 11/11] s390/qemu: cpu model enablement X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch enables all previous cpu model related patches and allows the feature to become active. It basically implements the host properties being fetched from the host and applied to the predefined S390 cpu classes during initialization of the HW platform. In a second step, the requeted cpu model determines from which cpu class the cpus become instantiated. Signed-off-by: Michael Mueller --- hw/s390x/s390-virtio-ccw.c | 15 +++++++++++++++ hw/s390x/s390-virtio.c | 31 +++++++++++++++++++++++++++++-- target-s390x/helper.c | 24 ++++++++++++++++++++++-- 3 files changed, 66 insertions(+), 4 deletions(-) diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index 9dd7bcc..64a1eaa 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -17,6 +17,7 @@ #include "css.h" #include "virtio-ccw.h" #include "hw/s390x/config.h" +#include "cpu-models.h" void io_subsystem_reset(void) { @@ -85,6 +86,7 @@ static void ccw_init(QEMUMachineInitArgs *args) int ret; VirtualCssBus *css_bus; char machine_name[128]; + struct S390HostProps prop; /* s390x ram size detection needs a 16bit multiplier + an increment. So guests > 64GB can be specified in 2MB steps etc. */ @@ -108,6 +110,19 @@ static void ccw_init(QEMUMachineInitArgs *args) set_s390_config_attr(KVM_DEV_S390_CONFIG_NAME, machine_name); } + if (kvm_enabled()) { + ret = s390_fetch_kvm_host_props(&prop); + if (ret) { + fprintf(stderr, "failed to retrieve KVM host properties\n"); + exit(1); + } + ret = s390_setup_cpu_classes(&prop); + if (ret) { + fprintf(stderr, "failed to setup S390 cpu classes\n"); + exit(1); + } + } + /* register hypercalls */ virtio_ccw_register_hcalls(); diff --git a/hw/s390x/s390-virtio.c b/hw/s390x/s390-virtio.c index 9237150..272a987 100644 --- a/hw/s390x/s390-virtio.c +++ b/hw/s390x/s390-virtio.c @@ -39,6 +39,8 @@ #include "hw/s390x/s390-virtio.h" #include "hw/s390x/config.h" +#include "cpu-models.h" +#include "sysemu/cpus.h" //#define DEBUG_S390 @@ -180,12 +182,37 @@ void s390_init_ipl_dev(const char *kernel_filename, void s390_init_cpus(const char *cpu_model, uint8_t *storage_keys) { - int i; + int i, ret; + S390CPUClass *cc; + ObjectClass *oc; - if (cpu_model == NULL) { + if (!cpu_model) { cpu_model = "host"; } + if (is_help_option(cpu_model)) { + list_cpus(stdout, &fprintf, cpu_model); + exit(0); + } + + if (kvm_enabled()) { + oc = s390_cpu_class_by_name(cpu_model); + if (!oc) { + fprintf(stderr, "Unable to find s390 CPU definition %s\n", cpu_model); + exit(1); + } + cc = S390_CPU_CLASS(oc); + } + + /* request CPU configuration */ + if (kvm_enabled()) { + ret = s390_request_kvm_cpu_config(cc); + if (ret) { + fprintf(stderr, "failed to request CPU configaration\n"); + exit(1); + } + } + ipi_states = g_malloc(sizeof(S390CPU *) * smp_cpus); for (i = 0; i < smp_cpus; i++) { diff --git a/target-s390x/helper.c b/target-s390x/helper.c index 61abfd7..a3d16ff 100644 --- a/target-s390x/helper.c +++ b/target-s390x/helper.c @@ -19,6 +19,7 @@ */ #include "cpu.h" +#include "cpu-models.h" #include "exec/gdbstub.h" #include "qemu/timer.h" #ifndef CONFIG_USER_ONLY @@ -74,10 +75,29 @@ S390CPU *cpu_s390x_init(const char *cpu_model) { S390CPU *cpu; CPUS390XState *env; + ObjectClass *oc; + S390CPUClass *cc; + char model[16]; + + if (kvm_enabled()) { + oc = s390_cpu_class_by_name(cpu_model); + if (!oc) { + return NULL; + } + cc = S390_CPU_CLASS(oc); + snprintf(model, sizeof(model), "%04x-ga%u", cc->type, cc->ga); + cpu = S390_CPU(object_new(object_class_get_name(oc))); + } else { + cpu = S390_CPU(object_new(TYPE_S390_CPU)); + } - cpu = S390_CPU(object_new(TYPE_S390_CPU)); env = &cpu->env; - env->cpu_model_str = cpu_model; + + if (kvm_enabled()) { + env->cpu_model_str = g_strdup(model); + } else { + env->cpu_model_str = cpu_model; + } object_property_set_bool(OBJECT(cpu), true, "realized", NULL);