From nobody Wed Dec 17 05:45:31 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1609759851; cv=none; d=zohomail.com; s=zohoarc; b=aoQFD783NCVsKquzyeNyPaGP2oHFQFViSdJ9PxM4YqLonQojbg8ogjq1CCQbHzWinRjo5QKX4jpItX2TgGQdLToYSUpWx52gCPdtJ83qu3wkZVDUM7GOQKH4FS+iBpy+2MlQITusFmJvV/A8Swe2gELJ6t4Y9ABUoo25er/cJLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609759851; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iPOL/Hb31U4uM5Tw0r3lNEhZkVBq5WoLCZSAoHjDr6g=; b=bXZ5vDE/Sm0NcIZ0TTK/iPeDLgoWdsaqo432+ltwKLyHuNExJVGgTjpY/SW02ad1Pn3jJsMGv7vSpkPLoOTye6mXZOoOhgdYi4Y0ux5giDS35ousUkOwGVBPFTnhr9lM7NZkwAwfBfKZT03nDqVIzNAiTAJLBZBFM5fsyheEro0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1609759851540578.5842525867114; Mon, 4 Jan 2021 03:30:51 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-526-gZu-AFpKODmL_dpwsoe-Gg-1; Mon, 04 Jan 2021 06:30:48 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D42E0612AD; Mon, 4 Jan 2021 11:30:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 985DB10023B1; Mon, 4 Jan 2021 11:30:42 +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 631E050030; Mon, 4 Jan 2021 11:30:42 +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 104BUUee006522 for ; Mon, 4 Jan 2021 06:30:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 22DFD5D756; Mon, 4 Jan 2021 11:30:30 +0000 (UTC) Received: from work.redhat.com (ovpn-112-122.ams2.redhat.com [10.36.112.122]) by smtp.corp.redhat.com (Postfix) with ESMTP id 626F061F20; Mon, 4 Jan 2021 11:30:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1609759850; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=iPOL/Hb31U4uM5Tw0r3lNEhZkVBq5WoLCZSAoHjDr6g=; b=bhRFFWPQIV+7jI/ctXmDrYUJAoGiN/EAjAPVDQs+XWccfBS4KEks1oJwLOgULRktx+zrI3 1okBIshI9U1osNmPhxBpqEc1n9O9s/uLfRFi3UT14tt5G7935QKE6K03NzcH+PVjBVf7Ab c254O6n4zOePdl+slfaTi4hbbpmcANo= X-MC-Unique: gZu-AFpKODmL_dpwsoe-Gg-1 From: Tim Wiederhake To: libvir-list@redhat.com Subject: [libvirt PATCH 5/9] cpu-cpuid: Merge checkFeature functions Date: Mon, 4 Jan 2021 12:30:15 +0100 Message-Id: <20210104113019.106513-6-twiederh@redhat.com> In-Reply-To: <20210104113019.106513-1-twiederh@redhat.com> References: <20210104113019.106513-1-twiederh@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Cc: Tim Wiederhake 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Prepare to deduplicate the list of relevant registers for cpuid and msr information. Signed-off-by: Tim Wiederhake --- tests/cputestdata/cpu-cpuid.py | 60 ++++++++++------------------------ 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index c9948da6f8..e90165e563 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -7,51 +7,27 @@ import json import xml.etree.ElementTree =20 =20 -def checkCPUIDFeature(cpuData, feature): - eax_in =3D feature["eax_in"] - ecx_in =3D feature["ecx_in"] - eax =3D feature["eax"] - ebx =3D feature["ebx"] - ecx =3D feature["ecx"] - edx =3D feature["edx"] - - if "cpuid" not in cpuData: - return False - - cpuid =3D cpuData["cpuid"] - if eax_in not in cpuid or ecx_in not in cpuid[eax_in]: - return False - - leaf =3D cpuid[eax_in][ecx_in] - return ((eax > 0 and leaf["eax"] & eax =3D=3D eax) or - (ebx > 0 and leaf["ebx"] & ebx =3D=3D ebx) or - (ecx > 0 and leaf["ecx"] & ecx =3D=3D ecx) or - (edx > 0 and leaf["edx"] & edx =3D=3D edx)) - - -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) + # cpuData["cpuid"][eax_in][ecx_in] =3D {eax:, ebx:, ecx:, edx:} + keyList =3D ["type", "eax_in", "ecx_in"] + regList =3D ["eax", "ebx", "ecx", "edx"] + elif feature["type"] =3D=3D "msr": + # cpuData["msr"][index] =3D {eax:, edx:} + keyList =3D ["type", "index"] + regList =3D ["eax", "edx"] + else: + return False + + for key in keyList: + if feature[key] not in cpuData: + return False + cpuData =3D cpuData[feature[key]] =20 - if feature["type"] =3D=3D "msr": - return checkMSRFeature(cpuData, feature) + for reg in regList: + if feature[reg] > 0 and feature[reg] =3D=3D feature[reg] & cpuData= [reg]: + return True + return False =20 =20 def addFeature(cpuData, feature): --=20 2.26.2