From nobody Sun May 5 00:07:51 2024 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.zoho.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 1496259384604612.2245404247788; Wed, 31 May 2017 12:36:24 -0700 (PDT) Received: from localhost ([::1]:33541 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG9Pq-0003Hg-Oy for importer@patchew.org; Wed, 31 May 2017 15:36:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG9OJ-0002NF-IH for qemu-devel@nongnu.org; Wed, 31 May 2017 15:34:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG9OG-0003OJ-Io for qemu-devel@nongnu.org; Wed, 31 May 2017 15:34:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55260) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG9OG-0003NG-BJ for qemu-devel@nongnu.org; Wed, 31 May 2017 15:34:44 -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 427A71A34EB; Wed, 31 May 2017 19:34:43 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-107.ams2.redhat.com [10.36.116.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAE211898E; Wed, 31 May 2017 19:34:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 427A71A34EB 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=pass smtp.mailfrom=david@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 427A71A34EB From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 21:34:33 +0200 Message-Id: <20170531193434.6918-2-david@redhat.com> In-Reply-To: <20170531193434.6918-1-david@redhat.com> References: <20170531193434.6918-1-david@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]); Wed, 31 May 2017 19:34:43 +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 v1 1/2] s390x/cpumodel: take care of the cpuid format bit for KVM 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: thuth@redhat.com, david@redhat.com, Christian Borntraeger , "Jason J . Herne" , Cornelia Huck , Aurelien Jarno , rth@twiddle.net 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" Let's also properly forward that bit. It should always be set. I verified it under z/VM, it seems to be always set there. For now, zKVM guests never get that bit set when the CPU model is active. The PoP mentiones, that z800 + z900 (HW generation 7) always set this bit to 0, so let's take care of that. Signed-off-by: David Hildenbrand Acked-by: Jason J. Herne --- target/s390x/cpu_models.c | 1 + target/s390x/cpu_models.h | 10 +++++++--- target/s390x/kvm.c | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 8d27363..9e23535 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -740,6 +740,7 @@ void s390_realize_cpu_model(CPUState *cs, Error **errp) /* copy over properties that can vary */ cpu->model->lowest_ibc =3D max_model->lowest_ibc; cpu->model->cpu_id =3D max_model->cpu_id; + cpu->model->cpu_id_format =3D max_model->cpu_id_format; cpu->model->cpu_ver =3D max_model->cpu_ver; =20 check_consistency(cpu->model); diff --git a/target/s390x/cpu_models.h b/target/s390x/cpu_models.h index 136a602..d41f8d6 100644 --- a/target/s390x/cpu_models.h +++ b/target/s390x/cpu_models.h @@ -46,6 +46,7 @@ typedef struct S390CPUModel { /* values copied from the "host" model, can change during migration */ uint16_t lowest_ibc; /* lowest IBC that the hardware supports */ uint32_t cpu_id; /* CPU id */ + uint8_t cpu_id_format; /* CPU id format bit */ uint8_t cpu_ver; /* CPU version, usually "ff" for kvm */ } S390CPUModel; =20 @@ -54,12 +55,14 @@ typedef struct S390CPUModel { * * bits 0-7: Zeroes (ff for kvm) * bits 8-31: CPU ID (serial number) - * bits 32-48: Machine type - * bits 48-63: Zeroes + * bits 32-47: Machine type + * bit 48: CPU ID format + * bits 49-63: Zeroes */ #define cpuid_type(x) (((x) >> 16) & 0xffff) #define cpuid_id(x) (((x) >> 32) & 0xffffff) #define cpuid_ver(x) (((x) >> 56) & 0xff) +#define cpuid_format(x) (((x) >> 15) & 0x1) =20 #define lowest_ibc(x) (((uint32_t)(x) >> 16) & 0xfff) #define unblocked_ibc(x) ((uint32_t)(x) & 0xfff) @@ -92,7 +95,8 @@ static inline uint64_t s390_cpuid_from_cpu_model(const S3= 90CPUModel *model) { return ((uint64_t)model->cpu_ver << 56) | ((uint64_t)model->cpu_id << 32) | - ((uint64_t)model->def->type << 16); + ((uint64_t)model->def->type << 16) | + (model->def->gen =3D=3D 7 ? 0 : (uint64_t)model->cpu_id_format = << 15); } S390CPUDef const *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec= _ga, S390FeatBitmap features); diff --git a/target/s390x/kvm.c b/target/s390x/kvm.c index ba1e60f..a3d0019 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -2580,6 +2580,7 @@ void kvm_s390_get_host_cpu_model(S390CPUModel *model,= Error **errp) unblocked_ibc =3D unblocked_ibc(prop.ibc); } model->cpu_id =3D cpuid_id(prop.cpuid); + model->cpu_id_format =3D cpuid_format(prop.cpuid); model->cpu_ver =3D 0xff; =20 /* get supported cpu features indicated via STFL(E) */ --=20 2.9.3 From nobody Sun May 5 00:07:51 2024 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.zoho.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 1496259385165795.2167397027858; Wed, 31 May 2017 12:36:25 -0700 (PDT) Received: from localhost ([::1]:33542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG9Pr-0003IF-NW for importer@patchew.org; Wed, 31 May 2017 15:36:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37356) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG9OK-0002NG-4Y for qemu-devel@nongnu.org; Wed, 31 May 2017 15:34:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dG9OJ-0003PJ-Bl for qemu-devel@nongnu.org; Wed, 31 May 2017 15:34:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34704) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dG9OJ-0003Ou-6G for qemu-devel@nongnu.org; Wed, 31 May 2017 15:34:47 -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 23F06C0471BF; Wed, 31 May 2017 19:34:46 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-107.ams2.redhat.com [10.36.116.107]) by smtp.corp.redhat.com (Postfix) with ESMTP id D064E189B9; Wed, 31 May 2017 19:34:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 23F06C0471BF Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=david@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 23F06C0471BF From: David Hildenbrand To: qemu-devel@nongnu.org Date: Wed, 31 May 2017 21:34:34 +0200 Message-Id: <20170531193434.6918-3-david@redhat.com> In-Reply-To: <20170531193434.6918-1-david@redhat.com> References: <20170531193434.6918-1-david@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.32]); Wed, 31 May 2017 19:34:46 +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 v1 2/2] s390x/cpumodel: improve defintion search without an IBC 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: thuth@redhat.com, david@redhat.com, Christian Borntraeger , "Jason J . Herne" , Cornelia Huck , Aurelien Jarno , rth@twiddle.net 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" Currently, under z/VM on a 0x2827, QEMU will detect a 0x2828 if no IBC value is provided. QEMU will simply take the last model of that HW generation, which happens to be the BC version. Let's improve our search for that case by selecting the latest CPU definition that matches the CPU type. This might still detect e.g. a GA2 version on a GA1 system, but as we don't have further information at hand, there isn't too much we can do about it. Signed-off-by: David Hildenbrand Acked-by: Jason J. Herne Reviewed-by: Halil Pasic --- target/s390x/cpu_models.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 9e23535..b6220c8 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -184,6 +184,7 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint= 8_t gen, uint8_t ec_ga, S390FeatBitmap features) { const S390CPUDef *last_compatible =3D NULL; + const S390CPUDef *matching_cpu_type =3D NULL; int i; =20 if (!gen) { @@ -218,8 +219,16 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uin= t8_t gen, uint8_t ec_ga, if (def->type =3D=3D type && def->ec_ga =3D=3D ec_ga) { return def; } + /* remember if we've at least seen one with the same cpu type */ + if (def->type =3D=3D type) { + matching_cpu_type =3D def; + } last_compatible =3D def; } + /* prefer the model with the same cpu type, esp. don't take the BC for= EC */ + if (matching_cpu_type) { + return matching_cpu_type; + } return last_compatible; } =20 --=20 2.9.3