From nobody Sun Feb 8 21:12:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554713020366194.22671934160178; Mon, 8 Apr 2019 01:43:40 -0700 (PDT) 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 B6F5C88AAD; Mon, 8 Apr 2019 08:43:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8012C60471; Mon, 8 Apr 2019 08:43:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 48442181BA18; Mon, 8 Apr 2019 08:43:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxOX009189 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6F66E5D721; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43A8F5D71F for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 48DCE103831; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:37 +0200 Message-Id: <7bd5224629772c3133a8089250de43325b9a6a19.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 33/36] cputest: Add support for MSR features to cpu-cpuid.py X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@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.26]); Mon, 08 Apr 2019 08:43:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-cpuid.py | 58 ++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index 89efc3a40c..ae3cf5996a 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -27,11 +27,29 @@ def checkCPUIDFeature(cpuData, feature): (edx > 0 and leaf["edx"] & edx =3D=3D edx)) =20 =20 +def checkMSRFeature(cpuData, feature): + index =3D feature["index"] + edx =3D feature["edx"] + eax =3D feature["eax"] + + if "msr" not in cpuData: + return False + + msr =3D cpuData["msr"] + if index not in msr: + return False + + msr =3D msr[index] + return ((edx > 0 and msr["edx"] & edx =3D=3D edx) or + (eax > 0 and msr["eax"] & eax =3D=3D eax)) + + def checkFeature(cpuData, feature): if feature["type"] =3D=3D "cpuid": return checkCPUIDFeature(cpuData, feature) =20 - return False + if feature["type"] =3D=3D "msr": + return checkMSRFeature(cpuData, feature) =20 =20 def addCPUIDFeature(cpuData, feature): @@ -51,9 +69,24 @@ def addCPUIDFeature(cpuData, feature): leaf[reg] |=3D feature[reg] =20 =20 +def addMSRFeature(cpuData, feature): + if "msr" not in cpuData: + cpuData["msr"] =3D {} + msr =3D cpuData["msr"] + + if feature["index"] not in msr: + msr[feature["index"]] =3D {"edx": 0, "eax": 0} + msr =3D msr[feature["index"]] + + for reg in ["edx", "eax"]: + msr[reg] |=3D feature[reg] + + def addFeature(cpuData, feature): if feature["type"] =3D=3D "cpuid": addCPUIDFeature(cpuData, feature) + elif feature["type"] =3D=3D "msr": + addMSRFeature(cpuData, feature) =20 =20 def parseQemu(path, features): @@ -82,6 +115,18 @@ def parseCPUData(path): =20 addFeature(cpuData, feature) =20 + if "msr" in data["cpudata"]: + if not isinstance(data["cpudata"]["msr"], list): + data["cpudata"]["msr"] =3D [data["cpudata"]["msr"]] + + for msr in data["cpudata"]["msr"]: + feature =3D {"type": "msr"} + feature["index"] =3D int(msr["@index"], 0) + feature["edx"] =3D int(msr["@edx"], 0) + feature["eax"] =3D int(msr["@eax"], 0) + + addFeature(cpuData, feature) + return cpuData =20 =20 @@ -90,6 +135,8 @@ def parseMapFeature(fType, data): =20 if fType =3D=3D "cpuid": fields =3D ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"] + elif fType =3D=3D "msr": + fields =3D ["index", "edx", "eax"] =20 for field in fields: attr =3D "@%s" % field @@ -109,7 +156,7 @@ def parseMap(): =20 cpuMap =3D {} for feature in data["cpus"]["feature"]: - for fType in ["cpuid"]: + for fType in ["cpuid", "msr"]: if fType in feature: cpuMap[feature["@name"]] =3D parseMapFeature(fType, featur= e[fType]) =20 @@ -132,6 +179,13 @@ def formatCPUData(cpuData, path, comment): f.write(line % ( eax_in, ecx_in, leaf["eax"], leaf["ebx"], leaf["ecx"], leaf["edx"]= )) + + if "msr" in cpuData: + msr =3D cpuData["msr"] + for index in sorted(msr.keys()): + f.write(" \n" %( + index, msr[index]['edx'], msr[index]['eax'])) + f.write("\n") =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list