From patchwork Wed May 31 19:34:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 9757995 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E68EA602BF for ; Wed, 31 May 2017 19:36:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D71A720265 for ; Wed, 31 May 2017 19:36:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC1A1283DA; Wed, 31 May 2017 19:36:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7CC9F27FC0 for ; Wed, 31 May 2017 19:36:00 +0000 (UTC) Received: from localhost ([::1]:33532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dG9PT-0002Nw-HY for patchwork-qemu-devel@patchwork.kernel.org; Wed, 31 May 2017 15:35:59 -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) 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 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) 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Halil Pasic Signed-off-by: David Hildenbrand Acked-by: Jason J. Herne Reviewed-by: Halil Pasic Signed-off-by: Christian Borntraeger --- 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, uint8_t gen, uint8_t ec_ga, S390FeatBitmap features) { const S390CPUDef *last_compatible = NULL; + const S390CPUDef *matching_cpu_type = NULL; int i; if (!gen) { @@ -218,8 +219,16 @@ const S390CPUDef *s390_find_cpu_def(uint16_t type, uint8_t gen, uint8_t ec_ga, if (def->type == type && def->ec_ga == ec_ga) { return def; } + /* remember if we've at least seen one with the same cpu type */ + if (def->type == type) { + matching_cpu_type = def; + } last_compatible = 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; }