From nobody Tue May 7 18:14:05 2024 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 1554712982189830.9039621141027; Mon, 8 Apr 2019 01:43:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 11CC73086231; Mon, 8 Apr 2019 08:43:00 +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 DE3E46608B; Mon, 8 Apr 2019 08:42:59 +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 8ABF13FB11; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gsPC009047 for ; Mon, 8 Apr 2019 04:42:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 52AF160A9E; Mon, 8 Apr 2019 08:42:54 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 01076665C7 for ; Mon, 8 Apr 2019 08:42:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 9D1D41001D0; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:05 +0200 Message-Id: <82128c63ce0ac55b5110d35f62a8b7bf94c6d326.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/36] domaincapstest: Test QEMU 3.1.0 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 08 Apr 2019 08:43:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- .../qemu_3.1.0.x86_64.xml | 153 ++++++++++++++++++ tests/domaincapstest.c | 4 + 2 files changed, 157 insertions(+) create mode 100644 tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml diff --git a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml b/tests/domai= ncapsschemadata/qemu_3.1.0.x86_64.xml new file mode 100644 index 0000000000..f3a33aee98 --- /dev/null +++ b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml @@ -0,0 +1,153 @@ + + /usr/bin/qemu-system-x86_64 + kvm + pc-i440fx-3.1 + x86_64 + + + + + /usr/share/AAVMF/AAVMF_CODE.fd + /usr/share/AAVMF/AAVMF32_CODE.fd + /usr/share/OVMF/OVMF_CODE.fd + + rom + pflash + + + yes + no + + + + + + + Skylake-Client-IBRS + Intel + + + + + + + + + + + + + qemu64 + qemu32 + phenom + pentium3 + pentium2 + pentium + n270 + kvm64 + kvm32 + coreduo + core2duo + athlon + Westmere-IBRS + Westmere + Skylake-Server-IBRS + Skylake-Server + Skylake-Client-IBRS + Skylake-Client + SandyBridge-IBRS + SandyBridge + Penryn + Opteron_G5 + Opteron_G4 + Opteron_G3 + Opteron_G2 + Opteron_G1 + Nehalem-IBRS + Nehalem + IvyBridge-IBRS + IvyBridge + Icelake-Server + Icelake-Client + Haswell-noTSX-IBRS + Haswell-noTSX + Haswell-IBRS + Haswell + EPYC-IBPB + EPYC + Conroe + Broadwell-noTSX-IBRS + Broadwell-noTSX + Broadwell-IBRS + Broadwell + 486 + + + + + + disk + cdrom + floppy + lun + + + ide + fdc + scsi + virtio + usb + sata + + + virtio + virtio-transitional + virtio-non-transitional + + + + + sdl + vnc + spice + + + + + + subsystem + + + default + mandatory + requisite + optional + + + usb + pci + scsi + + + + default + kvm + vfio + + + + + + + + + + diff --git a/tests/domaincapstest.c b/tests/domaincapstest.c index 2cccfbc8e2..77c5fcfb73 100644 --- a/tests/domaincapstest.c +++ b/tests/domaincapstest.c @@ -432,6 +432,10 @@ mymain(void) "/usr/bin/qemu-system-s390x", NULL, "s390x", VIR_DOMAIN_VIRT_KVM); =20 + DO_TEST_QEMU("3.1.0", "caps_3.1.0", + "/usr/bin/qemu-system-x86_64", NULL, + "x86_64", VIR_DOMAIN_VIRT_KVM); + DO_TEST_QEMU("4.0.0", "caps_4.0.0", "/usr/bin/qemu-system-x86_64", NULL, "x86_64", VIR_DOMAIN_VIRT_KVM); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712982219411.724041155078; Mon, 8 Apr 2019 01:43:02 -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 3C453E1F0A; Mon, 8 Apr 2019 08:43:00 +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 07FB5600D4; Mon, 8 Apr 2019 08:43:00 +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 AF0903FB12; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gs5A009058 for ; Mon, 8 Apr 2019 04:42:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 903F55D9C9; Mon, 8 Apr 2019 08:42:54 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E4CA55DA24 for ; Mon, 8 Apr 2019 08:42:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A138210361B; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:06 +0200 Message-Id: <135fba4dff7202c869647bcfe5c9dc07780f9449.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 02/36] cputest: Add data for Intel(R) Xeon(R) Platinum 8268 CPU 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.38]); Mon, 08 Apr 2019 08:43:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputest.c | 1 + ...6_64-cpuid-Xeon-Platinum-8268-disabled.xml | 7 + ...86_64-cpuid-Xeon-Platinum-8268-enabled.xml | 8 + .../x86_64-cpuid-Xeon-Platinum-8268-guest.xml | 35 + .../x86_64-cpuid-Xeon-Platinum-8268-host.xml | 36 + .../x86_64-cpuid-Xeon-Platinum-8268-json.xml | 13 + .../x86_64-cpuid-Xeon-Platinum-8268.json | 702 ++++++++++++++++++ .../x86_64-cpuid-Xeon-Platinum-8268.sig | 4 + .../x86_64-cpuid-Xeon-Platinum-8268.xml | 54 ++ 9 files changed, 860 insertions(+) create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-disab= led.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabl= ed.xml create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest= .xml create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.= xml create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.= xml create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.json create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.sig create mode 100644 tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml diff --git a/tests/cputest.c b/tests/cputest.c index 9a618c2242..1ade8091b2 100644 --- a/tests/cputest.c +++ b/tests/cputest.c @@ -1286,6 +1286,7 @@ mymain(void) DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-E7540", JSON_MODELS); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-Gold-5115", JSON_MODELS); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-Gold-6148", JSON_HOST); + DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-Platinum-8268", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-W3520", JSON_HOST); DO_TEST_CPUID(VIR_ARCH_X86_64, "Xeon-X5460", JSON_NONE); =20 diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-disabled.xml= b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-disabled.xml new file mode 100644 index 0000000000..32522eb9af --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-disabled.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml = b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml new file mode 100644 index 0000000000..434ac1956a --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml b/= tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml new file mode 100644 index 0000000000..6991b40af8 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml @@ -0,0 +1,35 @@ + + Skylake-Server-IBRS + Intel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml b/t= ests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml new file mode 100644 index 0000000000..90ac6edb14 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml @@ -0,0 +1,36 @@ + + x86_64 + Skylake-Server-IBRS + Intel + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml b/t= ests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml new file mode 100644 index 0000000000..12431de213 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml @@ -0,0 +1,13 @@ + + Skylake-Server-IBRS + Intel + + + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.json b/tests= /cputestdata/x86_64-cpuid-Xeon-Platinum-8268.json new file mode 100644 index 0000000000..71451f893d --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.json @@ -0,0 +1,702 @@ +{ + "return": { + "model": { + "name": "base", + "props": { + "phys-bits": 0, + "core-id": -1, + "xlevel": 2147483656, + "cmov": true, + "ia64": false, + "ssb-no": false, + "aes": true, + "mmx": true, + "rdpid": false, + "arat": true, + "gfni": false, + "ibrs-all": true, + "pause-filter": false, + "xsavec": true, + "intel-pt": false, + "hv-frequencies": false, + "tsc-frequency": 0, + "xd": true, + "hv-vendor-id": "", + "kvm-asyncpf": true, + "kvm_asyncpf": true, + "perfctr_core": false, + "perfctr-core": false, + "mpx": true, + "pbe": false, + "decodeassists": false, + "avx512cd": true, + "sse4_1": true, + "sse4.1": true, + "sse4-1": true, + "family": 6, + "legacy-cache": true, + "vmware-cpuid-freq": true, + "wbnoinvd": false, + "avx512f": true, + "msr": true, + "mce": true, + "mca": true, + "hv-runtime": false, + "xcrypt": false, + "thread-id": -1, + "min-level": 13, + "xgetbv1": true, + "cid": false, + "hv-relaxed": false, + "hv-crash": false, + "ds": false, + "fxsr": true, + "xsaveopt": true, + "xtpr": false, + "hv-evmcs": false, + "avx512vl": true, + "avx512-vpopcntdq": false, + "phe": false, + "extapic": false, + "3dnowprefetch": true, + "avx512vbmi2": false, + "cr8legacy": false, + "cpuid-0xb": true, + "xcrypt-en": false, + "kvm_pv_eoi": true, + "apic-id": 4294967295, + "rsba": false, + "pn": false, + "dca": false, + "vendor": "GenuineIntel", + "hv-ipi": false, + "pku": true, + "smx": false, + "cmp_legacy": false, + "cmp-legacy": false, + "node-id": -1, + "avx512-4fmaps": false, + "vmcb_clean": false, + "vmcb-clean": false, + "3dnowext": false, + "amd-no-ssb": false, + "hle": true, + "npt": false, + "rdctl-no": true, + "memory": "/machine/unattached/system[0]", + "clwb": true, + "lbrv": false, + "adx": true, + "ss": true, + "pni": true, + "svm_lock": false, + "svm-lock": false, + "pfthreshold": false, + "smep": true, + "smap": true, + "x2apic": true, + "avx512vbmi": false, + "avx512vnni": true, + "hv-stimer": false, + "x-hv-synic-kvm-only": true, + "i64": true, + "flushbyasid": false, + "f16c": true, + "ace2-en": false, + "pat": true, + "pae": true, + "sse": true, + "phe-en": false, + "kvm_nopiodelay": true, + "kvm-nopiodelay": true, + "tm": false, + "kvmclock-stable-bit": true, + "hypervisor": true, + "socket-id": -1, + "pcommit": false, + "syscall": true, + "level": 13, + "avx512dq": true, + "x-migrate-smi-count": false, + "svm": false, + "full-cpuid-auto-level": true, + "hv-reset": false, + "invtsc": false, + "sse3": true, + "sse2": true, + "ssbd": true, + "est": false, + "avx512ifma": false, + "tm2": false, + "kvm-pv-ipi": true, + "kvm-pv-eoi": true, + "cx8": true, + "cldemote": false, + "hv-reenlightenment": false, + "kvm_mmu": false, + "kvm-mmu": false, + "sse4_2": true, + "sse4.2": true, + "sse4-2": true, + "pge": true, + "fill-mtrr-mask": true, + "avx512bitalg": false, + "nodeid_msr": false, + "pdcm": false, + "movbe": true, + "model": 85, + "nrip_save": false, + "nrip-save": false, + "kvm_pv_unhalt": true, + "ssse3": true, + "sse4a": false, + "invpcid": true, + "pdpe1gb": true, + "tsc-deadline": true, + "skip-l1dfl-vmentry": true, + "fma": true, + "cx16": true, + "de": true, + "enforce": false, + "stepping": 6, + "xsave": true, + "clflush": true, + "skinit": false, + "tsc": true, + "tce": false, + "fpu": true, + "ibs": false, + "ds_cpl": false, + "ds-cpl": false, + "host-phys-bits": true, + "fma4": false, + "la57": false, + "osvw": false, + "check": true, + "hv-spinlocks": -1, + "pmu": false, + "pmm": false, + "apic": true, + "spec-ctrl": true, + "min-xlevel2": 0, + "tsc-adjust": true, + "tsc_adjust": true, + "kvm-steal-time": true, + "kvm_steal_time": true, + "kvmclock": true, + "l3-cache": true, + "lwp": false, + "amd-ssbd": false, + "ibpb": false, + "xop": false, + "avx": true, + "ace2": false, + "avx512bw": true, + "acpi": false, + "hv-vapic": false, + "fsgsbase": true, + "ht": false, + "nx": true, + "pclmulqdq": true, + "mmxext": false, + "vaes": false, + "popcnt": true, + "xsaves": true, + "tcg-cpuid": true, + "lm": true, + "umip": true, + "pse": true, + "avx2": true, + "sep": true, + "pclmuldq": true, + "virt-ssbd": false, + "x-hv-max-vps": -1, + "nodeid-msr": false, + "kvm": true, + "misalignsse": false, + "min-xlevel": 2147483656, + "kvm-pv-unhalt": true, + "bmi2": true, + "bmi1": true, + "realized": false, + "tsc_scale": false, + "tsc-scale": false, + "topoext": false, + "hv-vpindex": false, + "xlevel2": 0, + "clflushopt": true, + "kvm-no-smi-migration": false, + "monitor": false, + "avx512er": false, + "pmm-en": false, + "pcid": true, + "arch-capabilities": false, + "3dnow": false, + "erms": true, + "lahf-lm": true, + "lahf_lm": true, + "vpclmulqdq": false, + "fxsr-opt": false, + "hv-synic": false, + "xstore": false, + "fxsr_opt": false, + "kvm-hint-dedicated": false, + "rtm": true, + "lmce": true, + "hv-time": false, + "perfctr-nb": false, + "perfctr_nb": false, + "ffxsr": false, + "hv-tlbflush": false, + "rdrand": true, + "rdseed": true, + "avx512-4vnniw": false, + "vmx": false, + "vme": true, + "dtes64": false, + "mtrr": true, + "rdtscp": true, + "pse36": true, + "kvm-pv-tlb-flush": true, + "tbm": false, + "wdt": false, + "pause_filter": false, + "sha-ni": false, + "model-id": "Intel(R) Xeon(R) Platinum 8268 CPU @ 2.90GHz", + "abm": true, + "avx512pf": false, + "xstore-en": false + } + } + }, + "id": "model-expansion" +} + +{ + "return": [ + { + "name": "max", + "typename": "max-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": false + }, + { + "name": "host", + "typename": "host-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": false + }, + { + "name": "base", + "typename": "base-x86_64-cpu", + "unavailable-features": [], + "static": true, + "migration-safe": true + }, + { + "name": "qemu64", + "typename": "qemu64-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "qemu32", + "typename": "qemu32-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "phenom", + "typename": "phenom-x86_64-cpu", + "unavailable-features": [ + "mmxext", + "fxsr-opt", + "3dnowext", + "3dnow", + "sse4a", + "npt" + ], + "static": false, + "migration-safe": true + }, + { + "name": "pentium3", + "typename": "pentium3-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "pentium2", + "typename": "pentium2-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "pentium", + "typename": "pentium-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "n270", + "typename": "n270-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "kvm64", + "typename": "kvm64-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "kvm32", + "typename": "kvm32-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "cpu64-rhel6", + "typename": "cpu64-rhel6-x86_64-cpu", + "unavailable-features": [ + "sse4a" + ], + "static": false, + "migration-safe": true + }, + { + "name": "coreduo", + "typename": "coreduo-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "core2duo", + "typename": "core2duo-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "athlon", + "typename": "athlon-x86_64-cpu", + "unavailable-features": [ + "mmxext", + "3dnowext", + "3dnow" + ], + "static": false, + "migration-safe": true + }, + { + "name": "Westmere-IBRS", + "typename": "Westmere-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Westmere", + "typename": "Westmere-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Skylake-Server-IBRS", + "typename": "Skylake-Server-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Skylake-Server", + "typename": "Skylake-Server-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Skylake-Client-IBRS", + "typename": "Skylake-Client-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Skylake-Client", + "typename": "Skylake-Client-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "SandyBridge-IBRS", + "typename": "SandyBridge-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "SandyBridge", + "typename": "SandyBridge-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Penryn", + "typename": "Penryn-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Opteron_G5", + "typename": "Opteron_G5-x86_64-cpu", + "unavailable-features": [ + "sse4a", + "misalignsse", + "xop", + "fma4", + "tbm" + ], + "static": false, + "migration-safe": true + }, + { + "name": "Opteron_G4", + "typename": "Opteron_G4-x86_64-cpu", + "unavailable-features": [ + "sse4a", + "misalignsse", + "xop", + "fma4" + ], + "static": false, + "migration-safe": true + }, + { + "name": "Opteron_G3", + "typename": "Opteron_G3-x86_64-cpu", + "unavailable-features": [ + "sse4a", + "misalignsse" + ], + "static": false, + "migration-safe": true + }, + { + "name": "Opteron_G2", + "typename": "Opteron_G2-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Opteron_G1", + "typename": "Opteron_G1-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Nehalem-IBRS", + "typename": "Nehalem-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Nehalem", + "typename": "Nehalem-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "KnightsMill", + "typename": "KnightsMill-x86_64-cpu", + "unavailable-features": [ + "avx512pf", + "avx512er", + "avx512-vpopcntdq", + "avx512-4vnniw", + "avx512-4fmaps" + ], + "static": false, + "migration-safe": true + }, + { + "name": "IvyBridge-IBRS", + "typename": "IvyBridge-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "IvyBridge", + "typename": "IvyBridge-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Icelake-Server", + "typename": "Icelake-Server-x86_64-cpu", + "unavailable-features": [ + "avx512vbmi", + "", + "avx512vbmi2", + "gfni", + "vaes", + "vpclmulqdq", + "avx512bitalg", + "avx512-vpopcntdq", + "la57", + "wbnoinvd" + ], + "static": false, + "migration-safe": true + }, + { + "name": "Icelake-Client", + "typename": "Icelake-Client-x86_64-cpu", + "unavailable-features": [ + "avx512vbmi", + "", + "avx512vbmi2", + "gfni", + "vaes", + "vpclmulqdq", + "avx512bitalg", + "avx512-vpopcntdq", + "wbnoinvd" + ], + "static": false, + "migration-safe": true + }, + { + "name": "Haswell-noTSX-IBRS", + "typename": "Haswell-noTSX-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Haswell-noTSX", + "typename": "Haswell-noTSX-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Haswell-IBRS", + "typename": "Haswell-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Haswell", + "typename": "Haswell-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "EPYC-IBPB", + "typename": "EPYC-IBPB-x86_64-cpu", + "unavailable-features": [ + "sha-ni", + "mmxext", + "fxsr-opt", + "cr8legacy", + "sse4a", + "misalignsse", + "osvw", + "ibpb" + ], + "static": false, + "migration-safe": true + }, + { + "name": "EPYC", + "typename": "EPYC-x86_64-cpu", + "unavailable-features": [ + "sha-ni", + "mmxext", + "fxsr-opt", + "cr8legacy", + "sse4a", + "misalignsse", + "osvw" + ], + "static": false, + "migration-safe": true + }, + { + "name": "Conroe", + "typename": "Conroe-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Cascadelake-Server", + "typename": "Cascadelake-Server-x86_64-cpu", + "unavailable-features": [ + "" + ], + "static": false, + "migration-safe": true + }, + { + "name": "Broadwell-noTSX-IBRS", + "typename": "Broadwell-noTSX-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Broadwell-noTSX", + "typename": "Broadwell-noTSX-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Broadwell-IBRS", + "typename": "Broadwell-IBRS-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "Broadwell", + "typename": "Broadwell-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + }, + { + "name": "486", + "typename": "486-x86_64-cpu", + "unavailable-features": [], + "static": false, + "migration-safe": true + } + ], + "id": "definitions" +} diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.sig b/tests/= cputestdata/x86_64-cpuid-Xeon-Platinum-8268.sig new file mode 100644 index 0000000000..018161ff52 --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.sig @@ -0,0 +1,4 @@ +050656 +family: 6 (0x06) +model: 85 (0x55) +stepping: 6 (0x06) diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml b/tests/= cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml new file mode 100644 index 0000000000..75472d44fe --- /dev/null +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712977881215.5659023198982; Mon, 8 Apr 2019 01:42:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 107F33078AA3; Mon, 8 Apr 2019 08:42:56 +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 DF8A25DA35; Mon, 8 Apr 2019 08:42:55 +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 A6822181AC48; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gsNu009045 for ; Mon, 8 Apr 2019 04:42:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4E1295C297; Mon, 8 Apr 2019 08:42:54 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F028B5C5DF for ; Mon, 8 Apr 2019 08:42:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A3740103639; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:07 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 03/36] cpu_map: Add Cascadelake-Server CPU model 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 08 Apr 2019 08:42:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Introduced in QEMU 3.1.0 by commit c7a88b52f62b30c04158eeb07f73e3f72221b6a8 Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu_map/index.xml | 1 + src/cpu_map/x86_Cascadelake-Server.xml | 82 +++++++++++++++++++ .../x86_64-cpuid-Xeon-Platinum-8268-guest.xml | 5 +- .../x86_64-cpuid-Xeon-Platinum-8268-host.xml | 5 +- .../x86_64-cpuid-Xeon-Platinum-8268-json.xml | 5 +- .../qemu_3.1.0.x86_64.xml | 1 + .../qemu_4.0.0.x86_64.xml | 1 + 7 files changed, 88 insertions(+), 12 deletions(-) create mode 100644 src/cpu_map/x86_Cascadelake-Server.xml diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml index dccda3919d..d1f4827934 100644 --- a/src/cpu_map/index.xml +++ b/src/cpu_map/index.xml @@ -46,6 +46,7 @@ + =20 diff --git a/src/cpu_map/x86_Cascadelake-Server.xml b/src/cpu_map/x86_Casca= delake-Server.xml new file mode 100644 index 0000000000..7c7fc92c40 --- /dev/null +++ b/src/cpu_map/x86_Cascadelake-Server.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml b/= tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml index 6991b40af8..cc1fc90c45 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml @@ -1,5 +1,5 @@ - Skylake-Server-IBRS + Cascadelake-Server Intel @@ -20,14 +20,11 @@ - - - diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml b/t= ests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml index 90ac6edb14..dfabdc57c7 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml @@ -1,6 +1,6 @@ x86_64 - Skylake-Server-IBRS + Cascadelake-Server Intel @@ -21,14 +21,11 @@ - - - diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml b/t= ests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml index 12431de213..b7d12dced7 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml @@ -1,13 +1,10 @@ - Skylake-Server-IBRS + Cascadelake-Server Intel - - - diff --git a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml b/tests/domai= ncapsschemadata/qemu_3.1.0.x86_64.xml index f3a33aee98..f49da218e2 100644 --- a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml @@ -76,6 +76,7 @@ EPYC-IBPB EPYC Conroe + Cascadelake-Server Broadwell-noTSX-IBRS Broadwell-noTSX Broadwell-IBRS diff --git a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml b/tests/domai= ncapsschemadata/qemu_4.0.0.x86_64.xml index df66be9e29..84c33437a2 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml @@ -76,6 +76,7 @@ EPYC-IBPB EPYC Conroe + Cascadelake-Server Broadwell-noTSX-IBRS Broadwell-noTSX Broadwell-IBRS --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712977506274.5768027299523; Mon, 8 Apr 2019 01:42:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 834CC3081252; Mon, 8 Apr 2019 08:42:55 +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 371195C297; Mon, 8 Apr 2019 08:42:55 +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 ED022181AC44; Mon, 8 Apr 2019 08:42:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gsl7009038 for ; Mon, 8 Apr 2019 04:42:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2A8D05C297; Mon, 8 Apr 2019 08:42:54 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F0F045C640 for ; Mon, 8 Apr 2019 08:42:51 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A57BD10363A; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:08 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/36] cpu_x86: Do not cache microcode version 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 08 Apr 2019 08:42:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The microcode version checks are used to invalidate cached CPU data we get from QEMU. To minimize /proc/cpuinfo parsing the microcode version was only read when libvirtd started and cached for the daemon's lifetime. However, the CPU microcode can change anytime (updating the microcode package can automatically upload it to the CPU) and we need to stop caching it to avoid using stale CPU model data. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index add889c9a8..3b87386270 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -166,7 +166,6 @@ struct _virCPUx86Map { }; =20 static virCPUx86MapPtr cpuMap; -static unsigned int microcodeVersion; =20 int virCPUx86DriverOnceInit(void); VIR_ONCE_GLOBAL_INIT(virCPUx86Driver); @@ -1424,8 +1423,6 @@ virCPUx86DriverOnceInit(void) if (!(cpuMap =3D virCPUx86LoadMap())) return -1; =20 - microcodeVersion =3D virHostCPUGetMicrocodeVersion(); - return 0; } =20 @@ -2507,7 +2504,7 @@ virCPUx86GetHost(virCPUDefPtr cpu, goto cleanup; =20 ret =3D x86DecodeCPUData(cpu, cpuData, models); - cpu->microcodeVersion =3D microcodeVersion; + cpu->microcodeVersion =3D virHostCPUGetMicrocodeVersion(); =20 cleanup: virCPUx86DataFree(cpuData); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712991119622.5751623680381; Mon, 8 Apr 2019 01:43:11 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6082E30B24F6; Mon, 8 Apr 2019 08:43:09 +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 32FA45C643; Mon, 8 Apr 2019 08:43:09 +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 DDBD53FA49; Mon, 8 Apr 2019 08:43:08 +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 x388gvb5009112 for ; Mon, 8 Apr 2019 04:42:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD23B5D719; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 91FB15D71C for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id A77D410363B; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:09 +0200 Message-Id: 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 05/36] cpu_x86: Require within in CPU map 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 08 Apr 2019 08:43:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" A feature with no cpuid element is invalid and it should not be silently treated as a feature with all CPUID bits set to zero. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 3b87386270..3a8e3dd37f 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -924,6 +924,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt, if (n < 0) goto cleanup; =20 + if (n =3D=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Missing cpuid for feature %s"), + feature->name); + goto cleanup; + } + for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; if (x86ParseCPUID(ctxt, &cpuid) < 0) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713001437310.43031399711185; Mon, 8 Apr 2019 01:43:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 970F2E3DF1; Mon, 8 Apr 2019 08:43:19 +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 6BA355D731; Mon, 8 Apr 2019 08:43:19 +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 27FA5181B9FB; Mon, 8 Apr 2019 08:43:19 +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 x388gwjv009143 for ; Mon, 8 Apr 2019 04:42:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 16A025D719; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 91F735D71B for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id AA1EC10363C; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:10 +0200 Message-Id: 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 06/36] cpu_x86: Introduce virCPUx86DataItem container struct 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 08 Apr 2019 08:43:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The following patches introduce CPU features read from MSR in addition to those queried via CPUID instruction. Let's introduce a container struct which will be able to describe either feature type. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 312 ++++++++++++++++++--------------- src/cpu/cpu_x86.h | 2 +- src/cpu/cpu_x86_data.h | 9 +- src/libxl/libxl_capabilities.c | 8 +- src/qemu/qemu_monitor_json.c | 6 +- 5 files changed, 183 insertions(+), 154 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 3a8e3dd37f..c7937d55fd 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -45,7 +45,7 @@ typedef struct _virCPUx86Vendor virCPUx86Vendor; typedef virCPUx86Vendor *virCPUx86VendorPtr; struct _virCPUx86Vendor { char *name; - virCPUx86CPUID cpuid; + virCPUx86DataItem cpuid; }; =20 typedef struct _virCPUx86Feature virCPUx86Feature; @@ -57,17 +57,19 @@ struct _virCPUx86Feature { }; =20 =20 +#define CPUID(...) { .cpuid =3D {__VA_ARGS__} } + #define KVM_FEATURE_DEF(Name, Eax_in, Eax) \ - static virCPUx86CPUID Name ## _cpuid[] =3D { \ - { .eax_in =3D Eax_in, .eax =3D Eax }, \ + static virCPUx86DataItem Name ## _data[] =3D { \ + CPUID(.eax_in =3D Eax_in, .eax =3D Eax), \ } =20 #define KVM_FEATURE(Name) \ { \ .name =3D (char *) Name, \ .data =3D { \ - .len =3D ARRAY_CARDINALITY(Name ## _cpuid), \ - .data =3D Name ## _cpuid \ + .len =3D ARRAY_CARDINALITY(Name ## _data), \ + .items =3D Name ## _data, \ } \ } =20 @@ -288,17 +290,17 @@ x86FeatureFindInternal(const char *name) static int virCPUx86CPUIDSorter(const void *a, const void *b) { - virCPUx86CPUID *da =3D (virCPUx86CPUID *) a; - virCPUx86CPUID *db =3D (virCPUx86CPUID *) b; + virCPUx86DataItemPtr da =3D (virCPUx86DataItemPtr) a; + virCPUx86DataItemPtr db =3D (virCPUx86DataItemPtr) b; =20 - if (da->eax_in > db->eax_in) + if (da->cpuid.eax_in > db->cpuid.eax_in) return 1; - else if (da->eax_in < db->eax_in) + else if (da->cpuid.eax_in < db->cpuid.eax_in) return -1; =20 - if (da->ecx_in > db->ecx_in) + if (da->cpuid.ecx_in > db->cpuid.ecx_in) return 1; - else if (da->ecx_in < db->ecx_in) + else if (da->cpuid.ecx_in < db->cpuid.ecx_in) return -1; =20 return 0; @@ -306,7 +308,7 @@ virCPUx86CPUIDSorter(const void *a, const void *b) =20 =20 /* skips all zero CPUID leaves */ -static virCPUx86CPUID * +static virCPUx86DataItemPtr x86DataCpuidNext(virCPUx86DataIteratorPtr iterator) { const virCPUx86Data *data =3D iterator->data; @@ -315,24 +317,26 @@ x86DataCpuidNext(virCPUx86DataIteratorPtr iterator) return NULL; =20 while (++iterator->pos < data->len) { - if (!x86cpuidMatch(data->data + iterator->pos, &cpuidNull)) - return data->data + iterator->pos; + virCPUx86DataItemPtr item =3D data->items + iterator->pos; + + if (!x86cpuidMatch(&item->cpuid, &cpuidNull)) + return item; } =20 return NULL; } =20 =20 -static virCPUx86CPUID * +static virCPUx86DataItemPtr x86DataCpuid(const virCPUx86Data *data, - const virCPUx86CPUID *cpuid) + const virCPUx86DataItem *cpuid) { size_t i; =20 for (i =3D 0; i < data->len; i++) { - if (data->data[i].eax_in =3D=3D cpuid->eax_in && - data->data[i].ecx_in =3D=3D cpuid->ecx_in) - return data->data + i; + if (data->items[i].cpuid.eax_in =3D=3D cpuid->cpuid.eax_in && + data->items[i].cpuid.ecx_in =3D=3D cpuid->cpuid.ecx_in) + return data->items + i; } =20 return NULL; @@ -344,7 +348,7 @@ virCPUx86DataClear(virCPUx86Data *data) if (!data) return; =20 - VIR_FREE(data->data); + VIR_FREE(data->items); } =20 =20 @@ -364,12 +368,12 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *= src) { size_t i; =20 - if (VIR_ALLOC_N(dst->data, src->len) < 0) + if (VIR_ALLOC_N(dst->items, src->len) < 0) return -1; =20 dst->len =3D src->len; for (i =3D 0; i < src->len; i++) - dst->data[i] =3D src->data[i]; + dst->items[i] =3D src->items[i]; =20 return 0; } @@ -377,19 +381,19 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *= src) =20 static int virCPUx86DataAddCPUIDInt(virCPUx86Data *data, - const virCPUx86CPUID *cpuid) + const virCPUx86DataItem *cpuid) { - virCPUx86CPUID *existing; + virCPUx86DataItemPtr existing; =20 if ((existing =3D x86DataCpuid(data, cpuid))) { - x86cpuidSetBits(existing, cpuid); + x86cpuidSetBits(&existing->cpuid, &cpuid->cpuid); } else { - if (VIR_APPEND_ELEMENT_COPY(data->data, data->len, - *((virCPUx86CPUID *)cpuid)) < 0) + if (VIR_APPEND_ELEMENT_COPY(data->items, data->len, + *((virCPUx86DataItemPtr)cpuid)) < 0) return -1; =20 - qsort(data->data, data->len, - sizeof(virCPUx86CPUID), virCPUx86CPUIDSorter); + qsort(data->items, data->len, + sizeof(virCPUx86DataItem), virCPUx86CPUIDSorter); } =20 return 0; @@ -401,14 +405,14 @@ x86DataAdd(virCPUx86Data *data1, const virCPUx86Data *data2) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(data2); - virCPUx86CPUID *cpuid1; - virCPUx86CPUID *cpuid2; + virCPUx86DataItemPtr cpuid1; + virCPUx86DataItemPtr cpuid2; =20 while ((cpuid2 =3D x86DataCpuidNext(&iter))) { cpuid1 =3D x86DataCpuid(data1, cpuid2); =20 if (cpuid1) { - x86cpuidSetBits(cpuid1, cpuid2); + x86cpuidSetBits(&cpuid1->cpuid, &cpuid2->cpuid); } else { if (virCPUx86DataAddCPUIDInt(data1, cpuid2) < 0) return -1; @@ -424,12 +428,12 @@ x86DataSubtract(virCPUx86Data *data1, const virCPUx86Data *data2) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(data1); - virCPUx86CPUID *cpuid1; - virCPUx86CPUID *cpuid2; + virCPUx86DataItemPtr cpuid1; + virCPUx86DataItemPtr cpuid2; =20 while ((cpuid1 =3D x86DataCpuidNext(&iter))) { - cpuid2 =3D x86DataCpuid(data2, cpuid1); - x86cpuidClearBits(cpuid1, cpuid2); + if ((cpuid2 =3D x86DataCpuid(data2, cpuid1))) + x86cpuidClearBits(&cpuid1->cpuid, &cpuid2->cpuid); } } =20 @@ -439,15 +443,15 @@ x86DataIntersect(virCPUx86Data *data1, const virCPUx86Data *data2) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(data1); - virCPUx86CPUID *cpuid1; - virCPUx86CPUID *cpuid2; + virCPUx86DataItemPtr cpuid1; + virCPUx86DataItemPtr cpuid2; =20 while ((cpuid1 =3D x86DataCpuidNext(&iter))) { cpuid2 =3D x86DataCpuid(data2, cpuid1); if (cpuid2) - x86cpuidAndBits(cpuid1, cpuid2); + x86cpuidAndBits(&cpuid1->cpuid, &cpuid2->cpuid); else - x86cpuidClearBits(cpuid1, cpuid1); + x86cpuidClearBits(&cpuid1->cpuid, &cpuid1->cpuid); } } =20 @@ -466,12 +470,12 @@ x86DataIsSubset(const virCPUx86Data *data, const virCPUx86Data *subset) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit((virCPUx86Dat= a *)subset); - const virCPUx86CPUID *cpuid; - const virCPUx86CPUID *cpuidSubset; + const virCPUx86DataItem *cpuid; + const virCPUx86DataItem *cpuidSubset; =20 while ((cpuidSubset =3D x86DataCpuidNext(&iter))) { if (!(cpuid =3D x86DataCpuid(data, cpuidSubset)) || - !x86cpuidMatchMasked(cpuid, cpuidSubset)) + !x86cpuidMatchMasked(&cpuid->cpuid, &cpuidSubset->cpuid)) return false; } =20 @@ -506,14 +510,14 @@ static virCPUx86VendorPtr x86DataToVendor(const virCPUx86Data *data, virCPUx86MapPtr map) { - virCPUx86CPUID *cpuid; + virCPUx86DataItemPtr cpuid; size_t i; =20 for (i =3D 0; i < map->nvendors; i++) { virCPUx86VendorPtr vendor =3D map->vendors[i]; if ((cpuid =3D x86DataCpuid(data, &vendor->cpuid)) && - x86cpuidMatchMasked(cpuid, &vendor->cpuid)) { - x86cpuidClearBits(cpuid, &vendor->cpuid); + x86cpuidMatchMasked(&cpuid->cpuid, &vendor->cpuid.cpuid)) { + x86cpuidClearBits(&cpuid->cpuid, &vendor->cpuid.cpuid); return vendor; } } @@ -524,8 +528,10 @@ x86DataToVendor(const virCPUx86Data *data, =20 static int virCPUx86VendorToCPUID(const char *vendor, - virCPUx86CPUID *cpuid) + virCPUx86DataItemPtr data) { + virCPUx86CPUIDPtr cpuid =3D &data->cpuid; + if (strlen(vendor) !=3D VENDOR_STRING_LENGTH) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid CPU vendor string '%s'"), vendor); @@ -598,14 +604,16 @@ x86DataToSignatureFull(const virCPUx86Data *data, unsigned int *model, unsigned int *stepping) { - virCPUx86CPUID leaf1 =3D { .eax_in =3D 0x1 }; - virCPUx86CPUID *cpuid; + virCPUx86DataItem leaf1 =3D CPUID(.eax_in =3D 0x1); + virCPUx86DataItemPtr item; + virCPUx86CPUIDPtr cpuid; =20 *family =3D *model =3D *stepping =3D 0; =20 - if (!(cpuid =3D x86DataCpuid(data, &leaf1))) + if (!(item =3D x86DataCpuid(data, &leaf1))) return; =20 + cpuid =3D &item->cpuid; *family =3D ((cpuid->eax >> 20) & 0xff) + ((cpuid->eax >> 8) & 0xf); *model =3D ((cpuid->eax >> 12) & 0xf0) + ((cpuid->eax >> 4) & 0xf); *stepping =3D cpuid->eax & 0xf; @@ -618,13 +626,13 @@ x86DataToSignatureFull(const virCPUx86Data *data, static uint32_t x86DataToSignature(const virCPUx86Data *data) { - virCPUx86CPUID leaf1 =3D { .eax_in =3D 0x1 }; - virCPUx86CPUID *cpuid; + virCPUx86DataItem leaf1 =3D CPUID(.eax_in =3D 0x1); + virCPUx86DataItemPtr cpuid; =20 if (!(cpuid =3D x86DataCpuid(data, &leaf1))) return 0; =20 - return cpuid->eax & SIGNATURE_MASK; + return cpuid->cpuid.eax & SIGNATURE_MASK; } =20 =20 @@ -632,7 +640,7 @@ static int x86DataAddSignature(virCPUx86Data *data, uint32_t signature) { - virCPUx86CPUID cpuid =3D { .eax_in =3D 0x1, .eax =3D signature }; + virCPUx86DataItem cpuid =3D CPUID(.eax_in =3D 0x1, .eax =3D signature); =20 return virCPUx86DataAddCPUIDInt(data, &cpuid); } @@ -857,13 +865,14 @@ x86FeatureNames(virCPUx86MapPtr map, =20 static int x86ParseCPUID(xmlXPathContextPtr ctxt, - virCPUx86CPUID *cpuid) + virCPUx86DataItemPtr item) { + virCPUx86CPUIDPtr cpuid; unsigned long eax_in, ecx_in; unsigned long eax, ebx, ecx, edx; int ret_eax_in, ret_ecx_in, ret_eax, ret_ebx, ret_ecx, ret_edx; =20 - memset(cpuid, 0, sizeof(*cpuid)); + memset(item, 0, sizeof(*item)); =20 eax_in =3D ecx_in =3D 0; eax =3D ebx =3D ecx =3D edx =3D 0; @@ -878,6 +887,7 @@ x86ParseCPUID(xmlXPathContextPtr ctxt, ret_eax =3D=3D -2 || ret_ebx =3D=3D -2 || ret_ecx =3D=3D -2 || ret= _edx =3D=3D -2) return -1; =20 + cpuid =3D &item->cpuid; cpuid->eax_in =3D eax_in; cpuid->ecx_in =3D ecx_in; cpuid->eax =3D eax; @@ -896,7 +906,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, virCPUx86MapPtr map =3D data; xmlNodePtr *nodes =3D NULL; virCPUx86FeaturePtr feature; - virCPUx86CPUID cpuid; + virCPUx86DataItem cpuid; size_t i; int n; char *str =3D NULL; @@ -1139,16 +1149,16 @@ x86ModelCompare(virCPUx86ModelPtr model1, virCPUx86CompareResult result =3D EQUAL; virCPUx86DataIterator iter1 =3D virCPUx86DataIteratorInit(&model1->dat= a); virCPUx86DataIterator iter2 =3D virCPUx86DataIteratorInit(&model2->dat= a); - virCPUx86CPUID *cpuid1; - virCPUx86CPUID *cpuid2; + virCPUx86DataItemPtr cpuid1; + virCPUx86DataItemPtr cpuid2; =20 while ((cpuid1 =3D x86DataCpuidNext(&iter1))) { virCPUx86CompareResult match =3D SUPERSET; =20 if ((cpuid2 =3D x86DataCpuid(&model2->data, cpuid1))) { - if (x86cpuidMatch(cpuid1, cpuid2)) + if (x86cpuidMatch(&cpuid1->cpuid, &cpuid2->cpuid)) continue; - else if (!x86cpuidMatchMasked(cpuid1, cpuid2)) + else if (!x86cpuidMatchMasked(&cpuid1->cpuid, &cpuid2->cpuid)) match =3D SUBSET; } =20 @@ -1162,9 +1172,9 @@ x86ModelCompare(virCPUx86ModelPtr model1, virCPUx86CompareResult match =3D SUBSET; =20 if ((cpuid1 =3D x86DataCpuid(&model1->data, cpuid2))) { - if (x86cpuidMatch(cpuid2, cpuid1)) + if (x86cpuidMatch(&cpuid2->cpuid, &cpuid1->cpuid)) continue; - else if (!x86cpuidMatchMasked(cpuid2, cpuid1)) + else if (!x86cpuidMatchMasked(&cpuid2->cpuid, &cpuid1->cpuid)) match =3D SUPERSET; } =20 @@ -1448,11 +1458,12 @@ static char * virCPUx86DataFormat(const virCPUData *data) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(&data->data.x= 86); - virCPUx86CPUID *cpuid; + virCPUx86DataItemPtr item; virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAddLit(&buf, "\n"); - while ((cpuid =3D x86DataCpuidNext(&iter))) { + while ((item =3D x86DataCpuidNext(&iter))) { + virCPUx86CPUIDPtr cpuid =3D &item->cpuid; virBufferAsprintf(&buf, " data; model->data.len =3D 0; - model->data.data =3D NULL; + model->data.items =3D NULL; x86ModelFree(model); =20 return 0; @@ -2214,17 +2225,18 @@ cpuidCall(virCPUx86CPUID *cpuid) */ static int cpuidSetLeaf4(virCPUDataPtr data, - virCPUx86CPUID *subLeaf0) + virCPUx86DataItemPtr subLeaf0) { - virCPUx86CPUID cpuid =3D *subLeaf0; + virCPUx86DataItem item =3D *subLeaf0; + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; =20 if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) return -1; =20 - while (cpuid.eax & 0x1f) { - cpuid.ecx_in++; - cpuidCall(&cpuid); - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + while (cpuid->eax & 0x1f) { + cpuid->ecx_in++; + cpuidCall(cpuid); + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; } return 0; @@ -2237,18 +2249,19 @@ cpuidSetLeaf4(virCPUDataPtr data, */ static int cpuidSetLeaf7(virCPUDataPtr data, - virCPUx86CPUID *subLeaf0) + virCPUx86DataItemPtr subLeaf0) { - virCPUx86CPUID cpuid =3D { .eax_in =3D 0x7 }; + virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x7); + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; uint32_t sub; =20 if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) return -1; =20 - for (sub =3D 1; sub <=3D subLeaf0->eax; sub++) { - cpuid.ecx_in =3D sub; - cpuidCall(&cpuid); - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { + cpuid->ecx_in =3D sub; + cpuidCall(cpuid); + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; } return 0; @@ -2264,15 +2277,16 @@ cpuidSetLeaf7(virCPUDataPtr data, */ static int cpuidSetLeafB(virCPUDataPtr data, - virCPUx86CPUID *subLeaf0) + virCPUx86DataItemPtr subLeaf0) { - virCPUx86CPUID cpuid =3D *subLeaf0; + virCPUx86DataItem item =3D *subLeaf0; + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; =20 - while (cpuid.ecx & 0xff00) { - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + while (cpuid->ecx & 0xff00) { + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; - cpuid.ecx_in++; - cpuidCall(&cpuid); + cpuid->ecx_in++; + cpuidCall(cpuid); } return 0; } @@ -2288,9 +2302,10 @@ cpuidSetLeafB(virCPUDataPtr data, */ static int cpuidSetLeafD(virCPUDataPtr data, - virCPUx86CPUID *subLeaf0) + virCPUx86DataItemPtr subLeaf0) { - virCPUx86CPUID cpuid =3D { .eax_in =3D 0xd }; + virCPUx86DataItem item =3D CPUID(.eax_in =3D 0xd); + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; virCPUx86CPUID sub0; virCPUx86CPUID sub1; uint32_t sub; @@ -2298,13 +2313,13 @@ cpuidSetLeafD(virCPUDataPtr data, if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) return -1; =20 - cpuid.ecx_in =3D 1; - cpuidCall(&cpuid); - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + cpuid->ecx_in =3D 1; + cpuidCall(cpuid); + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; =20 - sub0 =3D *subLeaf0; - sub1 =3D cpuid; + sub0 =3D subLeaf0->cpuid; + sub1 =3D *cpuid; for (sub =3D 2; sub < 64; sub++) { if (sub < 32 && !(sub0.eax & (1 << sub)) && @@ -2315,9 +2330,9 @@ cpuidSetLeafD(virCPUDataPtr data, !(sub1.edx & (1 << (sub - 32)))) continue; =20 - cpuid.ecx_in =3D sub; - cpuidCall(&cpuid); - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + cpuid->ecx_in =3D sub; + cpuidCall(cpuid); + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; } return 0; @@ -2335,10 +2350,11 @@ cpuidSetLeafD(virCPUDataPtr data, */ static int cpuidSetLeafResID(virCPUDataPtr data, - virCPUx86CPUID *subLeaf0, + virCPUx86DataItemPtr subLeaf0, uint32_t res) { - virCPUx86CPUID cpuid =3D { .eax_in =3D subLeaf0->eax_in }; + virCPUx86DataItem item =3D CPUID(.eax_in =3D subLeaf0->cpuid.eax_in); + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; uint32_t sub; =20 if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) @@ -2347,9 +2363,9 @@ cpuidSetLeafResID(virCPUDataPtr data, for (sub =3D 1; sub < 32; sub++) { if (!(res & (1 << sub))) continue; - cpuid.ecx_in =3D sub; - cpuidCall(&cpuid); - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + cpuid->ecx_in =3D sub; + cpuidCall(cpuid); + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; } return 0; @@ -2363,31 +2379,32 @@ cpuidSetLeafResID(virCPUDataPtr data, */ static int cpuidSetLeaf12(virCPUDataPtr data, - virCPUx86CPUID *subLeaf0) + virCPUx86DataItemPtr subLeaf0) { - virCPUx86CPUID cpuid =3D { .eax_in =3D 0x7 }; - virCPUx86CPUID *cpuid7; + virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x7); + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86DataItemPtr cpuid7; =20 - if (!(cpuid7 =3D x86DataCpuid(&data->data.x86, &cpuid)) || - !(cpuid7->ebx & (1 << 2))) + if (!(cpuid7 =3D x86DataCpuid(&data->data.x86, &item)) || + !(cpuid7->cpuid.ebx & (1 << 2))) return 0; =20 if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) return -1; =20 - cpuid.eax_in =3D 0x12; - cpuid.ecx_in =3D 1; - cpuidCall(&cpuid); - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + cpuid->eax_in =3D 0x12; + cpuid->ecx_in =3D 1; + cpuidCall(cpuid); + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; =20 - cpuid.ecx_in =3D 2; - cpuidCall(&cpuid); - while (cpuid.eax & 0xf) { - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + cpuid->ecx_in =3D 2; + cpuidCall(cpuid); + while (cpuid->eax & 0xf) { + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; - cpuid.ecx_in++; - cpuidCall(&cpuid); + cpuid->ecx_in++; + cpuidCall(cpuid); } return 0; } @@ -2399,18 +2416,19 @@ cpuidSetLeaf12(virCPUDataPtr data, */ static int cpuidSetLeaf14(virCPUDataPtr data, - virCPUx86CPUID *subLeaf0) + virCPUx86DataItemPtr subLeaf0) { - virCPUx86CPUID cpuid =3D { .eax_in =3D 0x14 }; + virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x14); + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; uint32_t sub; =20 if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) return -1; =20 - for (sub =3D 1; sub <=3D subLeaf0->eax; sub++) { - cpuid.ecx_in =3D sub; - cpuidCall(&cpuid); - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { + cpuid->ecx_in =3D sub; + cpuidCall(cpuid); + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; } return 0; @@ -2424,21 +2442,22 @@ cpuidSetLeaf14(virCPUDataPtr data, */ static int cpuidSetLeaf17(virCPUDataPtr data, - virCPUx86CPUID *subLeaf0) + virCPUx86DataItemPtr subLeaf0) { - virCPUx86CPUID cpuid =3D { .eax_in =3D 0x17 }; + virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x17); + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; uint32_t sub; =20 - if (subLeaf0->eax < 3) + if (subLeaf0->cpuid.eax < 3) return 0; =20 if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) return -1; =20 - for (sub =3D 1; sub <=3D subLeaf0->eax; sub++) { - cpuid.ecx_in =3D sub; - cpuidCall(&cpuid); - if (virCPUx86DataAddCPUID(data, &cpuid) < 0) + for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { + cpuid->ecx_in =3D sub; + cpuidCall(cpuid); + if (virCPUx86DataAddCPUID(data, &item) < 0) return -1; } return 0; @@ -2451,39 +2470,40 @@ cpuidSet(uint32_t base, virCPUDataPtr data) int rc; uint32_t max; uint32_t leaf; - virCPUx86CPUID cpuid =3D { .eax_in =3D base }; + virCPUx86DataItem item =3D CPUID(.eax_in =3D base); + virCPUx86CPUIDPtr cpuid =3D &item.cpuid; =20 - cpuidCall(&cpuid); - max =3D cpuid.eax; + cpuidCall(cpuid); + max =3D cpuid->eax; =20 for (leaf =3D base; leaf <=3D max; leaf++) { - cpuid.eax_in =3D leaf; - cpuid.ecx_in =3D 0; - cpuidCall(&cpuid); + cpuid->eax_in =3D leaf; + cpuid->ecx_in =3D 0; + cpuidCall(cpuid); =20 /* Handle CPUID leaves that depend on previously queried bits or * which provide additional sub leaves for ecx_in > 0 */ if (leaf =3D=3D 0x4) - rc =3D cpuidSetLeaf4(data, &cpuid); + rc =3D cpuidSetLeaf4(data, &item); else if (leaf =3D=3D 0x7) - rc =3D cpuidSetLeaf7(data, &cpuid); + rc =3D cpuidSetLeaf7(data, &item); else if (leaf =3D=3D 0xb) - rc =3D cpuidSetLeafB(data, &cpuid); + rc =3D cpuidSetLeafB(data, &item); else if (leaf =3D=3D 0xd) - rc =3D cpuidSetLeafD(data, &cpuid); + rc =3D cpuidSetLeafD(data, &item); else if (leaf =3D=3D 0xf) - rc =3D cpuidSetLeafResID(data, &cpuid, cpuid.edx); + rc =3D cpuidSetLeafResID(data, &item, cpuid->edx); else if (leaf =3D=3D 0x10) - rc =3D cpuidSetLeafResID(data, &cpuid, cpuid.ebx); + rc =3D cpuidSetLeafResID(data, &item, cpuid->ebx); else if (leaf =3D=3D 0x12) - rc =3D cpuidSetLeaf12(data, &cpuid); + rc =3D cpuidSetLeaf12(data, &item); else if (leaf =3D=3D 0x14) - rc =3D cpuidSetLeaf14(data, &cpuid); + rc =3D cpuidSetLeaf14(data, &item); else if (leaf =3D=3D 0x17) - rc =3D cpuidSetLeaf17(data, &cpuid); + rc =3D cpuidSetLeaf17(data, &item); else - rc =3D virCPUx86DataAddCPUID(data, &cpuid); + rc =3D virCPUx86DataAddCPUID(data, &item); =20 if (rc < 0) return -1; @@ -3059,7 +3079,7 @@ virCPUx86ValidateFeatures(virCPUDefPtr cpu) =20 int virCPUx86DataAddCPUID(virCPUDataPtr cpuData, - const virCPUx86CPUID *cpuid) + const virCPUx86DataItem *cpuid) { return virCPUx86DataAddCPUIDInt(&cpuData->data.x86, cpuid); } @@ -3093,7 +3113,7 @@ int virCPUx86DataSetVendor(virCPUDataPtr cpuData, const char *vendor) { - virCPUx86CPUID cpuid =3D { 0 }; + virCPUx86DataItem cpuid =3D CPUID(0); =20 if (virCPUx86VendorToCPUID(vendor, &cpuid) < 0) return -1; diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h index 78714c0d67..166d4703aa 100644 --- a/src/cpu/cpu_x86.h +++ b/src/cpu/cpu_x86.h @@ -27,7 +27,7 @@ extern struct cpuArchDriver cpuDriverX86; =20 int virCPUx86DataAddCPUID(virCPUDataPtr cpuData, - const virCPUx86CPUID *cpuid); + const virCPUx86DataItem *cpuid); =20 int virCPUx86DataSetSignature(virCPUDataPtr cpuData, unsigned int family, diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index f3cc3952ed..0e63dd9245 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -23,6 +23,7 @@ =20 =20 typedef struct _virCPUx86CPUID virCPUx86CPUID; +typedef virCPUx86CPUID *virCPUx86CPUIDPtr; struct _virCPUx86CPUID { uint32_t eax_in; uint32_t ecx_in; @@ -68,10 +69,16 @@ struct _virCPUx86CPUID { =20 # define VIR_CPU_X86_DATA_INIT { 0 } =20 +typedef struct _virCPUx86DataItem virCPUx86DataItem; +typedef virCPUx86DataItem *virCPUx86DataItemPtr; +struct _virCPUx86DataItem { + virCPUx86CPUID cpuid; +}; + typedef struct _virCPUx86Data virCPUx86Data; struct _virCPUx86Data { size_t len; - virCPUx86CPUID *data; + virCPUx86DataItem *items; }; =20 #endif /* LIBVIRT_CPU_X86_DATA_H */ diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 19f90ba181..c19d05326d 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -66,13 +66,15 @@ struct guest_arch { static int libxlCapsAddCPUID(virCPUDataPtr data, virCPUx86CPUID *cpuid, ssize_t ncaps) { + virCPUx86DataItem item =3D { 0 }; size_t i; =20 for (i =3D 0; i < ncaps; i++) { - virCPUx86CPUID *c =3D &cpuid[i]; + item.cpuid =3D cpuid[i]; =20 - if (virCPUx86DataAddCPUID(data, c) < 0) { - VIR_DEBUG("Failed to add CPUID(%x,%x)", c->eax_in, c->ecx_in); + if (virCPUx86DataAddCPUID(data, &item) < 0) { + VIR_DEBUG("Failed to add CPUID(%x,%x)", + cpuid[i].eax_in, cpuid[i].ecx_in); return -1; } } diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 8e6c3ccd63..bee1b33f2a 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7186,7 +7186,7 @@ static virCPUDataPtr qemuMonitorJSONParseCPUx86Features(virJSONValuePtr data) { virCPUDataPtr cpudata =3D NULL; - virCPUx86CPUID cpuid; + virCPUx86DataItem item =3D { 0 }; size_t i; =20 if (!(cpudata =3D virCPUDataNew(VIR_ARCH_X86_64))) @@ -7194,8 +7194,8 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr da= ta) =20 for (i =3D 0; i < virJSONValueArraySize(data); i++) { if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(dat= a, i), - &cpuid) < 0 || - virCPUx86DataAddCPUID(cpudata, &cpuid) < 0) + &item.cpuid) < 0 || + virCPUx86DataAddCPUID(cpudata, &item) < 0) goto error; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713002507650.4386143568562; Mon, 8 Apr 2019 01:43:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BA7F2308CF8A; Mon, 8 Apr 2019 08:43:20 +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 87F5C1A267; Mon, 8 Apr 2019 08:43:20 +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 47E2B181BA04; Mon, 8 Apr 2019 08:43:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gvD5009131 for ; Mon, 8 Apr 2019 04:42:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id E7F66189FA; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB3D8600D4 for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id ACC0810363F; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:11 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/36] cpu_x86: Rename virCPUx86Vendor.cpuid 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Mon, 08 Apr 2019 08:43:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Although vendor string is always reported by CPUID, the container struct is used for consistency and thus "cpuid" name is not a good fit anymore. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index c7937d55fd..8a10c237e9 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -45,7 +45,7 @@ typedef struct _virCPUx86Vendor virCPUx86Vendor; typedef virCPUx86Vendor *virCPUx86VendorPtr; struct _virCPUx86Vendor { char *name; - virCPUx86DataItem cpuid; + virCPUx86DataItem data; }; =20 typedef struct _virCPUx86Feature virCPUx86Feature; @@ -515,9 +515,9 @@ x86DataToVendor(const virCPUx86Data *data, =20 for (i =3D 0; i < map->nvendors; i++) { virCPUx86VendorPtr vendor =3D map->vendors[i]; - if ((cpuid =3D x86DataCpuid(data, &vendor->cpuid)) && - x86cpuidMatchMasked(&cpuid->cpuid, &vendor->cpuid.cpuid)) { - x86cpuidClearBits(&cpuid->cpuid, &vendor->cpuid.cpuid); + if ((cpuid =3D x86DataCpuid(data, &vendor->data)) && + x86cpuidMatchMasked(&cpuid->cpuid, &vendor->data.cpuid)) { + x86cpuidClearBits(&cpuid->cpuid, &vendor->data.cpuid); return vendor; } } @@ -760,7 +760,7 @@ x86VendorParse(xmlXPathContextPtr ctxt, goto cleanup; } =20 - if (virCPUx86VendorToCPUID(string, &vendor->cpuid) < 0) + if (virCPUx86VendorToCPUID(string, &vendor->data) < 0) goto cleanup; =20 if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0) @@ -1666,7 +1666,7 @@ x86Compute(virCPUDefPtr host, =20 if (cpu->vendor && host_model->vendor && virCPUx86DataAddCPUIDInt(&guest_model->data, - &host_model->vendor->cpuid) < 0) + &host_model->vendor->data) < 0) goto error; =20 if (host_model->signatures && @@ -2154,7 +2154,7 @@ x86Encode(virArch arch, if (!(data_vendor =3D virCPUDataNew(arch))) goto error; =20 - if (v && virCPUx86DataAddCPUID(data_vendor, &v->cpuid) < 0) + if (v && virCPUx86DataAddCPUID(data_vendor, &v->data) < 0) goto error; } =20 @@ -2651,7 +2651,7 @@ virCPUx86Baseline(virCPUDefPtr *cpus, } =20 if (vendor && - virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->cpuid) < 0) + virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->data) < 0) goto error; =20 if (x86Decode(cpu, &base_model->data, models, modelName, migratable) <= 0) @@ -2950,7 +2950,7 @@ virCPUx86Translate(virCPUDefPtr cpu, goto cleanup; =20 if (model->vendor && - virCPUx86DataAddCPUIDInt(&model->data, &model->vendor->cpuid) < 0) + virCPUx86DataAddCPUIDInt(&model->data, &model->vendor->data) < 0) goto cleanup; =20 if (model->signatures && --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712986392829.211281861485; Mon, 8 Apr 2019 01:43:06 -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 718FD883B8; Mon, 8 Apr 2019 08:43:04 +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 3D7DF63B86; Mon, 8 Apr 2019 08:43:04 +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 E3CE13FB30; Mon, 8 Apr 2019 08:43:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gtcG009071 for ; Mon, 8 Apr 2019 04:42:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id E7A48665C8; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9622760A9E for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B2B85103641; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:12 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 08/36] cpu_x86: Rename virCPUx86DataItem variables 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:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 128 +++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 8a10c237e9..6c77b7ce13 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -329,13 +329,13 @@ x86DataCpuidNext(virCPUx86DataIteratorPtr iterator) =20 static virCPUx86DataItemPtr x86DataCpuid(const virCPUx86Data *data, - const virCPUx86DataItem *cpuid) + const virCPUx86DataItem *item) { size_t i; =20 for (i =3D 0; i < data->len; i++) { - if (data->items[i].cpuid.eax_in =3D=3D cpuid->cpuid.eax_in && - data->items[i].cpuid.ecx_in =3D=3D cpuid->cpuid.ecx_in) + if (data->items[i].cpuid.eax_in =3D=3D item->cpuid.eax_in && + data->items[i].cpuid.ecx_in =3D=3D item->cpuid.ecx_in) return data->items + i; } =20 @@ -381,15 +381,15 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *= src) =20 static int virCPUx86DataAddCPUIDInt(virCPUx86Data *data, - const virCPUx86DataItem *cpuid) + const virCPUx86DataItem *item) { virCPUx86DataItemPtr existing; =20 - if ((existing =3D x86DataCpuid(data, cpuid))) { - x86cpuidSetBits(&existing->cpuid, &cpuid->cpuid); + if ((existing =3D x86DataCpuid(data, item))) { + x86cpuidSetBits(&existing->cpuid, &item->cpuid); } else { if (VIR_APPEND_ELEMENT_COPY(data->items, data->len, - *((virCPUx86DataItemPtr)cpuid)) < 0) + *((virCPUx86DataItemPtr)item)) < 0) return -1; =20 qsort(data->items, data->len, @@ -405,16 +405,16 @@ x86DataAdd(virCPUx86Data *data1, const virCPUx86Data *data2) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(data2); - virCPUx86DataItemPtr cpuid1; - virCPUx86DataItemPtr cpuid2; + virCPUx86DataItemPtr item1; + virCPUx86DataItemPtr item2; =20 - while ((cpuid2 =3D x86DataCpuidNext(&iter))) { - cpuid1 =3D x86DataCpuid(data1, cpuid2); + while ((item2 =3D x86DataCpuidNext(&iter))) { + item1 =3D x86DataCpuid(data1, item2); =20 - if (cpuid1) { - x86cpuidSetBits(&cpuid1->cpuid, &cpuid2->cpuid); + if (item1) { + x86cpuidSetBits(&item1->cpuid, &item2->cpuid); } else { - if (virCPUx86DataAddCPUIDInt(data1, cpuid2) < 0) + if (virCPUx86DataAddCPUIDInt(data1, item2) < 0) return -1; } } @@ -428,12 +428,12 @@ x86DataSubtract(virCPUx86Data *data1, const virCPUx86Data *data2) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(data1); - virCPUx86DataItemPtr cpuid1; - virCPUx86DataItemPtr cpuid2; + virCPUx86DataItemPtr item1; + virCPUx86DataItemPtr item2; =20 - while ((cpuid1 =3D x86DataCpuidNext(&iter))) { - if ((cpuid2 =3D x86DataCpuid(data2, cpuid1))) - x86cpuidClearBits(&cpuid1->cpuid, &cpuid2->cpuid); + while ((item1 =3D x86DataCpuidNext(&iter))) { + if ((item2 =3D x86DataCpuid(data2, item1))) + x86cpuidClearBits(&item1->cpuid, &item2->cpuid); } } =20 @@ -443,15 +443,15 @@ x86DataIntersect(virCPUx86Data *data1, const virCPUx86Data *data2) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(data1); - virCPUx86DataItemPtr cpuid1; - virCPUx86DataItemPtr cpuid2; + virCPUx86DataItemPtr item1; + virCPUx86DataItemPtr item2; =20 - while ((cpuid1 =3D x86DataCpuidNext(&iter))) { - cpuid2 =3D x86DataCpuid(data2, cpuid1); - if (cpuid2) - x86cpuidAndBits(&cpuid1->cpuid, &cpuid2->cpuid); + while ((item1 =3D x86DataCpuidNext(&iter))) { + item2 =3D x86DataCpuid(data2, item1); + if (item2) + x86cpuidAndBits(&item1->cpuid, &item2->cpuid); else - x86cpuidClearBits(&cpuid1->cpuid, &cpuid1->cpuid); + x86cpuidClearBits(&item1->cpuid, &item1->cpuid); } } =20 @@ -470,12 +470,12 @@ x86DataIsSubset(const virCPUx86Data *data, const virCPUx86Data *subset) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit((virCPUx86Dat= a *)subset); - const virCPUx86DataItem *cpuid; - const virCPUx86DataItem *cpuidSubset; + const virCPUx86DataItem *item; + const virCPUx86DataItem *itemSubset; =20 - while ((cpuidSubset =3D x86DataCpuidNext(&iter))) { - if (!(cpuid =3D x86DataCpuid(data, cpuidSubset)) || - !x86cpuidMatchMasked(&cpuid->cpuid, &cpuidSubset->cpuid)) + while ((itemSubset =3D x86DataCpuidNext(&iter))) { + if (!(item =3D x86DataCpuid(data, itemSubset)) || + !x86cpuidMatchMasked(&item->cpuid, &itemSubset->cpuid)) return false; } =20 @@ -510,14 +510,14 @@ static virCPUx86VendorPtr x86DataToVendor(const virCPUx86Data *data, virCPUx86MapPtr map) { - virCPUx86DataItemPtr cpuid; + virCPUx86DataItemPtr item; size_t i; =20 for (i =3D 0; i < map->nvendors; i++) { virCPUx86VendorPtr vendor =3D map->vendors[i]; - if ((cpuid =3D x86DataCpuid(data, &vendor->data)) && - x86cpuidMatchMasked(&cpuid->cpuid, &vendor->data.cpuid)) { - x86cpuidClearBits(&cpuid->cpuid, &vendor->data.cpuid); + if ((item =3D x86DataCpuid(data, &vendor->data)) && + x86cpuidMatchMasked(&item->cpuid, &vendor->data.cpuid)) { + x86cpuidClearBits(&item->cpuid, &vendor->data.cpuid); return vendor; } } @@ -627,12 +627,12 @@ static uint32_t x86DataToSignature(const virCPUx86Data *data) { virCPUx86DataItem leaf1 =3D CPUID(.eax_in =3D 0x1); - virCPUx86DataItemPtr cpuid; + virCPUx86DataItemPtr item; =20 - if (!(cpuid =3D x86DataCpuid(data, &leaf1))) + if (!(item =3D x86DataCpuid(data, &leaf1))) return 0; =20 - return cpuid->cpuid.eax & SIGNATURE_MASK; + return item->cpuid.eax & SIGNATURE_MASK; } =20 =20 @@ -640,9 +640,9 @@ static int x86DataAddSignature(virCPUx86Data *data, uint32_t signature) { - virCPUx86DataItem cpuid =3D CPUID(.eax_in =3D 0x1, .eax =3D signature); + virCPUx86DataItem leaf1 =3D CPUID(.eax_in =3D 0x1, .eax =3D signature); =20 - return virCPUx86DataAddCPUIDInt(data, &cpuid); + return virCPUx86DataAddCPUIDInt(data, &leaf1); } =20 =20 @@ -906,7 +906,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, virCPUx86MapPtr map =3D data; xmlNodePtr *nodes =3D NULL; virCPUx86FeaturePtr feature; - virCPUx86DataItem cpuid; + virCPUx86DataItem item; size_t i; int n; char *str =3D NULL; @@ -943,13 +943,13 @@ x86FeatureParse(xmlXPathContextPtr ctxt, =20 for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; - if (x86ParseCPUID(ctxt, &cpuid) < 0) { + if (x86ParseCPUID(ctxt, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Invalid cpuid[%zu] in %s feature"), i, feature->name); goto cleanup; } - if (virCPUx86DataAddCPUIDInt(&feature->data, &cpuid)) + if (virCPUx86DataAddCPUIDInt(&feature->data, &item)) goto cleanup; } =20 @@ -1149,16 +1149,16 @@ x86ModelCompare(virCPUx86ModelPtr model1, virCPUx86CompareResult result =3D EQUAL; virCPUx86DataIterator iter1 =3D virCPUx86DataIteratorInit(&model1->dat= a); virCPUx86DataIterator iter2 =3D virCPUx86DataIteratorInit(&model2->dat= a); - virCPUx86DataItemPtr cpuid1; - virCPUx86DataItemPtr cpuid2; + virCPUx86DataItemPtr item1; + virCPUx86DataItemPtr item2; =20 - while ((cpuid1 =3D x86DataCpuidNext(&iter1))) { + while ((item1 =3D x86DataCpuidNext(&iter1))) { virCPUx86CompareResult match =3D SUPERSET; =20 - if ((cpuid2 =3D x86DataCpuid(&model2->data, cpuid1))) { - if (x86cpuidMatch(&cpuid1->cpuid, &cpuid2->cpuid)) + if ((item2 =3D x86DataCpuid(&model2->data, item1))) { + if (x86cpuidMatch(&item1->cpuid, &item2->cpuid)) continue; - else if (!x86cpuidMatchMasked(&cpuid1->cpuid, &cpuid2->cpuid)) + else if (!x86cpuidMatchMasked(&item1->cpuid, &item2->cpuid)) match =3D SUBSET; } =20 @@ -1168,13 +1168,13 @@ x86ModelCompare(virCPUx86ModelPtr model1, return UNRELATED; } =20 - while ((cpuid2 =3D x86DataCpuidNext(&iter2))) { + while ((item2 =3D x86DataCpuidNext(&iter2))) { virCPUx86CompareResult match =3D SUBSET; =20 - if ((cpuid1 =3D x86DataCpuid(&model1->data, cpuid2))) { - if (x86cpuidMatch(&cpuid2->cpuid, &cpuid1->cpuid)) + if ((item1 =3D x86DataCpuid(&model1->data, item2))) { + if (x86cpuidMatch(&item2->cpuid, &item1->cpuid)) continue; - else if (!x86cpuidMatchMasked(&cpuid2->cpuid, &cpuid1->cpuid)) + else if (!x86cpuidMatchMasked(&item2->cpuid, &item1->cpuid)) match =3D SUPERSET; } =20 @@ -1485,7 +1485,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) { xmlNodePtr *nodes =3D NULL; virCPUDataPtr cpuData =3D NULL; - virCPUx86DataItem cpuid; + virCPUx86DataItem item; size_t i; int n; =20 @@ -1501,12 +1501,12 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) =20 for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; - if (x86ParseCPUID(ctxt, &cpuid) < 0) { + if (x86ParseCPUID(ctxt, &item) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("failed to parse cpuid[%zu]"), i); goto error; } - if (virCPUx86DataAddCPUID(cpuData, &cpuid) < 0) + if (virCPUx86DataAddCPUID(cpuData, &item) < 0) goto error; } =20 @@ -2383,10 +2383,10 @@ cpuidSetLeaf12(virCPUDataPtr data, { virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x7); virCPUx86CPUIDPtr cpuid =3D &item.cpuid; - virCPUx86DataItemPtr cpuid7; + virCPUx86DataItemPtr leaf7; =20 - if (!(cpuid7 =3D x86DataCpuid(&data->data.x86, &item)) || - !(cpuid7->cpuid.ebx & (1 << 2))) + if (!(leaf7 =3D x86DataCpuid(&data->data.x86, &item)) || + !(leaf7->cpuid.ebx & (1 << 2))) return 0; =20 if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) @@ -3079,9 +3079,9 @@ virCPUx86ValidateFeatures(virCPUDefPtr cpu) =20 int virCPUx86DataAddCPUID(virCPUDataPtr cpuData, - const virCPUx86DataItem *cpuid) + const virCPUx86DataItem *item) { - return virCPUx86DataAddCPUIDInt(&cpuData->data.x86, cpuid); + return virCPUx86DataAddCPUIDInt(&cpuData->data.x86, item); } =20 =20 @@ -3113,12 +3113,12 @@ int virCPUx86DataSetVendor(virCPUDataPtr cpuData, const char *vendor) { - virCPUx86DataItem cpuid =3D CPUID(0); + virCPUx86DataItem item =3D CPUID(0); =20 - if (virCPUx86VendorToCPUID(vendor, &cpuid) < 0) + if (virCPUx86VendorToCPUID(vendor, &item) < 0) return -1; =20 - return virCPUx86DataAddCPUID(cpuData, &cpuid); + return virCPUx86DataAddCPUID(cpuData, &item); } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712995004928.136310364163; Mon, 8 Apr 2019 01:43:15 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5A52A2D7EC; Mon, 8 Apr 2019 08:43:13 +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 2D68C5DA38; Mon, 8 Apr 2019 08:43:13 +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 D5E06181B9EF; Mon, 8 Apr 2019 08:43:12 +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 x388gvS9009113 for ; Mon, 8 Apr 2019 04:42:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id BD5305D721; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 92F6F5D71E for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B84CB103642; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:13 +0200 Message-Id: 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 09/36] cpu_x86: Rename x86DataCpuidNext function 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 08 Apr 2019 08:43:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function is now called virCPUx86DataNext to reflect its purpose: it is an iterator over CPU data (both CPUID and MSR in the near future). Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 6c77b7ce13..5c2f7900a3 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -309,7 +309,7 @@ virCPUx86CPUIDSorter(const void *a, const void *b) =20 /* skips all zero CPUID leaves */ static virCPUx86DataItemPtr -x86DataCpuidNext(virCPUx86DataIteratorPtr iterator) +virCPUx86DataNext(virCPUx86DataIteratorPtr iterator) { const virCPUx86Data *data =3D iterator->data; =20 @@ -408,7 +408,7 @@ x86DataAdd(virCPUx86Data *data1, virCPUx86DataItemPtr item1; virCPUx86DataItemPtr item2; =20 - while ((item2 =3D x86DataCpuidNext(&iter))) { + while ((item2 =3D virCPUx86DataNext(&iter))) { item1 =3D x86DataCpuid(data1, item2); =20 if (item1) { @@ -431,7 +431,7 @@ x86DataSubtract(virCPUx86Data *data1, virCPUx86DataItemPtr item1; virCPUx86DataItemPtr item2; =20 - while ((item1 =3D x86DataCpuidNext(&iter))) { + while ((item1 =3D virCPUx86DataNext(&iter))) { if ((item2 =3D x86DataCpuid(data2, item1))) x86cpuidClearBits(&item1->cpuid, &item2->cpuid); } @@ -446,7 +446,7 @@ x86DataIntersect(virCPUx86Data *data1, virCPUx86DataItemPtr item1; virCPUx86DataItemPtr item2; =20 - while ((item1 =3D x86DataCpuidNext(&iter))) { + while ((item1 =3D virCPUx86DataNext(&iter))) { item2 =3D x86DataCpuid(data2, item1); if (item2) x86cpuidAndBits(&item1->cpuid, &item2->cpuid); @@ -461,7 +461,7 @@ x86DataIsEmpty(virCPUx86Data *data) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(data); =20 - return !x86DataCpuidNext(&iter); + return !virCPUx86DataNext(&iter); } =20 =20 @@ -473,7 +473,7 @@ x86DataIsSubset(const virCPUx86Data *data, const virCPUx86DataItem *item; const virCPUx86DataItem *itemSubset; =20 - while ((itemSubset =3D x86DataCpuidNext(&iter))) { + while ((itemSubset =3D virCPUx86DataNext(&iter))) { if (!(item =3D x86DataCpuid(data, itemSubset)) || !x86cpuidMatchMasked(&item->cpuid, &itemSubset->cpuid)) return false; @@ -1152,7 +1152,7 @@ x86ModelCompare(virCPUx86ModelPtr model1, virCPUx86DataItemPtr item1; virCPUx86DataItemPtr item2; =20 - while ((item1 =3D x86DataCpuidNext(&iter1))) { + while ((item1 =3D virCPUx86DataNext(&iter1))) { virCPUx86CompareResult match =3D SUPERSET; =20 if ((item2 =3D x86DataCpuid(&model2->data, item1))) { @@ -1168,7 +1168,7 @@ x86ModelCompare(virCPUx86ModelPtr model1, return UNRELATED; } =20 - while ((item2 =3D x86DataCpuidNext(&iter2))) { + while ((item2 =3D virCPUx86DataNext(&iter2))) { virCPUx86CompareResult match =3D SUBSET; =20 if ((item1 =3D x86DataCpuid(&model1->data, item2))) { @@ -1462,7 +1462,7 @@ virCPUx86DataFormat(const virCPUData *data) virBuffer buf =3D VIR_BUFFER_INITIALIZER; =20 virBufferAddLit(&buf, "\n"); - while ((item =3D x86DataCpuidNext(&iter))) { + while ((item =3D virCPUx86DataNext(&iter))) { virCPUx86CPUIDPtr cpuid =3D &item->cpuid; virBufferAsprintf(&buf, " Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554713004969824.3432927811169; Mon, 8 Apr 2019 01:43:24 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4964D31524FB; Mon, 8 Apr 2019 08:43:23 +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 1D99360FC8; Mon, 8 Apr 2019 08:43:23 +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 CB4053D39D; Mon, 8 Apr 2019 08:43:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gwVp009144 for ; Mon, 8 Apr 2019 04:42:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 19C6D600D4; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BBE006013D for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id BDC40103643; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:14 +0200 Message-Id: <4fdc0f0df7024517311e43bca97b8b9c7f9144ee.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 10/36] cpu_x86: Rename x86DataCpuid 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 08 Apr 2019 08:43:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It is now called virCPUx86DataGet. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 5c2f7900a3..ad5e23843f 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -328,8 +328,8 @@ virCPUx86DataNext(virCPUx86DataIteratorPtr iterator) =20 =20 static virCPUx86DataItemPtr -x86DataCpuid(const virCPUx86Data *data, - const virCPUx86DataItem *item) +virCPUx86DataGet(const virCPUx86Data *data, + const virCPUx86DataItem *item) { size_t i; =20 @@ -385,7 +385,7 @@ virCPUx86DataAddCPUIDInt(virCPUx86Data *data, { virCPUx86DataItemPtr existing; =20 - if ((existing =3D x86DataCpuid(data, item))) { + if ((existing =3D virCPUx86DataGet(data, item))) { x86cpuidSetBits(&existing->cpuid, &item->cpuid); } else { if (VIR_APPEND_ELEMENT_COPY(data->items, data->len, @@ -409,7 +409,7 @@ x86DataAdd(virCPUx86Data *data1, virCPUx86DataItemPtr item2; =20 while ((item2 =3D virCPUx86DataNext(&iter))) { - item1 =3D x86DataCpuid(data1, item2); + item1 =3D virCPUx86DataGet(data1, item2); =20 if (item1) { x86cpuidSetBits(&item1->cpuid, &item2->cpuid); @@ -432,7 +432,7 @@ x86DataSubtract(virCPUx86Data *data1, virCPUx86DataItemPtr item2; =20 while ((item1 =3D virCPUx86DataNext(&iter))) { - if ((item2 =3D x86DataCpuid(data2, item1))) + if ((item2 =3D virCPUx86DataGet(data2, item1))) x86cpuidClearBits(&item1->cpuid, &item2->cpuid); } } @@ -447,7 +447,7 @@ x86DataIntersect(virCPUx86Data *data1, virCPUx86DataItemPtr item2; =20 while ((item1 =3D virCPUx86DataNext(&iter))) { - item2 =3D x86DataCpuid(data2, item1); + item2 =3D virCPUx86DataGet(data2, item1); if (item2) x86cpuidAndBits(&item1->cpuid, &item2->cpuid); else @@ -474,7 +474,7 @@ x86DataIsSubset(const virCPUx86Data *data, const virCPUx86DataItem *itemSubset; =20 while ((itemSubset =3D virCPUx86DataNext(&iter))) { - if (!(item =3D x86DataCpuid(data, itemSubset)) || + if (!(item =3D virCPUx86DataGet(data, itemSubset)) || !x86cpuidMatchMasked(&item->cpuid, &itemSubset->cpuid)) return false; } @@ -515,7 +515,7 @@ x86DataToVendor(const virCPUx86Data *data, =20 for (i =3D 0; i < map->nvendors; i++) { virCPUx86VendorPtr vendor =3D map->vendors[i]; - if ((item =3D x86DataCpuid(data, &vendor->data)) && + if ((item =3D virCPUx86DataGet(data, &vendor->data)) && x86cpuidMatchMasked(&item->cpuid, &vendor->data.cpuid)) { x86cpuidClearBits(&item->cpuid, &vendor->data.cpuid); return vendor; @@ -610,7 +610,7 @@ x86DataToSignatureFull(const virCPUx86Data *data, =20 *family =3D *model =3D *stepping =3D 0; =20 - if (!(item =3D x86DataCpuid(data, &leaf1))) + if (!(item =3D virCPUx86DataGet(data, &leaf1))) return; =20 cpuid =3D &item->cpuid; @@ -629,7 +629,7 @@ x86DataToSignature(const virCPUx86Data *data) virCPUx86DataItem leaf1 =3D CPUID(.eax_in =3D 0x1); virCPUx86DataItemPtr item; =20 - if (!(item =3D x86DataCpuid(data, &leaf1))) + if (!(item =3D virCPUx86DataGet(data, &leaf1))) return 0; =20 return item->cpuid.eax & SIGNATURE_MASK; @@ -1155,7 +1155,7 @@ x86ModelCompare(virCPUx86ModelPtr model1, while ((item1 =3D virCPUx86DataNext(&iter1))) { virCPUx86CompareResult match =3D SUPERSET; =20 - if ((item2 =3D x86DataCpuid(&model2->data, item1))) { + if ((item2 =3D virCPUx86DataGet(&model2->data, item1))) { if (x86cpuidMatch(&item1->cpuid, &item2->cpuid)) continue; else if (!x86cpuidMatchMasked(&item1->cpuid, &item2->cpuid)) @@ -1171,7 +1171,7 @@ x86ModelCompare(virCPUx86ModelPtr model1, while ((item2 =3D virCPUx86DataNext(&iter2))) { virCPUx86CompareResult match =3D SUBSET; =20 - if ((item1 =3D x86DataCpuid(&model1->data, item2))) { + if ((item1 =3D virCPUx86DataGet(&model1->data, item2))) { if (x86cpuidMatch(&item2->cpuid, &item1->cpuid)) continue; else if (!x86cpuidMatchMasked(&item2->cpuid, &item1->cpuid)) @@ -2385,7 +2385,7 @@ cpuidSetLeaf12(virCPUDataPtr data, virCPUx86CPUIDPtr cpuid =3D &item.cpuid; virCPUx86DataItemPtr leaf7; =20 - if (!(leaf7 =3D x86DataCpuid(&data->data.x86, &item)) || + if (!(leaf7 =3D virCPUx86DataGet(&data->data.x86, &item)) || !(leaf7->cpuid.ebx & (1 << 2))) return 0; =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712981873889.9557062215442; Mon, 8 Apr 2019 01:43:01 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 0F7A6753F7; Mon, 8 Apr 2019 08:43:00 +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 DF02C1091EF6; Mon, 8 Apr 2019 08:42:59 +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 8ED82181B9E0; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gt3O009066 for ; Mon, 8 Apr 2019 04:42:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id CD3DA1803A; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A04BC18033 for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C30A8103644; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:15 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 11/36] cpu_x86: Rename virCPUx86CPUIDSorter 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Mon, 08 Apr 2019 08:43:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It is called virCPUx86DataSorter since the function will work on any CPU data type. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index ad5e23843f..b354339852 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -288,7 +288,7 @@ x86FeatureFindInternal(const char *name) =20 =20 static int -virCPUx86CPUIDSorter(const void *a, const void *b) +virCPUx86DataSorter(const void *a, const void *b) { virCPUx86DataItemPtr da =3D (virCPUx86DataItemPtr) a; virCPUx86DataItemPtr db =3D (virCPUx86DataItemPtr) b; @@ -393,7 +393,7 @@ virCPUx86DataAddCPUIDInt(virCPUx86Data *data, return -1; =20 qsort(data->items, data->len, - sizeof(virCPUx86DataItem), virCPUx86CPUIDSorter); + sizeof(virCPUx86DataItem), virCPUx86DataSorter); } =20 return 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712998730874.4032768255032; Mon, 8 Apr 2019 01:43:18 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B55087649; Mon, 8 Apr 2019 08:43:17 +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 D1F705D717; Mon, 8 Apr 2019 08:43:16 +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 92AFE181B9F5; Mon, 8 Apr 2019 08:43:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gv4G009132 for ; Mon, 8 Apr 2019 04:42:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id E81C563B86; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB4416013A for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id C85B4103645; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:16 +0200 Message-Id: <75a028b2a424b55f250faa106c98dd7189e6b8e4.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 12/36] cpu_x86: Rename virCPUx86DataAddCPUIDInt 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.15 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:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The new name is virCPUx86DataAddItem. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index b354339852..21f58a8c3f 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -380,8 +380,8 @@ x86DataCopy(virCPUx86Data *dst, const virCPUx86Data *sr= c) =20 =20 static int -virCPUx86DataAddCPUIDInt(virCPUx86Data *data, - const virCPUx86DataItem *item) +virCPUx86DataAddItem(virCPUx86Data *data, + const virCPUx86DataItem *item) { virCPUx86DataItemPtr existing; =20 @@ -414,7 +414,7 @@ x86DataAdd(virCPUx86Data *data1, if (item1) { x86cpuidSetBits(&item1->cpuid, &item2->cpuid); } else { - if (virCPUx86DataAddCPUIDInt(data1, item2) < 0) + if (virCPUx86DataAddItem(data1, item2) < 0) return -1; } } @@ -642,7 +642,7 @@ x86DataAddSignature(virCPUx86Data *data, { virCPUx86DataItem leaf1 =3D CPUID(.eax_in =3D 0x1, .eax =3D signature); =20 - return virCPUx86DataAddCPUIDInt(data, &leaf1); + return virCPUx86DataAddItem(data, &leaf1); } =20 =20 @@ -949,7 +949,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt, i, feature->name); goto cleanup; } - if (virCPUx86DataAddCPUIDInt(&feature->data, &item)) + if (virCPUx86DataAddItem(&feature->data, &item)) goto cleanup; } =20 @@ -1665,8 +1665,8 @@ x86Compute(virCPUDefPtr host, goto error; =20 if (cpu->vendor && host_model->vendor && - virCPUx86DataAddCPUIDInt(&guest_model->data, - &host_model->vendor->data) < 0) + virCPUx86DataAddItem(&guest_model->data, + &host_model->vendor->data) < 0) goto error; =20 if (host_model->signatures && @@ -2651,7 +2651,7 @@ virCPUx86Baseline(virCPUDefPtr *cpus, } =20 if (vendor && - virCPUx86DataAddCPUIDInt(&base_model->data, &vendor->data) < 0) + virCPUx86DataAddItem(&base_model->data, &vendor->data) < 0) goto error; =20 if (x86Decode(cpu, &base_model->data, models, modelName, migratable) <= 0) @@ -2950,7 +2950,7 @@ virCPUx86Translate(virCPUDefPtr cpu, goto cleanup; =20 if (model->vendor && - virCPUx86DataAddCPUIDInt(&model->data, &model->vendor->data) < 0) + virCPUx86DataAddItem(&model->data, &model->vendor->data) < 0) goto cleanup; =20 if (model->signatures && @@ -3081,7 +3081,7 @@ int virCPUx86DataAddCPUID(virCPUDataPtr cpuData, const virCPUx86DataItem *item) { - return virCPUx86DataAddCPUIDInt(&cpuData->data.x86, item); + return virCPUx86DataAddItem(&cpuData->data.x86, item); } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712990314144.7562985930566; Mon, 8 Apr 2019 01:43:10 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 4553C3082B66; Mon, 8 Apr 2019 08:43:08 +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 1DE9F109B79D; Mon, 8 Apr 2019 08:43:08 +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 C12EE3FAF6; Mon, 8 Apr 2019 08:43:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gukt009081 for ; Mon, 8 Apr 2019 04:42:56 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3ECE360A9E; Mon, 8 Apr 2019 08:42:56 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E1A9166090 for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id CE3FD103646; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:17 +0200 Message-Id: <244006b3df9cc07f9b5db3a1e4ab32a8788a65a8.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 13/36] cpu_x86: Rename virCPUx86DataAddCPUID 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 08 Apr 2019 08:43:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" It's called virCPUx86DataAdd now. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 46 +++++++++++++++++----------------- src/cpu/cpu_x86.h | 4 +-- src/libvirt_private.syms | 2 +- src/libxl/libxl_capabilities.c | 2 +- src/qemu/qemu_monitor_json.c | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 21f58a8c3f..492839496e 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1506,7 +1506,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) _("failed to parse cpuid[%zu]"), i); goto error; } - if (virCPUx86DataAddCPUID(cpuData, &item) < 0) + if (virCPUx86DataAdd(cpuData, &item) < 0) goto error; } =20 @@ -2154,7 +2154,7 @@ x86Encode(virArch arch, if (!(data_vendor =3D virCPUDataNew(arch))) goto error; =20 - if (v && virCPUx86DataAddCPUID(data_vendor, &v->data) < 0) + if (v && virCPUx86DataAdd(data_vendor, &v->data) < 0) goto error; } =20 @@ -2230,13 +2230,13 @@ cpuidSetLeaf4(virCPUDataPtr data, virCPUx86DataItem item =3D *subLeaf0; virCPUx86CPUIDPtr cpuid =3D &item.cpuid; =20 - if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) + if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 while (cpuid->eax & 0x1f) { cpuid->ecx_in++; cpuidCall(cpuid); - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; } return 0; @@ -2255,13 +2255,13 @@ cpuidSetLeaf7(virCPUDataPtr data, virCPUx86CPUIDPtr cpuid =3D &item.cpuid; uint32_t sub; =20 - if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) + if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { cpuid->ecx_in =3D sub; cpuidCall(cpuid); - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; } return 0; @@ -2283,7 +2283,7 @@ cpuidSetLeafB(virCPUDataPtr data, virCPUx86CPUIDPtr cpuid =3D &item.cpuid; =20 while (cpuid->ecx & 0xff00) { - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; cpuid->ecx_in++; cpuidCall(cpuid); @@ -2310,12 +2310,12 @@ cpuidSetLeafD(virCPUDataPtr data, virCPUx86CPUID sub1; uint32_t sub; =20 - if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) + if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 cpuid->ecx_in =3D 1; cpuidCall(cpuid); - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; =20 sub0 =3D subLeaf0->cpuid; @@ -2332,7 +2332,7 @@ cpuidSetLeafD(virCPUDataPtr data, =20 cpuid->ecx_in =3D sub; cpuidCall(cpuid); - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; } return 0; @@ -2357,7 +2357,7 @@ cpuidSetLeafResID(virCPUDataPtr data, virCPUx86CPUIDPtr cpuid =3D &item.cpuid; uint32_t sub; =20 - if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) + if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 for (sub =3D 1; sub < 32; sub++) { @@ -2365,7 +2365,7 @@ cpuidSetLeafResID(virCPUDataPtr data, continue; cpuid->ecx_in =3D sub; cpuidCall(cpuid); - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; } return 0; @@ -2389,19 +2389,19 @@ cpuidSetLeaf12(virCPUDataPtr data, !(leaf7->cpuid.ebx & (1 << 2))) return 0; =20 - if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) + if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 cpuid->eax_in =3D 0x12; cpuid->ecx_in =3D 1; cpuidCall(cpuid); - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; =20 cpuid->ecx_in =3D 2; cpuidCall(cpuid); while (cpuid->eax & 0xf) { - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; cpuid->ecx_in++; cpuidCall(cpuid); @@ -2422,13 +2422,13 @@ cpuidSetLeaf14(virCPUDataPtr data, virCPUx86CPUIDPtr cpuid =3D &item.cpuid; uint32_t sub; =20 - if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) + if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { cpuid->ecx_in =3D sub; cpuidCall(cpuid); - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; } return 0; @@ -2451,13 +2451,13 @@ cpuidSetLeaf17(virCPUDataPtr data, if (subLeaf0->cpuid.eax < 3) return 0; =20 - if (virCPUx86DataAddCPUID(data, subLeaf0) < 0) + if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { cpuid->ecx_in =3D sub; cpuidCall(cpuid); - if (virCPUx86DataAddCPUID(data, &item) < 0) + if (virCPUx86DataAdd(data, &item) < 0) return -1; } return 0; @@ -2503,7 +2503,7 @@ cpuidSet(uint32_t base, virCPUDataPtr data) else if (leaf =3D=3D 0x17) rc =3D cpuidSetLeaf17(data, &item); else - rc =3D virCPUx86DataAddCPUID(data, &item); + rc =3D virCPUx86DataAdd(data, &item); =20 if (rc < 0) return -1; @@ -3078,8 +3078,8 @@ virCPUx86ValidateFeatures(virCPUDefPtr cpu) =20 =20 int -virCPUx86DataAddCPUID(virCPUDataPtr cpuData, - const virCPUx86DataItem *item) +virCPUx86DataAdd(virCPUDataPtr cpuData, + const virCPUx86DataItem *item) { return virCPUx86DataAddItem(&cpuData->data.x86, item); } @@ -3118,7 +3118,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData, if (virCPUx86VendorToCPUID(vendor, &item) < 0) return -1; =20 - return virCPUx86DataAddCPUID(cpuData, &item); + return virCPUx86DataAdd(cpuData, &item); } =20 =20 diff --git a/src/cpu/cpu_x86.h b/src/cpu/cpu_x86.h index 166d4703aa..cd44cbe4f3 100644 --- a/src/cpu/cpu_x86.h +++ b/src/cpu/cpu_x86.h @@ -26,8 +26,8 @@ =20 extern struct cpuArchDriver cpuDriverX86; =20 -int virCPUx86DataAddCPUID(virCPUDataPtr cpuData, - const virCPUx86DataItem *cpuid); +int virCPUx86DataAdd(virCPUDataPtr cpuData, + const virCPUx86DataItem *cpuid); =20 int virCPUx86DataSetSignature(virCPUDataPtr cpuData, unsigned int family, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 212adf53c1..132ee3cae9 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1238,7 +1238,7 @@ virCPUValidateFeatures; =20 =20 # cpu/cpu_x86.h -virCPUx86DataAddCPUID; +virCPUx86DataAdd; virCPUx86DataAddFeature; virCPUx86DataGetSignature; virCPUx86DataSetSignature; diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index c19d05326d..7ab556af3c 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -72,7 +72,7 @@ libxlCapsAddCPUID(virCPUDataPtr data, virCPUx86CPUID *cpu= id, ssize_t ncaps) for (i =3D 0; i < ncaps; i++) { item.cpuid =3D cpuid[i]; =20 - if (virCPUx86DataAddCPUID(data, &item) < 0) { + if (virCPUx86DataAdd(data, &item) < 0) { VIR_DEBUG("Failed to add CPUID(%x,%x)", cpuid[i].eax_in, cpuid[i].ecx_in); return -1; diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index bee1b33f2a..a9ba6cf4f6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7195,7 +7195,7 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr da= ta) for (i =3D 0; i < virJSONValueArraySize(data); i++) { if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(dat= a, i), &item.cpuid) < 0 || - virCPUx86DataAddCPUID(cpudata, &item) < 0) + virCPUx86DataAdd(cpudata, &item) < 0) goto error; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713006205404.90156110128487; Mon, 8 Apr 2019 01:43:26 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 99D7C3092678; Mon, 8 Apr 2019 08:43:24 +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 678A95C297; Mon, 8 Apr 2019 08:43:24 +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 214793D86; Mon, 8 Apr 2019 08:43:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gwlB009154 for ; Mon, 8 Apr 2019 04:42:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3D2EC1091EF6; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F4891091EEC for ; Mon, 8 Apr 2019 08:42:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D3AFC103647; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:18 +0200 Message-Id: <22973ab7e681d2ff10f3247669a090ecde9c63c2.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 14/36] cpu_x86: Rename virCPUx86VendorToCPUID 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 08 Apr 2019 08:43:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Renamed as virCPUx86VendorToData. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 492839496e..121c88ad43 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -527,8 +527,8 @@ x86DataToVendor(const virCPUx86Data *data, =20 =20 static int -virCPUx86VendorToCPUID(const char *vendor, - virCPUx86DataItemPtr data) +virCPUx86VendorToData(const char *vendor, + virCPUx86DataItemPtr data) { virCPUx86CPUIDPtr cpuid =3D &data->cpuid; =20 @@ -760,7 +760,7 @@ x86VendorParse(xmlXPathContextPtr ctxt, goto cleanup; } =20 - if (virCPUx86VendorToCPUID(string, &vendor->data) < 0) + if (virCPUx86VendorToData(string, &vendor->data) < 0) goto cleanup; =20 if (VIR_APPEND_ELEMENT(map->vendors, map->nvendors, vendor) < 0) @@ -3115,7 +3115,7 @@ virCPUx86DataSetVendor(virCPUDataPtr cpuData, { virCPUx86DataItem item =3D CPUID(0); =20 - if (virCPUx86VendorToCPUID(vendor, &item) < 0) + if (virCPUx86VendorToData(vendor, &item) < 0) return -1; =20 return virCPUx86DataAdd(cpuData, &item); --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712990215490.88856277791615; Mon, 8 Apr 2019 01:43:10 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 581377E437; Mon, 8 Apr 2019 08:43:08 +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 2BDB25D71F; Mon, 8 Apr 2019 08:43:08 +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 D6C3A3FAF4; Mon, 8 Apr 2019 08:43:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gwGP009153 for ; Mon, 8 Apr 2019 04:42:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A5401092002; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0F4DA1091EF6 for ; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id D91A8103648; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:19 +0200 Message-Id: <9425d9f13b2d03c5e84b8b4c11e018d69dfc8df7.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 15/36] cpu_x86: Simplify x86DataAdd 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 08 Apr 2019 08:43:08 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The while loop just copied half of virCPUx86DataAddItem. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 121c88ad43..41067617df 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -405,18 +405,11 @@ x86DataAdd(virCPUx86Data *data1, const virCPUx86Data *data2) { virCPUx86DataIterator iter =3D virCPUx86DataIteratorInit(data2); - virCPUx86DataItemPtr item1; - virCPUx86DataItemPtr item2; + virCPUx86DataItemPtr item; =20 - while ((item2 =3D virCPUx86DataNext(&iter))) { - item1 =3D virCPUx86DataGet(data1, item2); - - if (item1) { - x86cpuidSetBits(&item1->cpuid, &item2->cpuid); - } else { - if (virCPUx86DataAddItem(data1, item2) < 0) - return -1; - } + while ((item =3D virCPUx86DataNext(&iter))) { + if (virCPUx86DataAddItem(data1, item) < 0) + return -1; } =20 return 0; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712993890630.0241196919604; Mon, 8 Apr 2019 01:43:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1088E301899D; Mon, 8 Apr 2019 08:43:12 +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 DC46C648CB; Mon, 8 Apr 2019 08:43:11 +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 93F50181AC45; Mon, 8 Apr 2019 08:43:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gvcc009096 for ; Mon, 8 Apr 2019 04:42:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5760B66090; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C843648CB for ; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id DE7A5103649; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:20 +0200 Message-Id: <6ae869bfbdd7f31409ce5260211a5e7982f78824.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 16/36] cpu_x86: Introduce virCPUx86DataCmp 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 08 Apr 2019 08:43:12 +0000 (UTC) Content-Type: text/plain; charset="utf-8" virCPUx86DataSorter already compares two virCPUx86DataItem structs. Let's add a tiny wrapper around it called virCPUx86DataCmp and use it instead of open coded comparisons. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 41067617df..74d157d780 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -306,6 +306,13 @@ virCPUx86DataSorter(const void *a, const void *b) return 0; } =20 +static int +virCPUx86DataItemCmp(const virCPUx86DataItem *item1, + const virCPUx86DataItem *item2) +{ + return virCPUx86DataSorter(item1, item2); +} + =20 /* skips all zero CPUID leaves */ static virCPUx86DataItemPtr @@ -334,9 +341,9 @@ virCPUx86DataGet(const virCPUx86Data *data, size_t i; =20 for (i =3D 0; i < data->len; i++) { - if (data->items[i].cpuid.eax_in =3D=3D item->cpuid.eax_in && - data->items[i].cpuid.ecx_in =3D=3D item->cpuid.ecx_in) - return data->items + i; + virCPUx86DataItemPtr di =3D data->items + i; + if (virCPUx86DataItemCmp(di, item) =3D=3D 0) + return di; } =20 return NULL; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713021468193.43148970181005; Mon, 8 Apr 2019 01:43:41 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B102088AA6; Mon, 8 Apr 2019 08:43:39 +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 819D35D717; Mon, 8 Apr 2019 08:43:39 +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 429D8181BA1C; Mon, 8 Apr 2019 08:43:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxpa009204 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9DFA21A267; 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 71D3B1949C for ; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id E3E5A10364D; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:21 +0200 Message-Id: <85528c7c7a1ff4b3521f57509cb5105737c52c4a.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 17/36] cpu_x86: Make x86cpuidSetBits more general 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.15 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:40 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function is renamed as virCPUx86DataItemSetBits and it works on virCPUx86DataItem now. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 74d157d780..f713f02929 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -216,16 +216,16 @@ x86cpuidMatchMasked(const virCPUx86CPUID *cpuid, =20 =20 static void -x86cpuidSetBits(virCPUx86CPUID *cpuid, - const virCPUx86CPUID *mask) +virCPUx86DataItemSetBits(virCPUx86DataItemPtr item, + const virCPUx86DataItem *mask) { if (!mask) return; =20 - cpuid->eax |=3D mask->eax; - cpuid->ebx |=3D mask->ebx; - cpuid->ecx |=3D mask->ecx; - cpuid->edx |=3D mask->edx; + item->cpuid.eax |=3D mask->cpuid.eax; + item->cpuid.ebx |=3D mask->cpuid.ebx; + item->cpuid.ecx |=3D mask->cpuid.ecx; + item->cpuid.edx |=3D mask->cpuid.edx; } =20 =20 @@ -393,7 +393,7 @@ virCPUx86DataAddItem(virCPUx86Data *data, virCPUx86DataItemPtr existing; =20 if ((existing =3D virCPUx86DataGet(data, item))) { - x86cpuidSetBits(&existing->cpuid, &item->cpuid); + virCPUx86DataItemSetBits(existing, item); } else { if (VIR_APPEND_ELEMENT_COPY(data->items, data->len, *((virCPUx86DataItemPtr)item)) < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712997972261.9922586100747; Mon, 8 Apr 2019 01:43:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EEB3A89C46; Mon, 8 Apr 2019 08:43:15 +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 CBC9E60F88; Mon, 8 Apr 2019 08:43:15 +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 81E153FA4E; Mon, 8 Apr 2019 08:43:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gvLi009103 for ; Mon, 8 Apr 2019 04:42:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 73D035DA2C; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 452C25DA24 for ; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id E967310366A; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:22 +0200 Message-Id: <345d1d121f6b6c349e4cf11e962536d11db3cb1d.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 18/36] cpu_x86: Make x86cpuidClearBits more general 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 08 Apr 2019 08:43:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The parameters changed from virCPUx86CPUID to virCPUx86DataItem and the function is now called virCPUx86DataItemClearBits. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index f713f02929..dcdd0b60b0 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -230,16 +230,16 @@ virCPUx86DataItemSetBits(virCPUx86DataItemPtr item, =20 =20 static void -x86cpuidClearBits(virCPUx86CPUID *cpuid, - const virCPUx86CPUID *mask) +virCPUx86DataItemClearBits(virCPUx86DataItemPtr item, + const virCPUx86DataItem *mask) { if (!mask) return; =20 - cpuid->eax &=3D ~mask->eax; - cpuid->ebx &=3D ~mask->ebx; - cpuid->ecx &=3D ~mask->ecx; - cpuid->edx &=3D ~mask->edx; + item->cpuid.eax &=3D ~mask->cpuid.eax; + item->cpuid.ebx &=3D ~mask->cpuid.ebx; + item->cpuid.ecx &=3D ~mask->cpuid.ecx; + item->cpuid.edx &=3D ~mask->cpuid.edx; } =20 =20 @@ -432,8 +432,8 @@ x86DataSubtract(virCPUx86Data *data1, virCPUx86DataItemPtr item2; =20 while ((item1 =3D virCPUx86DataNext(&iter))) { - if ((item2 =3D virCPUx86DataGet(data2, item1))) - x86cpuidClearBits(&item1->cpuid, &item2->cpuid); + item2 =3D virCPUx86DataGet(data2, item1); + virCPUx86DataItemClearBits(item1, item2); } } =20 @@ -451,7 +451,7 @@ x86DataIntersect(virCPUx86Data *data1, if (item2) x86cpuidAndBits(&item1->cpuid, &item2->cpuid); else - x86cpuidClearBits(&item1->cpuid, &item1->cpuid); + virCPUx86DataItemClearBits(item1, item1); } } =20 @@ -517,7 +517,7 @@ x86DataToVendor(const virCPUx86Data *data, virCPUx86VendorPtr vendor =3D map->vendors[i]; if ((item =3D virCPUx86DataGet(data, &vendor->data)) && x86cpuidMatchMasked(&item->cpuid, &vendor->data.cpuid)) { - x86cpuidClearBits(&item->cpuid, &vendor->data.cpuid); + virCPUx86DataItemClearBits(item, &vendor->data); return vendor; } } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712987259562.6439279918935; Mon, 8 Apr 2019 01:43:07 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 73723308402A; Mon, 8 Apr 2019 08:43:05 +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 462721092002; Mon, 8 Apr 2019 08:43:05 +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 06E99181B9E8; Mon, 8 Apr 2019 08:43:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gvwO009111 for ; Mon, 8 Apr 2019 04:42:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id BBD0D18033; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F9465C297 for ; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id EECC110366B; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:23 +0200 Message-Id: <50e75b9ca7879b04fb6eddee1433b2e77da14bca.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 19/36] cpu_x86: Make x86cpuidAndBits more general 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 08 Apr 2019 08:43:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function now works on virCPUx86DataItem and it's renamed as virCPUx86DataItemAndBits. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index dcdd0b60b0..57bdffc3af 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -244,16 +244,16 @@ virCPUx86DataItemClearBits(virCPUx86DataItemPtr item, =20 =20 static void -x86cpuidAndBits(virCPUx86CPUID *cpuid, - const virCPUx86CPUID *mask) +virCPUx86DataItemAndBits(virCPUx86DataItemPtr item, + const virCPUx86DataItem *mask) { if (!mask) return; =20 - cpuid->eax &=3D mask->eax; - cpuid->ebx &=3D mask->ebx; - cpuid->ecx &=3D mask->ecx; - cpuid->edx &=3D mask->edx; + item->cpuid.eax &=3D mask->cpuid.eax; + item->cpuid.ebx &=3D mask->cpuid.ebx; + item->cpuid.ecx &=3D mask->cpuid.ecx; + item->cpuid.edx &=3D mask->cpuid.edx; } =20 =20 @@ -449,7 +449,7 @@ x86DataIntersect(virCPUx86Data *data1, while ((item1 =3D virCPUx86DataNext(&iter))) { item2 =3D virCPUx86DataGet(data2, item1); if (item2) - x86cpuidAndBits(&item1->cpuid, &item2->cpuid); + virCPUx86DataItemAndBits(item1, item2); else virCPUx86DataItemClearBits(item1, item1); } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 155471298611632.96277097261691; Mon, 8 Apr 2019 01:43:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6FD8B81113; Mon, 8 Apr 2019 08:43:04 +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 4608E665CA; Mon, 8 Apr 2019 08:43:04 +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 F0134181AC92; Mon, 8 Apr 2019 08:43:03 +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 x388gvN6009114 for ; Mon, 8 Apr 2019 04:42:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id C16ED5D71C; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 96C675D71F for ; Mon, 8 Apr 2019 08:42:57 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 000F110366C; Mon, 8 Apr 2019 10:42:50 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:24 +0200 Message-Id: <1e7c7ceb088b211961e53c7cc978d68e484f12d5.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 20/36] cpu_x86: Make x86cpuidMatchMasked more general 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 08 Apr 2019 08:43:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function is renamed as virCPUx86DataItemMatchMasked to reflect the change in parameter types. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 57bdffc3af..b88cd83aed 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -205,13 +205,13 @@ x86cpuidMatch(const virCPUx86CPUID *cpuid1, =20 =20 static bool -x86cpuidMatchMasked(const virCPUx86CPUID *cpuid, - const virCPUx86CPUID *mask) +virCPUx86DataItemMatchMasked(const virCPUx86DataItem *item, + const virCPUx86DataItem *mask) { - return ((cpuid->eax & mask->eax) =3D=3D mask->eax && - (cpuid->ebx & mask->ebx) =3D=3D mask->ebx && - (cpuid->ecx & mask->ecx) =3D=3D mask->ecx && - (cpuid->edx & mask->edx) =3D=3D mask->edx); + return ((item->cpuid.eax & mask->cpuid.eax) =3D=3D mask->cpuid.eax && + (item->cpuid.ebx & mask->cpuid.ebx) =3D=3D mask->cpuid.ebx && + (item->cpuid.ecx & mask->cpuid.ecx) =3D=3D mask->cpuid.ecx && + (item->cpuid.edx & mask->cpuid.edx) =3D=3D mask->cpuid.edx); } =20 =20 @@ -475,7 +475,7 @@ x86DataIsSubset(const virCPUx86Data *data, =20 while ((itemSubset =3D virCPUx86DataNext(&iter))) { if (!(item =3D virCPUx86DataGet(data, itemSubset)) || - !x86cpuidMatchMasked(&item->cpuid, &itemSubset->cpuid)) + !virCPUx86DataItemMatchMasked(item, itemSubset)) return false; } =20 @@ -516,7 +516,7 @@ x86DataToVendor(const virCPUx86Data *data, for (i =3D 0; i < map->nvendors; i++) { virCPUx86VendorPtr vendor =3D map->vendors[i]; if ((item =3D virCPUx86DataGet(data, &vendor->data)) && - x86cpuidMatchMasked(&item->cpuid, &vendor->data.cpuid)) { + virCPUx86DataItemMatchMasked(item, &vendor->data)) { virCPUx86DataItemClearBits(item, &vendor->data); return vendor; } @@ -1158,7 +1158,7 @@ x86ModelCompare(virCPUx86ModelPtr model1, if ((item2 =3D virCPUx86DataGet(&model2->data, item1))) { if (x86cpuidMatch(&item1->cpuid, &item2->cpuid)) continue; - else if (!x86cpuidMatchMasked(&item1->cpuid, &item2->cpuid)) + else if (!virCPUx86DataItemMatchMasked(item1, item2)) match =3D SUBSET; } =20 @@ -1174,7 +1174,7 @@ x86ModelCompare(virCPUx86ModelPtr model1, if ((item1 =3D virCPUx86DataGet(&model1->data, item2))) { if (x86cpuidMatch(&item2->cpuid, &item1->cpuid)) continue; - else if (!x86cpuidMatchMasked(&item2->cpuid, &item1->cpuid)) + else if (!virCPUx86DataItemMatchMasked(item2, item1)) match =3D SUPERSET; } =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713010440283.4828600681758; Mon, 8 Apr 2019 01:43:30 -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 C81F33087BD6; Mon, 8 Apr 2019 08:43:28 +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 9CFE4600D4; Mon, 8 Apr 2019 08:43:28 +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 54450181BA0A; Mon, 8 Apr 2019 08:43:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gwLC009163 for ; Mon, 8 Apr 2019 04:42:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id D58C4109B79D; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AA95A1092002 for ; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 057D810366D; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:25 +0200 Message-Id: <048d1abf04f5ce18f01467cfdddd399b74cec839.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 21/36] cpu_x86: Make x86cpuidMatch more general 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.45]); Mon, 08 Apr 2019 08:43:29 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function now works on virtCPUx86DataItem and it's called virCPUx86DataItemMatch. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index b88cd83aed..62a7914160 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -37,8 +37,6 @@ VIR_LOG_INIT("cpu.cpu_x86"); =20 #define VENDOR_STRING_LENGTH 12 =20 -static const virCPUx86CPUID cpuidNull =3D { 0 }; - static const virArch archs[] =3D { VIR_ARCH_I686, VIR_ARCH_X86_64 }; =20 typedef struct _virCPUx86Vendor virCPUx86Vendor; @@ -194,13 +192,13 @@ struct _virCPUx86DataIterator { =20 =20 static bool -x86cpuidMatch(const virCPUx86CPUID *cpuid1, - const virCPUx86CPUID *cpuid2) +virCPUx86DataItemMatch(const virCPUx86DataItem *item1, + const virCPUx86DataItem *item2) { - return (cpuid1->eax =3D=3D cpuid2->eax && - cpuid1->ebx =3D=3D cpuid2->ebx && - cpuid1->ecx =3D=3D cpuid2->ecx && - cpuid1->edx =3D=3D cpuid2->edx); + return (item1->cpuid.eax =3D=3D item2->cpuid.eax && + item1->cpuid.ebx =3D=3D item2->cpuid.ebx && + item1->cpuid.ecx =3D=3D item2->cpuid.ecx && + item1->cpuid.edx =3D=3D item2->cpuid.edx); } =20 =20 @@ -319,6 +317,7 @@ static virCPUx86DataItemPtr virCPUx86DataNext(virCPUx86DataIteratorPtr iterator) { const virCPUx86Data *data =3D iterator->data; + virCPUx86DataItem zero =3D { 0 }; =20 if (!data) return NULL; @@ -326,7 +325,7 @@ virCPUx86DataNext(virCPUx86DataIteratorPtr iterator) while (++iterator->pos < data->len) { virCPUx86DataItemPtr item =3D data->items + iterator->pos; =20 - if (!x86cpuidMatch(&item->cpuid, &cpuidNull)) + if (!virCPUx86DataItemMatch(item, &zero)) return item; } =20 @@ -1156,7 +1155,7 @@ x86ModelCompare(virCPUx86ModelPtr model1, virCPUx86CompareResult match =3D SUPERSET; =20 if ((item2 =3D virCPUx86DataGet(&model2->data, item1))) { - if (x86cpuidMatch(&item1->cpuid, &item2->cpuid)) + if (virCPUx86DataItemMatch(item1, item2)) continue; else if (!virCPUx86DataItemMatchMasked(item1, item2)) match =3D SUBSET; @@ -1172,7 +1171,7 @@ x86ModelCompare(virCPUx86ModelPtr model1, virCPUx86CompareResult match =3D SUBSET; =20 if ((item1 =3D virCPUx86DataGet(&model1->data, item2))) { - if (x86cpuidMatch(&item2->cpuid, &item1->cpuid)) + if (virCPUx86DataItemMatch(item2, item1)) continue; else if (!virCPUx86DataItemMatchMasked(item2, item1)) match =3D SUPERSET; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713014809500.27939117704886; Mon, 8 Apr 2019 01:43:34 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6EE9BED265; Mon, 8 Apr 2019 08:43:32 +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 425AB5D71E; Mon, 8 Apr 2019 08:43:32 +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 EDD623FAF6; Mon, 8 Apr 2019 08:43:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxjv009168 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2D56E6608B; 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 A9EE3665C7 for ; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 0BB2E10366E; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:26 +0200 Message-Id: <80f359e1fee7d6f6a8932f0c85e477fd12b09bb4.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 22/36] cpu_x86: Store virCPUx86DataItem content in union 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 08 Apr 2019 08:43:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The structure can only be used for CPUID data now. Adding a type indicator and moving the data into a union will let us store alternative data types. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 202 ++++++++++++++++++++++++--------- src/cpu/cpu_x86_data.h | 10 +- src/libxl/libxl_capabilities.c | 3 +- src/qemu/qemu_monitor_json.c | 3 +- 4 files changed, 160 insertions(+), 58 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 62a7914160..192e067d38 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -55,7 +55,9 @@ struct _virCPUx86Feature { }; =20 =20 -#define CPUID(...) { .cpuid =3D {__VA_ARGS__} } +#define CPUID(...) \ + { .type =3D VIR_CPU_X86_DATA_CPUID, \ + .data =3D { .cpuid =3D {__VA_ARGS__} } } =20 #define KVM_FEATURE_DEF(Name, Eax_in, Eax) \ static virCPUx86DataItem Name ## _data[] =3D { \ @@ -195,10 +197,22 @@ static bool virCPUx86DataItemMatch(const virCPUx86DataItem *item1, const virCPUx86DataItem *item2) { - return (item1->cpuid.eax =3D=3D item2->cpuid.eax && - item1->cpuid.ebx =3D=3D item2->cpuid.ebx && - item1->cpuid.ecx =3D=3D item2->cpuid.ecx && - item1->cpuid.edx =3D=3D item2->cpuid.edx); + const virCPUx86CPUID *cpuid1; + const virCPUx86CPUID *cpuid2; + + switch (item1->type) { + case VIR_CPU_X86_DATA_CPUID: + cpuid1 =3D &item1->data.cpuid; + cpuid2 =3D &item2->data.cpuid; + return (cpuid1->eax =3D=3D cpuid2->eax && + cpuid1->ebx =3D=3D cpuid2->ebx && + cpuid1->ecx =3D=3D cpuid2->ecx && + cpuid1->edx =3D=3D cpuid2->edx); + + case VIR_CPU_X86_DATA_NONE: + default: + return false; + } } =20 =20 @@ -206,10 +220,22 @@ static bool virCPUx86DataItemMatchMasked(const virCPUx86DataItem *item, const virCPUx86DataItem *mask) { - return ((item->cpuid.eax & mask->cpuid.eax) =3D=3D mask->cpuid.eax && - (item->cpuid.ebx & mask->cpuid.ebx) =3D=3D mask->cpuid.ebx && - (item->cpuid.ecx & mask->cpuid.ecx) =3D=3D mask->cpuid.ecx && - (item->cpuid.edx & mask->cpuid.edx) =3D=3D mask->cpuid.edx); + const virCPUx86CPUID *cpuid; + const virCPUx86CPUID *cpuidMask; + + switch (item->type) { + case VIR_CPU_X86_DATA_CPUID: + cpuid =3D &item->data.cpuid; + cpuidMask =3D &mask->data.cpuid; + return ((cpuid->eax & cpuidMask->eax) =3D=3D cpuidMask->eax && + (cpuid->ebx & cpuidMask->ebx) =3D=3D cpuidMask->ebx && + (cpuid->ecx & cpuidMask->ecx) =3D=3D cpuidMask->ecx && + (cpuid->edx & cpuidMask->edx) =3D=3D cpuidMask->edx); + + case VIR_CPU_X86_DATA_NONE: + default: + return false; + } } =20 =20 @@ -217,13 +243,26 @@ static void virCPUx86DataItemSetBits(virCPUx86DataItemPtr item, const virCPUx86DataItem *mask) { + virCPUx86CPUIDPtr cpuid; + const virCPUx86CPUID *cpuidMask; + if (!mask) return; =20 - item->cpuid.eax |=3D mask->cpuid.eax; - item->cpuid.ebx |=3D mask->cpuid.ebx; - item->cpuid.ecx |=3D mask->cpuid.ecx; - item->cpuid.edx |=3D mask->cpuid.edx; + switch (item->type) { + case VIR_CPU_X86_DATA_CPUID: + cpuid =3D &item->data.cpuid; + cpuidMask =3D &mask->data.cpuid; + cpuid->eax |=3D cpuidMask->eax; + cpuid->ebx |=3D cpuidMask->ebx; + cpuid->ecx |=3D cpuidMask->ecx; + cpuid->edx |=3D cpuidMask->edx; + break; + + case VIR_CPU_X86_DATA_NONE: + default: + break; + } } =20 =20 @@ -231,13 +270,26 @@ static void virCPUx86DataItemClearBits(virCPUx86DataItemPtr item, const virCPUx86DataItem *mask) { + virCPUx86CPUIDPtr cpuid; + const virCPUx86CPUID *cpuidMask; + if (!mask) return; =20 - item->cpuid.eax &=3D ~mask->cpuid.eax; - item->cpuid.ebx &=3D ~mask->cpuid.ebx; - item->cpuid.ecx &=3D ~mask->cpuid.ecx; - item->cpuid.edx &=3D ~mask->cpuid.edx; + switch (item->type) { + case VIR_CPU_X86_DATA_CPUID: + cpuid =3D &item->data.cpuid; + cpuidMask =3D &mask->data.cpuid; + cpuid->eax &=3D ~cpuidMask->eax; + cpuid->ebx &=3D ~cpuidMask->ebx; + cpuid->ecx &=3D ~cpuidMask->ecx; + cpuid->edx &=3D ~cpuidMask->edx; + break; + + case VIR_CPU_X86_DATA_NONE: + default: + break; + } } =20 =20 @@ -245,13 +297,26 @@ static void virCPUx86DataItemAndBits(virCPUx86DataItemPtr item, const virCPUx86DataItem *mask) { + virCPUx86CPUIDPtr cpuid; + const virCPUx86CPUID *cpuidMask; + if (!mask) return; =20 - item->cpuid.eax &=3D mask->cpuid.eax; - item->cpuid.ebx &=3D mask->cpuid.ebx; - item->cpuid.ecx &=3D mask->cpuid.ecx; - item->cpuid.edx &=3D mask->cpuid.edx; + switch (item->type) { + case VIR_CPU_X86_DATA_CPUID: + cpuid =3D &item->data.cpuid; + cpuidMask =3D &mask->data.cpuid; + cpuid->eax &=3D cpuidMask->eax; + cpuid->ebx &=3D cpuidMask->ebx; + cpuid->ecx &=3D cpuidMask->ecx; + cpuid->edx &=3D cpuidMask->edx; + break; + + case VIR_CPU_X86_DATA_NONE: + default: + break; + } } =20 =20 @@ -291,15 +356,29 @@ virCPUx86DataSorter(const void *a, const void *b) virCPUx86DataItemPtr da =3D (virCPUx86DataItemPtr) a; virCPUx86DataItemPtr db =3D (virCPUx86DataItemPtr) b; =20 - if (da->cpuid.eax_in > db->cpuid.eax_in) + if (da->type > db->type) return 1; - else if (da->cpuid.eax_in < db->cpuid.eax_in) + else if (da->type < db->type) return -1; =20 - if (da->cpuid.ecx_in > db->cpuid.ecx_in) - return 1; - else if (da->cpuid.ecx_in < db->cpuid.ecx_in) - return -1; + switch (da->type) { + case VIR_CPU_X86_DATA_CPUID: + if (da->data.cpuid.eax_in > db->data.cpuid.eax_in) + return 1; + else if (da->data.cpuid.eax_in < db->data.cpuid.eax_in) + return -1; + + if (da->data.cpuid.ecx_in > db->data.cpuid.ecx_in) + return 1; + else if (da->data.cpuid.ecx_in < db->data.cpuid.ecx_in) + return -1; + + break; + + case VIR_CPU_X86_DATA_NONE: + default: + break; + } =20 return 0; } @@ -527,9 +606,9 @@ x86DataToVendor(const virCPUx86Data *data, =20 static int virCPUx86VendorToData(const char *vendor, - virCPUx86DataItemPtr data) + virCPUx86DataItemPtr item) { - virCPUx86CPUIDPtr cpuid =3D &data->cpuid; + virCPUx86CPUIDPtr cpuid; =20 if (strlen(vendor) !=3D VENDOR_STRING_LENGTH) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -537,6 +616,8 @@ virCPUx86VendorToData(const char *vendor, return -1; } =20 + item->type =3D VIR_CPU_X86_DATA_CPUID; + cpuid =3D &item->data.cpuid; cpuid->eax_in =3D 0; cpuid->ecx_in =3D 0; cpuid->ebx =3D virReadBufInt32LE(vendor); @@ -612,7 +693,7 @@ x86DataToSignatureFull(const virCPUx86Data *data, if (!(item =3D virCPUx86DataGet(data, &leaf1))) return; =20 - cpuid =3D &item->cpuid; + cpuid =3D &item->data.cpuid; *family =3D ((cpuid->eax >> 20) & 0xff) + ((cpuid->eax >> 8) & 0xf); *model =3D ((cpuid->eax >> 12) & 0xf0) + ((cpuid->eax >> 4) & 0xf); *stepping =3D cpuid->eax & 0xf; @@ -631,7 +712,7 @@ x86DataToSignature(const virCPUx86Data *data) if (!(item =3D virCPUx86DataGet(data, &leaf1))) return 0; =20 - return item->cpuid.eax & SIGNATURE_MASK; + return item->data.cpuid.eax & SIGNATURE_MASK; } =20 =20 @@ -886,7 +967,8 @@ x86ParseCPUID(xmlXPathContextPtr ctxt, ret_eax =3D=3D -2 || ret_ebx =3D=3D -2 || ret_ecx =3D=3D -2 || ret= _edx =3D=3D -2) return -1; =20 - cpuid =3D &item->cpuid; + item->type =3D VIR_CPU_X86_DATA_CPUID; + cpuid =3D &item->data.cpuid; cpuid->eax_in =3D eax_in; cpuid->ecx_in =3D ecx_in; cpuid->eax =3D eax; @@ -1462,13 +1544,23 @@ virCPUx86DataFormat(const virCPUData *data) =20 virBufferAddLit(&buf, "\n"); while ((item =3D virCPUx86DataNext(&iter))) { - virCPUx86CPUIDPtr cpuid =3D &item->cpuid; - virBufferAsprintf(&buf, - " \n", - cpuid->eax_in, cpuid->ecx_in, - cpuid->eax, cpuid->ebx, cpuid->ecx, cpuid->edx); + virCPUx86CPUIDPtr cpuid; + + switch (item->type) { + case VIR_CPU_X86_DATA_CPUID: + cpuid =3D &item->data.cpuid; + virBufferAsprintf(&buf, + " \n", + cpuid->eax_in, cpuid->ecx_in, + cpuid->eax, cpuid->ebx, cpuid->ecx, cpuid->e= dx); + break; + + case VIR_CPU_X86_DATA_NONE: + default: + break; + } } virBufferAddLit(&buf, "\n"); =20 @@ -2227,7 +2319,7 @@ cpuidSetLeaf4(virCPUDataPtr data, virCPUx86DataItemPtr subLeaf0) { virCPUx86DataItem item =3D *subLeaf0; - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; =20 if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; @@ -2251,13 +2343,13 @@ cpuidSetLeaf7(virCPUDataPtr data, virCPUx86DataItemPtr subLeaf0) { virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x7); - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; uint32_t sub; =20 if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 - for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { + for (sub =3D 1; sub <=3D subLeaf0->data.cpuid.eax; sub++) { cpuid->ecx_in =3D sub; cpuidCall(cpuid); if (virCPUx86DataAdd(data, &item) < 0) @@ -2279,7 +2371,7 @@ cpuidSetLeafB(virCPUDataPtr data, virCPUx86DataItemPtr subLeaf0) { virCPUx86DataItem item =3D *subLeaf0; - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; =20 while (cpuid->ecx & 0xff00) { if (virCPUx86DataAdd(data, &item) < 0) @@ -2304,7 +2396,7 @@ cpuidSetLeafD(virCPUDataPtr data, virCPUx86DataItemPtr subLeaf0) { virCPUx86DataItem item =3D CPUID(.eax_in =3D 0xd); - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; virCPUx86CPUID sub0; virCPUx86CPUID sub1; uint32_t sub; @@ -2317,7 +2409,7 @@ cpuidSetLeafD(virCPUDataPtr data, if (virCPUx86DataAdd(data, &item) < 0) return -1; =20 - sub0 =3D subLeaf0->cpuid; + sub0 =3D subLeaf0->data.cpuid; sub1 =3D *cpuid; for (sub =3D 2; sub < 64; sub++) { if (sub < 32 && @@ -2352,8 +2444,8 @@ cpuidSetLeafResID(virCPUDataPtr data, virCPUx86DataItemPtr subLeaf0, uint32_t res) { - virCPUx86DataItem item =3D CPUID(.eax_in =3D subLeaf0->cpuid.eax_in); - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86DataItem item =3D CPUID(.eax_in =3D subLeaf0->data.cpuid.eax_= in); + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; uint32_t sub; =20 if (virCPUx86DataAdd(data, subLeaf0) < 0) @@ -2381,11 +2473,11 @@ cpuidSetLeaf12(virCPUDataPtr data, virCPUx86DataItemPtr subLeaf0) { virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x7); - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; virCPUx86DataItemPtr leaf7; =20 if (!(leaf7 =3D virCPUx86DataGet(&data->data.x86, &item)) || - !(leaf7->cpuid.ebx & (1 << 2))) + !(leaf7->data.cpuid.ebx & (1 << 2))) return 0; =20 if (virCPUx86DataAdd(data, subLeaf0) < 0) @@ -2418,13 +2510,13 @@ cpuidSetLeaf14(virCPUDataPtr data, virCPUx86DataItemPtr subLeaf0) { virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x14); - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; uint32_t sub; =20 if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 - for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { + for (sub =3D 1; sub <=3D subLeaf0->data.cpuid.eax; sub++) { cpuid->ecx_in =3D sub; cpuidCall(cpuid); if (virCPUx86DataAdd(data, &item) < 0) @@ -2444,16 +2536,16 @@ cpuidSetLeaf17(virCPUDataPtr data, virCPUx86DataItemPtr subLeaf0) { virCPUx86DataItem item =3D CPUID(.eax_in =3D 0x17); - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; uint32_t sub; =20 - if (subLeaf0->cpuid.eax < 3) + if (subLeaf0->data.cpuid.eax < 3) return 0; =20 if (virCPUx86DataAdd(data, subLeaf0) < 0) return -1; =20 - for (sub =3D 1; sub <=3D subLeaf0->cpuid.eax; sub++) { + for (sub =3D 1; sub <=3D subLeaf0->data.cpuid.eax; sub++) { cpuid->ecx_in =3D sub; cpuidCall(cpuid); if (virCPUx86DataAdd(data, &item) < 0) @@ -2470,7 +2562,7 @@ cpuidSet(uint32_t base, virCPUDataPtr data) uint32_t max; uint32_t leaf; virCPUx86DataItem item =3D CPUID(.eax_in =3D base); - virCPUx86CPUIDPtr cpuid =3D &item.cpuid; + virCPUx86CPUIDPtr cpuid =3D &item.data.cpuid; =20 cpuidCall(cpuid); max =3D cpuid->eax; diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index 0e63dd9245..b16860b201 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -69,10 +69,18 @@ struct _virCPUx86CPUID { =20 # define VIR_CPU_X86_DATA_INIT { 0 } =20 +typedef enum { + VIR_CPU_X86_DATA_NONE =3D 0, + VIR_CPU_X86_DATA_CPUID, +} virCPUx86DataType; + typedef struct _virCPUx86DataItem virCPUx86DataItem; typedef virCPUx86DataItem *virCPUx86DataItemPtr; struct _virCPUx86DataItem { - virCPUx86CPUID cpuid; + virCPUx86DataType type; + union { + virCPUx86CPUID cpuid; + } data; }; =20 typedef struct _virCPUx86Data virCPUx86Data; diff --git a/src/libxl/libxl_capabilities.c b/src/libxl/libxl_capabilities.c index 7ab556af3c..73ae0b3fa1 100644 --- a/src/libxl/libxl_capabilities.c +++ b/src/libxl/libxl_capabilities.c @@ -69,8 +69,9 @@ libxlCapsAddCPUID(virCPUDataPtr data, virCPUx86CPUID *cpu= id, ssize_t ncaps) virCPUx86DataItem item =3D { 0 }; size_t i; =20 + item.type =3D VIR_CPU_X86_DATA_CPUID; for (i =3D 0; i < ncaps; i++) { - item.cpuid =3D cpuid[i]; + item.data.cpuid =3D cpuid[i]; =20 if (virCPUx86DataAdd(data, &item) < 0) { VIR_DEBUG("Failed to add CPUID(%x,%x)", diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index a9ba6cf4f6..bd2d65e804 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -7192,9 +7192,10 @@ qemuMonitorJSONParseCPUx86Features(virJSONValuePtr d= ata) if (!(cpudata =3D virCPUDataNew(VIR_ARCH_X86_64))) goto error; =20 + item.type =3D VIR_CPU_X86_DATA_CPUID; for (i =3D 0; i < virJSONValueArraySize(data); i++) { if (qemuMonitorJSONParseCPUx86FeatureWord(virJSONValueArrayGet(dat= a, i), - &item.cpuid) < 0 || + &item.data.cpuid) < 0 || virCPUx86DataAdd(cpudata, &item) < 0) goto error; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713031852841.3070229766432; Mon, 8 Apr 2019 01:43:51 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 07492267DB; Mon, 8 Apr 2019 08:43:50 +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 CC3316608B; Mon, 8 Apr 2019 08:43:49 +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 7BAA0181D0A0; Mon, 8 Apr 2019 08:43:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388h1bk009252 for ; Mon, 8 Apr 2019 04:43:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id A26E318033; Mon, 8 Apr 2019 08:43:01 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 46EAA5C297 for ; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 1167610366F; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:27 +0200 Message-Id: <69a7a005521134422d6d52bc42e35bb7b955f3ba.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 23/36] cpu_x86: Add support for storing MSR features in CPU map 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 08 Apr 2019 08:43:50 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 127 +++++++++++++++++++++++++++++---- src/cpu/cpu_x86_data.h | 10 +++ tests/cputestdata/cpu-cpuid.py | 3 +- 3 files changed, 127 insertions(+), 13 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 192e067d38..57837209b4 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -199,6 +199,8 @@ virCPUx86DataItemMatch(const virCPUx86DataItem *item1, { const virCPUx86CPUID *cpuid1; const virCPUx86CPUID *cpuid2; + const virCPUx86MSR *msr1; + const virCPUx86MSR *msr2; =20 switch (item1->type) { case VIR_CPU_X86_DATA_CPUID: @@ -209,6 +211,12 @@ virCPUx86DataItemMatch(const virCPUx86DataItem *item1, cpuid1->ecx =3D=3D cpuid2->ecx && cpuid1->edx =3D=3D cpuid2->edx); =20 + case VIR_CPU_X86_DATA_MSR: + msr1 =3D &item1->data.msr; + msr2 =3D &item2->data.msr; + return (msr1->eax =3D=3D msr2->eax && + msr1->edx =3D=3D msr2->edx); + case VIR_CPU_X86_DATA_NONE: default: return false; @@ -222,6 +230,8 @@ virCPUx86DataItemMatchMasked(const virCPUx86DataItem *i= tem, { const virCPUx86CPUID *cpuid; const virCPUx86CPUID *cpuidMask; + const virCPUx86MSR *msr; + const virCPUx86MSR *msrMask; =20 switch (item->type) { case VIR_CPU_X86_DATA_CPUID: @@ -232,6 +242,12 @@ virCPUx86DataItemMatchMasked(const virCPUx86DataItem *= item, (cpuid->ecx & cpuidMask->ecx) =3D=3D cpuidMask->ecx && (cpuid->edx & cpuidMask->edx) =3D=3D cpuidMask->edx); =20 + case VIR_CPU_X86_DATA_MSR: + msr =3D &item->data.msr; + msrMask =3D &mask->data.msr; + return ((msr->eax & msrMask->eax) =3D=3D msrMask->eax && + (msr->edx & msrMask->edx) =3D=3D msrMask->edx); + case VIR_CPU_X86_DATA_NONE: default: return false; @@ -245,6 +261,8 @@ virCPUx86DataItemSetBits(virCPUx86DataItemPtr item, { virCPUx86CPUIDPtr cpuid; const virCPUx86CPUID *cpuidMask; + virCPUx86MSRPtr msr; + const virCPUx86MSR *msrMask; =20 if (!mask) return; @@ -259,6 +277,13 @@ virCPUx86DataItemSetBits(virCPUx86DataItemPtr item, cpuid->edx |=3D cpuidMask->edx; break; =20 + case VIR_CPU_X86_DATA_MSR: + msr =3D &item->data.msr; + msrMask =3D &mask->data.msr; + msr->eax |=3D msrMask->eax; + msr->edx |=3D msrMask->edx; + break; + case VIR_CPU_X86_DATA_NONE: default: break; @@ -272,6 +297,8 @@ virCPUx86DataItemClearBits(virCPUx86DataItemPtr item, { virCPUx86CPUIDPtr cpuid; const virCPUx86CPUID *cpuidMask; + virCPUx86MSRPtr msr; + const virCPUx86MSR *msrMask; =20 if (!mask) return; @@ -286,6 +313,13 @@ virCPUx86DataItemClearBits(virCPUx86DataItemPtr item, cpuid->edx &=3D ~cpuidMask->edx; break; =20 + case VIR_CPU_X86_DATA_MSR: + msr =3D &item->data.msr; + msrMask =3D &mask->data.msr; + msr->eax &=3D ~msrMask->eax; + msr->edx &=3D ~msrMask->edx; + break; + case VIR_CPU_X86_DATA_NONE: default: break; @@ -299,6 +333,8 @@ virCPUx86DataItemAndBits(virCPUx86DataItemPtr item, { virCPUx86CPUIDPtr cpuid; const virCPUx86CPUID *cpuidMask; + virCPUx86MSRPtr msr; + const virCPUx86MSR *msrMask; =20 if (!mask) return; @@ -313,6 +349,13 @@ virCPUx86DataItemAndBits(virCPUx86DataItemPtr item, cpuid->edx &=3D cpuidMask->edx; break; =20 + case VIR_CPU_X86_DATA_MSR: + msr =3D &item->data.msr; + msrMask =3D &mask->data.msr; + msr->eax &=3D msrMask->eax; + msr->edx &=3D msrMask->edx; + break; + case VIR_CPU_X86_DATA_NONE: default: break; @@ -375,6 +418,14 @@ virCPUx86DataSorter(const void *a, const void *b) =20 break; =20 + case VIR_CPU_X86_DATA_MSR: + if (da->data.msr.index > db->data.msr.index) + return 1; + else if (da->data.msr.index < db->data.msr.index) + return -1; + + break; + case VIR_CPU_X86_DATA_NONE: default: break; @@ -979,6 +1030,31 @@ x86ParseCPUID(xmlXPathContextPtr ctxt, } =20 =20 +static int +x86ParseMSR(xmlXPathContextPtr ctxt, + virCPUx86DataItemPtr item) +{ + virCPUx86MSRPtr msr; + unsigned long index; + unsigned long eax; + unsigned long edx; + + memset(item, 0, sizeof(*item)); + + if (virXPathULongHex("string(@index)", ctxt, &index) < 0 || + virXPathULongHex("string(@eax)", ctxt, &eax) < 0 || + virXPathULongHex("string(@edx)", ctxt, &edx) < 0) + return -1; + + item->type =3D VIR_CPU_X86_DATA_MSR; + msr =3D &item->data.msr; + msr->index =3D index; + msr->eax =3D eax; + msr->edx =3D edx; + return 0; +} + + static int x86FeatureParse(xmlXPathContextPtr ctxt, const char *name, @@ -1011,25 +1087,35 @@ x86FeatureParse(xmlXPathContextPtr ctxt, if (STREQ_NULLABLE(str, "no")) feature->migratable =3D false; =20 - n =3D virXPathNodeSet("./cpuid", ctxt, &nodes); + n =3D virXPathNodeSet("./cpuid|./msr", ctxt, &nodes); if (n < 0) goto cleanup; =20 if (n =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Missing cpuid for feature %s"), + _("Missing cpuid or msr element in feature %s"), feature->name); goto cleanup; } =20 for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; - if (x86ParseCPUID(ctxt, &item) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid cpuid[%zu] in %s feature"), - i, feature->name); - goto cleanup; + if (virXMLNodeNameEqual(nodes[i], "cpuid")) { + if (x86ParseCPUID(ctxt, &item) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid cpuid[%zu] in %s feature"), + i, feature->name); + goto cleanup; + } + } else { + if (x86ParseMSR(ctxt, &item) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid msr[%zu] in %s feature"), + i, feature->name); + goto cleanup; + } } + if (virCPUx86DataAddItem(&feature->data, &item)) goto cleanup; } @@ -1545,6 +1631,7 @@ virCPUx86DataFormat(const virCPUData *data) virBufferAddLit(&buf, "\n"); while ((item =3D virCPUx86DataNext(&iter))) { virCPUx86CPUIDPtr cpuid; + virCPUx86MSRPtr msr; =20 switch (item->type) { case VIR_CPU_X86_DATA_CPUID: @@ -1557,6 +1644,13 @@ virCPUx86DataFormat(const virCPUData *data) cpuid->eax, cpuid->ebx, cpuid->ecx, cpuid->e= dx); break; =20 + case VIR_CPU_X86_DATA_MSR: + msr =3D &item->data.msr; + virBufferAsprintf(&buf, + " \n", + msr->index, msr->eax, msr->edx); + break; + case VIR_CPU_X86_DATA_NONE: default: break; @@ -1580,7 +1674,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) size_t i; int n; =20 - n =3D virXPathNodeSet("/cpudata/cpuid", ctxt, &nodes); + n =3D virXPathNodeSet("/cpudata/cpuid|/cpudata/msr", ctxt, &nodes); if (n <=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("no x86 CPU data found")); @@ -1592,11 +1686,20 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt) =20 for (i =3D 0; i < n; i++) { ctxt->node =3D nodes[i]; - if (x86ParseCPUID(ctxt, &item) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("failed to parse cpuid[%zu]"), i); - goto error; + if (virXMLNodeNameEqual(nodes[i], "cpuid")) { + if (x86ParseCPUID(ctxt, &item) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to parse cpuid[%zu]"), i); + goto error; + } + } else { + if (x86ParseMSR(ctxt, &item) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to parse msr[%zu]"), i); + goto error; + } } + if (virCPUx86DataAdd(cpuData, &item) < 0) goto error; } diff --git a/src/cpu/cpu_x86_data.h b/src/cpu/cpu_x86_data.h index b16860b201..4600870c4c 100644 --- a/src/cpu/cpu_x86_data.h +++ b/src/cpu/cpu_x86_data.h @@ -33,6 +33,14 @@ struct _virCPUx86CPUID { uint32_t edx; }; =20 +typedef struct _virCPUx86MSR virCPUx86MSR; +typedef virCPUx86MSR *virCPUx86MSRPtr; +struct _virCPUx86MSR { + uint32_t index; + uint32_t eax; + uint32_t edx; +}; + # define CPUX86_BASIC 0x0 # define CPUX86_KVM 0x40000000 # define CPUX86_EXTENDED 0x80000000 @@ -72,6 +80,7 @@ struct _virCPUx86CPUID { typedef enum { VIR_CPU_X86_DATA_NONE =3D 0, VIR_CPU_X86_DATA_CPUID, + VIR_CPU_X86_DATA_MSR, } virCPUx86DataType; =20 typedef struct _virCPUx86DataItem virCPUx86DataItem; @@ -80,6 +89,7 @@ struct _virCPUx86DataItem { virCPUx86DataType type; union { virCPUx86CPUID cpuid; + virCPUx86MSR msr; } data; }; =20 diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index f532475702..f549003124 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -307,7 +307,8 @@ def parseMap(): =20 cpuMap =3D {} for feature in data["cpus"]["feature"]: - cpuMap[feature["@name"]] =3D parseFeature(feature["cpuid"]) + if "cpuid" in feature: + cpuMap[feature["@name"]] =3D parseFeature(feature["cpuid"]) =20 return cpuMap =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713005028816.1108102179893; Mon, 8 Apr 2019 01:43:25 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4574F30BA340; Mon, 8 Apr 2019 08:43:23 +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 186F25C297; Mon, 8 Apr 2019 08:43:23 +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 C6FC8181BA07; Mon, 8 Apr 2019 08:43:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388h1nm009229 for ; Mon, 8 Apr 2019 04:43:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D4B260FD4; Mon, 8 Apr 2019 08:43:01 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C1BB60FD2 for ; Mon, 8 Apr 2019 08:42:58 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 16D0D103670; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:28 +0200 Message-Id: <38a9fac06c640cc9ebf80668d302116571f92942.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 24/36] cpu_x86: Move *CheckFeature functions 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Mon, 08 Apr 2019 08:43:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" They are static and we will need to call them a little bit closer to the beginning of the file. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 69 ++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 34 deletions(-) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 57837209b4..1fe6770d57 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2707,6 +2707,41 @@ cpuidSet(uint32_t base, virCPUDataPtr data) } =20 =20 +static int +virCPUx86CheckFeature(const virCPUDef *cpu, + const char *name) +{ + int ret =3D -1; + virCPUx86MapPtr map; + virCPUx86ModelPtr model =3D NULL; + + if (!(map =3D virCPUx86GetMap())) + return -1; + + if (!(model =3D x86ModelFromCPU(cpu, map, -1))) + goto cleanup; + + ret =3D x86FeatureInData(name, &model->data, map); + + cleanup: + x86ModelFree(model); + return ret; +} + + +static int +virCPUx86DataCheckFeature(const virCPUData *data, + const char *name) +{ + virCPUx86MapPtr map; + + if (!(map =3D virCPUx86GetMap())) + return -1; + + return x86FeatureInData(name, &data->data.x86, map); +} + + static int virCPUx86GetHost(virCPUDefPtr cpu, virDomainCapsCPUModelsPtr models) @@ -3063,40 +3098,6 @@ virCPUx86UpdateLive(virCPUDefPtr cpu, } =20 =20 -static int -virCPUx86CheckFeature(const virCPUDef *cpu, - const char *name) -{ - int ret =3D -1; - virCPUx86MapPtr map; - virCPUx86ModelPtr model =3D NULL; - - if (!(map =3D virCPUx86GetMap())) - return -1; - - if (!(model =3D x86ModelFromCPU(cpu, map, -1))) - goto cleanup; - - ret =3D x86FeatureInData(name, &model->data, map); - - cleanup: - x86ModelFree(model); - return ret; -} - - -static int -virCPUx86DataCheckFeature(const virCPUData *data, - const char *name) -{ - virCPUx86MapPtr map; - - if (!(map =3D virCPUx86GetMap())) - return -1; - - return x86FeatureInData(name, &data->data.x86, map); -} - static int virCPUx86GetModels(char ***models) { --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713025246242.04126807012858; Mon, 8 Apr 2019 01:43:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 816D7316769F; Mon, 8 Apr 2019 08:43:43 +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 5C3C160A9E; Mon, 8 Apr 2019 08:43:43 +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 C3F0E4EA71; Mon, 8 Apr 2019 08:43:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxOX009214 for ; Mon, 8 Apr 2019 04:43:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDAC61A267; 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 7175317796 for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 1DE4510371A; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:29 +0200 Message-Id: <6b46a84114c6c5f8df8d3ee883dac45bb021da7e.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 25/36] cputest: Drop support for old QEMU from cpu-parse.sh 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Mon, 08 Apr 2019 08:43:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We don't really need to parse CPU data from QEMU older than 2.9 (i.e., before query-cpu-model-expansion) at this point. But even if there's a need to do so, we can always use an older version of this script to do the conversion. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-cpuid.py | 262 ++------------------------------- tests/cputestdata/cpu-parse.sh | 3 +- 2 files changed, 12 insertions(+), 253 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index f549003124..56d5efc1c2 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -5,175 +5,6 @@ import sys import json import xmltodict =20 -# This is a list of x86 CPU features as of QEMU 2.8.50 and it won't need a= ny -# updates since in the future because query-cpu-model-expansion will be us= ed -# with newer QEMU. -cpuidMap =3D [ - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 001, "edx": 0, "names": ["pni", "sse3"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 002, "edx": 0, "names": ["pclmulqdq", "pclmuldq"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 004, "edx": 0, "names": ["dtes64"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 008, "edx": 0, "names": ["monitor"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 010, "edx": 0, "names": ["ds-cpl", "ds_cpl"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 020, "edx": 0, "names": ["vmx"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 040, "edx": 0, "names": ["smx"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 080, "edx": 0, "names": ["est"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 100, "edx": 0, "names": ["tm2"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 200, "edx": 0, "names": ["ssse3"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 400, "edx": 0, "names": ["cid"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00001= 000, "edx": 0, "names": ["fma"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00002= 000, "edx": 0, "names": ["cx16"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00004= 000, "edx": 0, "names": ["xtpr"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00008= 000, "edx": 0, "names": ["pdcm"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00020= 000, "edx": 0, "names": ["pcid"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00040= 000, "edx": 0, "names": ["dca"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00080= 000, "edx": 0, "names": ["sse4.1", "sse4-1", "sse4_1"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00100= 000, "edx": 0, "names": ["sse4.2", "sse4-2", "sse4_2"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00200= 000, "edx": 0, "names": ["x2apic"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00400= 000, "edx": 0, "names": ["movbe"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00800= 000, "edx": 0, "names": ["popcnt"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x01000= 000, "edx": 0, "names": ["tsc-deadline"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x02000= 000, "edx": 0, "names": ["aes"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x04000= 000, "edx": 0, "names": ["xsave"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x08000= 000, "edx": 0, "names": ["osxsave"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x10000= 000, "edx": 0, "names": ["avx"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x20000= 000, "edx": 0, "names": ["f16c"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x40000= 000, "edx": 0, "names": ["rdrand"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x80000= 000, "edx": 0, "names": ["hypervisor"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000001, "names": ["fpu"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000002, "names": ["vme"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000004, "names": ["de"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000008, "names": ["pse"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000010, "names": ["tsc"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000020, "names": ["msr"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000040, "names": ["pae"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000080, "names": ["mce"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000100, "names": ["cx8"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000200, "names": ["apic"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000800, "names": ["sep"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00001000, "names": ["mtrr"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00002000, "names": ["pge"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00004000, "names": ["mca"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00008000, "names": ["cmov"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00010000, "names": ["pat"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00020000, "names": ["pse36"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00040000, "names": ["pn"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00080000, "names": ["clflush"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00200000, "names": ["ds"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00400000, "names": ["acpi"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00800000, "names": ["mmx"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x01000000, "names": ["fxsr"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x02000000, "names": ["sse"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x04000000, "names": ["sse2"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x08000000, "names": ["ss"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x10000000, "names": ["ht"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x20000000, "names": ["tm"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x40000000, "names": ["ia64"]}, - {"in_eax": 0x00000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x80000000, "names": ["pbe"]}, - {"in_eax": 0x00000006, "in_ecx": 0, "eax": 0x00000004, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["arat"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000001, "ecx"= : 0, "edx": 0, "names": ["fsgsbase"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000002, "ecx"= : 0, "edx": 0, "names": ["tsc-adjust", "tsc_adjust"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000008, "ecx"= : 0, "edx": 0, "names": ["bmi1"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000010, "ecx"= : 0, "edx": 0, "names": ["hle"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000020, "ecx"= : 0, "edx": 0, "names": ["avx2"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000080, "ecx"= : 0, "edx": 0, "names": ["smep"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000100, "ecx"= : 0, "edx": 0, "names": ["bmi2"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000200, "ecx"= : 0, "edx": 0, "names": ["erms"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000400, "ecx"= : 0, "edx": 0, "names": ["invpcid"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00000800, "ecx"= : 0, "edx": 0, "names": ["rtm"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00001000, "ecx"= : 0, "edx": 0, "names": []}, # cmt is unknown to QEMU - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00004000, "ecx"= : 0, "edx": 0, "names": ["mpx"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00010000, "ecx"= : 0, "edx": 0, "names": ["avx512f"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00020000, "ecx"= : 0, "edx": 0, "names": ["avx512dq"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00040000, "ecx"= : 0, "edx": 0, "names": ["rdseed"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00080000, "ecx"= : 0, "edx": 0, "names": ["adx"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00100000, "ecx"= : 0, "edx": 0, "names": ["smap"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00200000, "ecx"= : 0, "edx": 0, "names": ["avx512ifma"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00400000, "ecx"= : 0, "edx": 0, "names": ["pcommit"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x00800000, "ecx"= : 0, "edx": 0, "names": ["clflushopt"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x01000000, "ecx"= : 0, "edx": 0, "names": ["clwb"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x04000000, "ecx"= : 0, "edx": 0, "names": ["avx512pf"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x08000000, "ecx"= : 0, "edx": 0, "names": ["avx512er"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x10000000, "ecx"= : 0, "edx": 0, "names": ["avx512cd"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x20000000, "ecx"= : 0, "edx": 0, "names": ["sha-ni"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x40000000, "ecx"= : 0, "edx": 0, "names": ["avx512bw"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0x80000000, "ecx"= : 0, "edx": 0, "names": ["avx512vl"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 002, "edx": 0, "names": ["avx512vbmi"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 004, "edx": 0, "names": ["umip"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 008, "edx": 0, "names": ["pku"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 010, "edx": 0, "names": ["ospke"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00004= 000, "edx": 0, "names": ["avx512-vpopcntdq"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00010= 000, "edx": 0, "names": ["la57"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00400= 000, "edx": 0, "names": ["rdpid"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000004, "names": ["avx512-4vnniw"]}, - {"in_eax": 0x00000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000008, "names": ["avx512-4fmaps"]}, - {"in_eax": 0x0000000d, "in_ecx": 1, "eax": 0x00000001, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["xsaveopt"]}, - {"in_eax": 0x0000000d, "in_ecx": 1, "eax": 0x00000002, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["xsavec"]}, - {"in_eax": 0x0000000d, "in_ecx": 1, "eax": 0x00000004, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["xgetbv1"]}, - {"in_eax": 0x0000000d, "in_ecx": 1, "eax": 0x00000008, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["xsaves"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x00000001, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvmclock"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x00000002, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvm-nopiodelay", "kvm_nopiodelay"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x00000004, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvm-mmu", "kvm_mmu"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x00000008, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvmclock"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x00000010, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvm-asyncpf", "kvm_asyncpf"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x00000020, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvm-steal-time", "kvm_steal_time"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x00000040, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvm-pv-eoi", "kvm_pv_eoi"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x00000080, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvm-pv-unhalt", "kvm_pv_unhalt"]}, - {"in_eax": 0x40000001, "in_ecx": 0, "eax": 0x01000000, "ebx": 0, "ecx"= : 0, "edx": 0, "names": ["kvmclock-stable-bit"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 001, "edx": 0, "names": ["lahf-lm", "lahf_lm"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 002, "edx": 0, "names": ["cmp-legacy", "cmp_legacy"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 004, "edx": 0, "names": ["svm"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 008, "edx": 0, "names": ["extapic"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 010, "edx": 0, "names": ["cr8legacy"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 020, "edx": 0, "names": ["abm"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 040, "edx": 0, "names": ["sse4a"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 080, "edx": 0, "names": ["misalignsse"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 100, "edx": 0, "names": ["3dnowprefetch"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 200, "edx": 0, "names": ["osvw"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 400, "edx": 0, "names": ["ibs"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00000= 800, "edx": 0, "names": ["xop"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00001= 000, "edx": 0, "names": ["skinit"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00002= 000, "edx": 0, "names": ["wdt"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00008= 000, "edx": 0, "names": ["lwp"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00010= 000, "edx": 0, "names": ["fma4"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00020= 000, "edx": 0, "names": ["tce"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00080= 000, "edx": 0, "names": ["nodeid-msr", "nodeid_msr"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00200= 000, "edx": 0, "names": ["tbm"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00400= 000, "edx": 0, "names": ["topoext"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x00800= 000, "edx": 0, "names": ["perfctr-core", "perfctr_core"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0x01000= 000, "edx": 0, "names": ["perfctr-nb", "perfctr_nb"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000800, "names": ["syscall"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00100000, "names": ["nx", "xd"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00400000, "names": ["mmxext"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x02000000, "names": ["fxsr-opt", "ffxsr", "fxsr_opt"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x04000000, "names": ["pdpe1gb"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x08000000, "names": ["rdtscp"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x20000000, "names": ["lm", "i64"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x40000000, "names": ["3dnowext"]}, - {"in_eax": 0x80000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x80000000, "names": ["3dnow"]}, - {"in_eax": 0x80000007, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000100, "names": ["invtsc"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000001, "names": ["npt"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000002, "names": ["lbrv"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000004, "names": ["svm-lock", "svm_lock"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000008, "names": ["nrip-save", "nrip_save"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000010, "names": ["tsc-scale", "tsc_scale"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000020, "names": ["vmcb-clean", "vmcb_clean"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000040, "names": ["flushbyasid"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000080, "names": ["decodeassists"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000400, "names": ["pause-filter", "pause_filter"]}, - {"in_eax": 0x8000000A, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00001000, "names": ["pfthreshold"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000004, "names": ["xstore"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000008, "names": ["xstore-en"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000040, "names": ["xcrypt"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000080, "names": ["xcrypt-en"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000100, "names": ["ace2"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000200, "names": ["ace2-en"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000400, "names": ["phe"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00000800, "names": ["phe-en"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00001000, "names": ["pmm"]}, - {"in_eax": 0xC0000001, "in_ecx": 0, "eax": 0, "ebx": 0, "ecx": 0, "edx= ": 0x00002000, "names": ["pmm-en"]}, -] - - def cpuidIsSet(cpuid, feature): in_eax =3D feature["in_eax"] in_ecx =3D feature["in_ecx"] @@ -192,68 +23,19 @@ def cpuidIsSet(cpuid, feature): (edx > 0 and leaf["edx"] & edx > 0)) =20 =20 -def cpuidLeaf(cpuid, in_eax, in_ecx): - if in_eax not in cpuid: - cpuid[in_eax] =3D {} - leaf =3D cpuid[in_eax] - - if in_ecx not in leaf: - leaf[in_ecx] =3D {"eax": 0, "ebx": 0, "ecx": 0, "edx": 0} - leaf =3D leaf[in_ecx] - - return leaf - - def cpuidAdd(cpuid, feature): - leaf =3D cpuidLeaf(cpuid, feature["in_eax"], feature["in_ecx"]) + if feature["in_eax"] not in cpuid: + cpuid[feature["in_eax"]] =3D {} + leaf =3D cpuid[feature["in_eax"]] + + if feature["in_ecx"] not in leaf: + leaf[feature["in_ecx"]] =3D {"eax": 0, "ebx": 0, "ecx": 0, "edx": = 0} + leaf =3D leaf[feature["in_ecx"]] + for reg in ["eax", "ebx", "ecx", "edx"]: leaf[reg] |=3D feature[reg] =20 =20 -def parseFeatureWords(path): - features =3D None - - dec =3D json.JSONDecoder() - - with open(path, "r") as f: - s =3D f.read() - - props =3D {} - rest =3D [] - chunk =3D 0 - while s !=3D "": - (data, pos) =3D dec.raw_decode(s) - if chunk =3D=3D 0: - features =3D data["return"] - elif chunk < 5: - keys =3D ["family", "model", "stepping", "model-id"] - props[keys[chunk - 1]] =3D data["return"] - else: - rest.append(data) - - while pos < len(s) and s[pos] !=3D "{": - pos +=3D 1 - s =3D s[pos:] - chunk +=3D 1 - - if props["model-id"].find("Intel") !=3D -1: - props["vendor"] =3D "GenuineIntel" - elif props["model-id"].find("AMD") !=3D -1: - props["vendor"] =3D "AuthenticAMD" - - cpuid =3D {} - for feat in features: - in_eax =3D feat["cpuid-input-eax"] - in_ecx =3D 0 - if "cpuid-input-ecx" in feat: - in_ecx =3D feat["cpuid-input-ecx"] - - leaf =3D cpuidLeaf(cpuid, in_eax, in_ecx) - leaf[feat["cpuid-register"].lower()] =3D feat["features"] - - return props, cpuid, rest - - def parseQemu(path, features): cpuid =3D {} with open(path, "r") as f: @@ -330,27 +112,6 @@ def formatCpuid(cpuid, path, comment): f.write("\n") =20 =20 -def convert(path): - props, cpuid, rest =3D parseFeatureWords(path) - - for feature in cpuidMap: - value =3D cpuidIsSet(cpuid, feature) - for name in feature["names"]: - props[name] =3D value - - print(path) - with open(path, "w") as f: - json.dump({"return": {"model": {"name": "base", "props": props}}, - "id": "model-expansion"}, - f, indent=3D2, separators=3D(',', ': ')) - f.write("\n") - - for chunk in rest: - f.write("\n") - json.dump(chunk, f, indent=3D2, separators=3D(',', ': ')) - f.write("\n") - - def diff(cpuMap, path): base =3D path.replace(".json", "") jsonFile =3D path @@ -374,16 +135,13 @@ def diff(cpuMap, path): =20 =20 if len(sys.argv) < 3: - print("Usage: %s convert|diff json_file..." % sys.argv[0]) + print("Usage: %s diff json_file..." % sys.argv[0]) sys.exit(1) =20 action =3D sys.argv[1] args =3D sys.argv[2:] =20 -if action =3D=3D "convert": - for path in args: - convert(path) -elif action =3D=3D "diff": +if action =3D=3D "diff": cpuMap =3D parseMap() for path in args: diff(cpuMap, path) diff --git a/tests/cputestdata/cpu-parse.sh b/tests/cputestdata/cpu-parse.sh index 3a2bfa0491..a001647549 100755 --- a/tests/cputestdata/cpu-parse.sh +++ b/tests/cputestdata/cpu-parse.sh @@ -53,7 +53,8 @@ json <<<"$data" >$fname.json if [[ -s $fname.json ]]; then echo $fname.json if ! grep -q model-expansion $fname.json; then - $(dirname $0)/cpu-cpuid.py convert $fname.json + echo "Missing query-cpu-model-expansion reply in $name.json" >&2 + exit 1 fi $(dirname $0)/cpu-cpuid.py diff $fname.json else --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713033453100.84578080736912; Mon, 8 Apr 2019 01:43:53 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DCD0230230A0; Mon, 8 Apr 2019 08:43:51 +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 B4B065D71B; Mon, 8 Apr 2019 08:43:51 +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 691424ED2A; Mon, 8 Apr 2019 08:43:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388h14x009247 for ; Mon, 8 Apr 2019 04:43:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8A46A60BE5; Mon, 8 Apr 2019 08:43:01 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1C02760FD1 for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 2342810378D; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:30 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 26/36] cputest: Generalize function names in 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 08 Apr 2019 08:43:52 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The function will have to deal with both CPUID and MSR features. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-cpuid.py | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index 56d5efc1c2..866c8047cd 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -5,7 +5,7 @@ import sys import json import xmltodict =20 -def cpuidIsSet(cpuid, feature): +def checkFeature(cpuid, feature): in_eax =3D feature["in_eax"] in_ecx =3D feature["in_ecx"] eax =3D feature["eax"] @@ -23,7 +23,7 @@ def cpuidIsSet(cpuid, feature): (edx > 0 and leaf["edx"] & edx > 0)) =20 =20 -def cpuidAdd(cpuid, feature): +def addFeature(cpuid, feature): if feature["in_eax"] not in cpuid: cpuid[feature["in_eax"]] =3D {} leaf =3D cpuid[feature["in_eax"]] @@ -37,19 +37,19 @@ def cpuidAdd(cpuid, feature): =20 =20 def parseQemu(path, features): - cpuid =3D {} + cpuData =3D {} with open(path, "r") as f: data, pos =3D json.JSONDecoder().raw_decode(f.read()) =20 for (prop, val) in data["return"]["model"]["props"].items(): if val and prop in features: - cpuidAdd(cpuid, features[prop]) + addFeature(cpuData, features[prop]) =20 - return cpuid + return cpuData =20 =20 -def parseCpuid(path): - cpuid =3D {} +def parseCPUData(path): + cpuData =3D {} with open(path, "rb") as f: data =3D xmltodict.parse(f) =20 @@ -60,12 +60,12 @@ def parseCpuid(path): for reg in ["eax", "ebx", "ecx", "edx"]: feature[reg] =3D int(leaf["@" + reg], 0) =20 - cpuidAdd(cpuid, feature) + addFeature(cpuData, feature) =20 - return cpuid + return cpuData =20 =20 -def parseFeature(data): +def parseMapFeature(data): cpuid =3D {} for reg in ["in_eax", "in_ecx", "eax", "ebx", "ecx", "edx"]: if reg.startswith("in_"): @@ -90,12 +90,12 @@ def parseMap(): cpuMap =3D {} for feature in data["cpus"]["feature"]: if "cpuid" in feature: - cpuMap[feature["@name"]] =3D parseFeature(feature["cpuid"]) + cpuMap[feature["@name"]] =3D parseMapFeature(feature["cpuid"]) =20 return cpuMap =20 =20 -def formatCpuid(cpuid, path, comment): +def formatCPUData(cpuid, path, comment): print(path) with open(path, "w") as f: f.write("\n") @@ -115,23 +115,23 @@ def formatCpuid(cpuid, path, comment): def diff(cpuMap, path): base =3D path.replace(".json", "") jsonFile =3D path - cpuidFile =3D base + ".xml" + cpuDataFile =3D base + ".xml" enabledFile =3D base + "-enabled.xml" disabledFile =3D base + "-disabled.xml" =20 - cpuid =3D parseCpuid(cpuidFile) + cpuData =3D parseCPUData(cpuDataFile) qemu =3D parseQemu(jsonFile, cpuMap) =20 enabled =3D {} disabled =3D {} for feature in cpuMap.values(): - if cpuidIsSet(qemu, feature): - cpuidAdd(enabled, feature) - elif cpuidIsSet(cpuid, feature): - cpuidAdd(disabled, feature) + if checkFeature(qemu, feature): + addFeature(enabled, feature) + elif checkFeature(cpuData, feature): + addFeature(disabled, feature) =20 - formatCpuid(enabled, enabledFile, "Features enabled by QEMU") - formatCpuid(disabled, disabledFile, "Features disabled by QEMU") + formatCPUData(enabled, enabledFile, "Features enabled by QEMU") + formatCPUData(disabled, disabledFile, "Features disabled by QEMU") =20 =20 if len(sys.argv) < 3: --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713009378804.8664730413004; Mon, 8 Apr 2019 01:43:29 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADCCE307B96B; Mon, 8 Apr 2019 08:43:27 +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 83531665C5; Mon, 8 Apr 2019 08:43:27 +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 45389181BA08; Mon, 8 Apr 2019 08:43:27 +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 x388gxOC009173 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 45D675D721; 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 1A2455D71E for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 289D5103825; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:31 +0200 Message-Id: <8421e99cb08d240f848eae4c231e133e09a7f041.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 27/36] cputest: Fix comparison in checkCPUIDFeature in 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 08 Apr 2019 08:43:28 +0000 (UTC) Content-Type: text/plain; charset="utf-8" leaf["eax"] & eax > 0 check works correctly only if there's at most 1 bit set in eax. Luckily that's been always the case, but fixing this could save us from future surprises. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-cpuid.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index 866c8047cd..0a2710689d 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -15,12 +15,12 @@ def checkFeature(cpuid, feature): =20 if in_eax not in cpuid or in_ecx not in cpuid[in_eax]: return False - else: - leaf =3D cpuid[in_eax][in_ecx] - return ((eax > 0 and leaf["eax"] & eax > 0) or - (ebx > 0 and leaf["ebx"] & ebx > 0) or - (ecx > 0 and leaf["ecx"] & ecx > 0) or - (edx > 0 and leaf["edx"] & edx > 0)) + + leaf =3D cpuid[in_eax][in_ecx] + 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)) =20 =20 def addFeature(cpuid, feature): --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713001099476.0257986940935; Mon, 8 Apr 2019 01:43:21 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CA65307E04F; Mon, 8 Apr 2019 08:43:19 +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 55DFE60CD6; Mon, 8 Apr 2019 08:43:19 +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 188373F5CC; Mon, 8 Apr 2019 08:43:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388h1xn009227 for ; Mon, 8 Apr 2019 04:43:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4910460FD5; Mon, 8 Apr 2019 08:43:01 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BEF960CD6 for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 2E322103826; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:32 +0200 Message-Id: <1a845af868bd4188b2bb1a49c8cd1b0417086012.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 28/36] cputest: Rename in_e[ac]x as e[ac]x_in in 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 08 Apr 2019 08:43:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This will let us simplify the code since the dictionary keys will match attribute names in various XMLs. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-cpuid.py | 39 ++++++++++++++++------------------ 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index 0a2710689d..cba5fc165a 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -6,17 +6,17 @@ import json import xmltodict =20 def checkFeature(cpuid, feature): - in_eax =3D feature["in_eax"] - in_ecx =3D feature["in_ecx"] + 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"] =20 - if in_eax not in cpuid or in_ecx not in cpuid[in_eax]: + if eax_in not in cpuid or ecx_in not in cpuid[eax_in]: return False =20 - leaf =3D cpuid[in_eax][in_ecx] + 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 @@ -24,13 +24,13 @@ def checkFeature(cpuid, feature): =20 =20 def addFeature(cpuid, feature): - if feature["in_eax"] not in cpuid: - cpuid[feature["in_eax"]] =3D {} - leaf =3D cpuid[feature["in_eax"]] + if feature["eax_in"] not in cpuid: + cpuid[feature["eax_in"]] =3D {} + leaf =3D cpuid[feature["eax_in"]] =20 - if feature["in_ecx"] not in leaf: - leaf[feature["in_ecx"]] =3D {"eax": 0, "ebx": 0, "ecx": 0, "edx": = 0} - leaf =3D leaf[feature["in_ecx"]] + if feature["ecx_in"] not in leaf: + leaf[feature["ecx_in"]] =3D {"eax": 0, "ebx": 0, "ecx": 0, "edx": = 0} + leaf =3D leaf[feature["ecx_in"]] =20 for reg in ["eax", "ebx", "ecx", "edx"]: leaf[reg] |=3D feature[reg] @@ -55,8 +55,8 @@ def parseCPUData(path): =20 for leaf in data["cpudata"]["cpuid"]: feature =3D {} - feature["in_eax"] =3D int(leaf["@eax_in"], 0) - feature["in_ecx"] =3D int(leaf["@ecx_in"], 0) + feature["eax_in"] =3D int(leaf["@eax_in"], 0) + feature["ecx_in"] =3D int(leaf["@ecx_in"], 0) for reg in ["eax", "ebx", "ecx", "edx"]: feature[reg] =3D int(leaf["@" + reg], 0) =20 @@ -67,11 +67,8 @@ def parseCPUData(path): =20 def parseMapFeature(data): cpuid =3D {} - for reg in ["in_eax", "in_ecx", "eax", "ebx", "ecx", "edx"]: - if reg.startswith("in_"): - attr =3D "@%s_in" % reg[3:] - else: - attr =3D "@%s" % reg + for reg in ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"]: + attr =3D "@%s" % reg =20 if attr in data: cpuid[reg] =3D int(data[attr], 0) @@ -100,14 +97,14 @@ def formatCPUData(cpuid, path, comment): with open(path, "w") as f: f.write("\n") f.write("\n") - for in_eax in sorted(cpuid.keys()): - for in_ecx in sorted(cpuid[in_eax].keys()): - leaf =3D cpuid[in_eax][in_ecx] + for eax_in in sorted(cpuid.keys()): + for ecx_in in sorted(cpuid[eax_in].keys()): + leaf =3D cpuid[eax_in][ecx_in] line =3D (" \n") f.write(line % ( - in_eax, in_ecx, + eax_in, ecx_in, leaf["eax"], leaf["ebx"], leaf["ecx"], leaf["edx"]= )) f.write("\n") =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713012999520.5896741311866; Mon, 8 Apr 2019 01:43:32 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 70D14308622F; Mon, 8 Apr 2019 08:43:31 +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 419FE5D969; Mon, 8 Apr 2019 08:43:31 +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 F307741F3C; Mon, 8 Apr 2019 08:43:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxKJ009175 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 48D0F5D9C9; 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 1DEDF5DA2C for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 339B2103827; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:33 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 29/36] cputest: Prepare cpu-cpuid.py for MSR features 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 08 Apr 2019 08:43:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Let's make sure the current CPUID specific code is only applied to CPUID features. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-cpuid.py | 36 +++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index cba5fc165a..ac69c5a012 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -5,7 +5,7 @@ import sys import json import xmltodict =20 -def checkFeature(cpuid, feature): +def checkCPUIDFeature(cpuData, feature): eax_in =3D feature["eax_in"] ecx_in =3D feature["ecx_in"] eax =3D feature["eax"] @@ -13,6 +13,10 @@ def checkFeature(cpuid, feature): ecx =3D feature["ecx"] edx =3D feature["edx"] =20 + 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 =20 @@ -23,7 +27,18 @@ def checkFeature(cpuid, feature): (edx > 0 and leaf["edx"] & edx =3D=3D edx)) =20 =20 -def addFeature(cpuid, feature): +def checkFeature(cpuData, feature): + if feature["type"] =3D=3D "cpuid": + return checkCPUIDFeature(cpuData, feature) + + return False + + +def addCPUIDFeature(cpuData, feature): + if "cpuid" not in cpuData: + cpuData["cpuid"] =3D {} + cpuid =3D cpuData["cpuid"] + if feature["eax_in"] not in cpuid: cpuid[feature["eax_in"]] =3D {} leaf =3D cpuid[feature["eax_in"]] @@ -36,6 +51,11 @@ def addFeature(cpuid, feature): leaf[reg] |=3D feature[reg] =20 =20 +def addFeature(cpuData, feature): + if feature["type"] =3D=3D "cpuid": + addCPUIDFeature(cpuData, feature) + + def parseQemu(path, features): cpuData =3D {} with open(path, "r") as f: @@ -54,7 +74,7 @@ def parseCPUData(path): data =3D xmltodict.parse(f) =20 for leaf in data["cpudata"]["cpuid"]: - feature =3D {} + feature =3D {"type": "cpuid"} feature["eax_in"] =3D int(leaf["@eax_in"], 0) feature["ecx_in"] =3D int(leaf["@ecx_in"], 0) for reg in ["eax", "ebx", "ecx", "edx"]: @@ -66,7 +86,7 @@ def parseCPUData(path): =20 =20 def parseMapFeature(data): - cpuid =3D {} + cpuid =3D {"type": "cpuid"} for reg in ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"]: attr =3D "@%s" % reg =20 @@ -92,11 +112,13 @@ def parseMap(): return cpuMap =20 =20 -def formatCPUData(cpuid, path, comment): +def formatCPUData(cpuData, path, comment): print(path) with open(path, "w") as f: f.write("\n") f.write("\n") + + cpuid =3D cpuData["cpuid"] for eax_in in sorted(cpuid.keys()): for ecx_in in sorted(cpuid[eax_in].keys()): leaf =3D cpuid[eax_in][ecx_in] @@ -119,8 +141,8 @@ def diff(cpuMap, path): cpuData =3D parseCPUData(cpuDataFile) qemu =3D parseQemu(jsonFile, cpuMap) =20 - enabled =3D {} - disabled =3D {} + enabled =3D {"cpuid": {}} + disabled =3D {"cpuid": {}} for feature in cpuMap.values(): if checkFeature(qemu, feature): addFeature(enabled, feature) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554712997718590.3008979048689; Mon, 8 Apr 2019 01:43:17 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0B3A81233; Mon, 8 Apr 2019 08:43:15 +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 BB102665CB; Mon, 8 Apr 2019 08:43:15 +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 76E0D3FA4D; Mon, 8 Apr 2019 08:43:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388h1Oa009222 for ; Mon, 8 Apr 2019 04:43:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2F6815C297; Mon, 8 Apr 2019 08:43:01 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 00D141803A for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 38CB7103828; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 30/36] cputest: Generalize feature parsing in 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 08 Apr 2019 08:43:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The parseMapFeature for parsing features from CPU map XML can be easily generalized to support more feature types. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-cpuid.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/cputestdata/cpu-cpuid.py b/tests/cputestdata/cpu-cpuid.py index ac69c5a012..89efc3a40c 100755 --- a/tests/cputestdata/cpu-cpuid.py +++ b/tests/cputestdata/cpu-cpuid.py @@ -85,17 +85,20 @@ def parseCPUData(path): return cpuData =20 =20 -def parseMapFeature(data): - cpuid =3D {"type": "cpuid"} - for reg in ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"]: - attr =3D "@%s" % reg +def parseMapFeature(fType, data): + ret =3D {"type": fType} =20 + if fType =3D=3D "cpuid": + fields =3D ["eax_in", "ecx_in", "eax", "ebx", "ecx", "edx"] + + for field in fields: + attr =3D "@%s" % field if attr in data: - cpuid[reg] =3D int(data[attr], 0) + ret[field] =3D int(data[attr], 0) else: - cpuid[reg] =3D 0 + ret[field] =3D 0 =20 - return cpuid + return ret =20 =20 def parseMap(): @@ -106,8 +109,9 @@ def parseMap(): =20 cpuMap =3D {} for feature in data["cpus"]["feature"]: - if "cpuid" in feature: - cpuMap[feature["@name"]] =3D parseMapFeature(feature["cpuid"]) + for fType in ["cpuid"]: + if fType in feature: + cpuMap[feature["@name"]] =3D parseMapFeature(fType, featur= e[fType]) =20 return cpuMap =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 15547130178291019.2574498270739; Mon, 8 Apr 2019 01:43:37 -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 366C430BC660; Mon, 8 Apr 2019 08:43:36 +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 040BA60471; Mon, 8 Apr 2019 08:43:36 +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 B0B35181BA13; Mon, 8 Apr 2019 08:43:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxiX009174 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 469191803A; 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 1A92E1822D for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 3E3E3103829; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:35 +0200 Message-Id: <3ae52cdf6db252d8a8ecba965f1ac7d251af562c.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 31/36] cputest: Add support for MSR features to cpu-gather.sh 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.46]); Mon, 08 Apr 2019 08:43:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This patch adds an inline python code for reading MSR features. Since reading MSRs is a privileged operation, we have to read them from /dev/cpu/*/msr if it is readable (i.e., the script runs as root) or fallback to using KVM ioctl which can be done by any user that can start virtual machines. The python code is inlined rather than provided in a separate script because whenever there's an issue with proper detection of CPU features, we ask the reporter to run cpu-gather.sh script to give us all data we need to know about the host CPU. Asking them to run several scripts would likely result in one of them being ignored or forgotten. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-gather.sh | 49 ++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/tests/cputestdata/cpu-gather.sh b/tests/cputestdata/cpu-gather= .sh index 9c696f57bd..cefd1b0d0d 100755 --- a/tests/cputestdata/cpu-gather.sh +++ b/tests/cputestdata/cpu-gather.sh @@ -7,8 +7,55 @@ grep 'model name' /proc/cpuinfo | head -n1 =20 cpuid -1r - echo + +for python in python3 python2; do + $python < Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1554713029432609.683872918376; Mon, 8 Apr 2019 01:43:49 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BC4288E50; Mon, 8 Apr 2019 08:43:47 +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 33159648CB; Mon, 8 Apr 2019 08:43:47 +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 E8A79181BA1D; Mon, 8 Apr 2019 08:43:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388h1mU009228 for ; Mon, 8 Apr 2019 04:43:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 48B2660BE5; Mon, 8 Apr 2019 08:43:01 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.188]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1BC3D60CCC for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 4392B10382E; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:36 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 32/36] cputest: Add support for MSR features to cpu-parse.sh 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 08 Apr 2019 08:43:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The script just parses whatever cpu-gather.sh printed out. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- tests/cputestdata/cpu-parse.sh | 9 ++++++--- tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/cputestdata/cpu-parse.sh b/tests/cputestdata/cpu-parse.sh index a001647549..7501c57cba 100755 --- a/tests/cputestdata/cpu-parse.sh +++ b/tests/cputestdata/cpu-parse.sh @@ -23,12 +23,15 @@ fname=3D"x86_64-cpuid-$fname" xml() { hex=3D'\(0x[0-9a-f]\+\)' - match=3D"$hex $hex: eax=3D$hex ebx=3D$hex ecx=3D$hex edx=3D$hex" - subst=3D"" + matchCPUID=3D"$hex $hex: eax=3D$hex ebx=3D$hex ecx=3D$hex edx=3D$hex" + substCPUID=3D"" + + matchMSR=3D"$hex: $hex\(.......[0-9a-f]\)" + substMSR=3D"" =20 echo "" echo "" - sed -ne "s/^ *$match$/ $subst/p" + sed -ne "s/^ *$matchCPUID$/ $substCPUID/p; s/^ *$matchMSR$/ $substMS= R/p" echo "" } =20 diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml b/tests/= cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml index 75472d44fe..f1261da891 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268.xml @@ -51,4 +51,5 @@ + --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 From nobody Tue May 7 18:14:05 2024 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 1554713016876345.09500286491266; Mon, 8 Apr 2019 01:43:36 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3D6E33092662; Mon, 8 Apr 2019 08:43:35 +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 110071092002; Mon, 8 Apr 2019 08:43:35 +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 C6EDF181B9E8; Mon, 8 Apr 2019 08:43:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxhZ009188 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7027F6608B; 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 4486A665C7 for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 4E70D103833; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:38 +0200 Message-Id: <73e748a985c821b73f44242a3471d5408f578e91.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 34/36] vircpuhost: Add support for reading MSRs 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 08 Apr 2019 08:43:35 +0000 (UTC) Content-Type: text/plain; charset="utf-8" The new virHostCPUGetMSR internal API will try to read the MSR from /dev/cpu/0/msr and if it is not possible (the device does not exist or libvirt is running unprivileged), it will fallback to asking KVM for the MSR using KVM_GET_MSRS ioctl. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/libvirt_private.syms | 1 + src/util/virhostcpu.c | 80 ++++++++++++++++++++++++++++++++++++++++ src/util/virhostcpu.h | 3 ++ 3 files changed, 84 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 132ee3cae9..59a9a6f093 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2016,6 +2016,7 @@ virHostCPUGetInfo; virHostCPUGetKVMMaxVCPUs; virHostCPUGetMap; virHostCPUGetMicrocodeVersion; +virHostCPUGetMSR; virHostCPUGetOnline; virHostCPUGetOnlineBitmap; virHostCPUGetPresentBitmap; diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c index 6514c3d765..10bf3a93d5 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c @@ -58,6 +58,7 @@ VIR_LOG_INIT("util.hostcpu"); =20 #define KVM_DEVICE "/dev/kvm" +#define MSR_DEVICE "/dev/cpu/0/msr" =20 =20 #if defined(__FreeBSD__) || defined(__APPLE__) @@ -1254,3 +1255,82 @@ virHostCPUGetMicrocodeVersion(void) } =20 #endif /* __linux__ */ + + +#if HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS) +static int +virHostCPUGetMSRFromKVM(unsigned long index, + uint64_t *result) +{ + VIR_AUTOCLOSE fd =3D -1; + struct { + struct kvm_msrs header; + struct kvm_msr_entry entry; + } msr =3D { + .header =3D { .nmsrs =3D 1 }, + .entry =3D { .index =3D index }, + }; + + if ((fd =3D open(KVM_DEVICE, O_RDONLY)) < 0) { + virReportSystemError(errno, _("Unable to open %s"), KVM_DEVICE); + return -1; + } + + if (ioctl(fd, KVM_GET_MSRS, &msr) < 0) { + VIR_DEBUG("Cannot get MSR 0x%lx from KVM", index); + return 1; + } + + *result =3D msr.entry.data; + return 0; +} + +#else + +static int +virHostCPUGetMSRFromKVM(unsigned long index ATTRIBUTE_UNUSED, + uint64_t *result ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Reading MSRs via KVM is not supported on this = platform")); + return -1; +} +#endif /* HAVE_LINUX_KVM_H && defined(KVM_GET_MSRS) */ + + +/* + * Returns 0 on success, + * 1 when the MSR is not supported by the host CPU, +* -1 on error. + */ +int +virHostCPUGetMSR(unsigned long index, + uint64_t *msr) +{ + VIR_AUTOCLOSE fd =3D -1; + char ebuf[1024]; + + *msr =3D 0; + + if ((fd =3D open(MSR_DEVICE, O_RDONLY)) < 0) { + VIR_DEBUG("Unable to open %s: %s", + MSR_DEVICE, virStrerror(errno, ebuf, sizeof(ebuf))); + } else { + int rc =3D pread(fd, msr, sizeof(*msr), index); + + if (rc =3D=3D sizeof(*msr)) + return 0; + + if (rc < 0 && errno =3D=3D EIO) { + VIR_DEBUG("CPU does not support MSR 0x%lx", index); + return 1; + } + + VIR_DEBUG("Cannot read MSR 0x%lx from %s: %s", + index, MSR_DEVICE, virStrerror(errno, ebuf, sizeof(ebuf)= )); + } + + VIR_DEBUG("Falling back to KVM ioctl"); + + return virHostCPUGetMSRFromKVM(index, msr); +} diff --git a/src/util/virhostcpu.h b/src/util/virhostcpu.h index df6a7e789d..0d20dbef61 100644 --- a/src/util/virhostcpu.h +++ b/src/util/virhostcpu.h @@ -66,4 +66,7 @@ int virHostCPUGetOnline(unsigned int cpu, bool *online); =20 unsigned int virHostCPUGetMicrocodeVersion(void); =20 +int virHostCPUGetMSR(unsigned long index, + uint64_t *msr); + #endif /* LIBVIRT_VIRHOSTCPU_H */ --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713024064258.56151709739106; Mon, 8 Apr 2019 01:43:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F6D3A85F; Mon, 8 Apr 2019 08:43: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 1941260A9E; Mon, 8 Apr 2019 08:43: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 CF99A4A460; Mon, 8 Apr 2019 08:43:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x388gxVf009190 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72A5A600D4; 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 449F9189FA for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 53F68103841; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:39 +0200 Message-Id: <4f2020b5f3525bf7f4c117774c269d0292afdd0a.1554711784.git.jdenemar@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 35/36] cpu_x86: Read CPU features from IA32_ARCH_CAPABILITIES MSR 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 08 Apr 2019 08:43:42 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This is used by the host capabilities code to construct host CPU definition. Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- src/cpu/cpu_x86.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 1fe6770d57..74385f7992 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -2759,6 +2759,30 @@ virCPUx86GetHost(virCPUDefPtr cpu, cpuidSet(CPUX86_EXTENDED, cpuData) < 0) goto cleanup; =20 + /* Read the IA32_ARCH_CAPABILITIES MSR (0x10a) if supported. + * This is best effort since there might be no way to read the MSR. */ + if (virCPUx86DataCheckFeature(cpuData, "arch-capabilities") =3D=3D 1) { + uint64_t msr; + unsigned long index =3D 0x10a; + int rc =3D virHostCPUGetMSR(index, &msr); + + if (rc < 0) { + virResetLastError(); + } else if (rc =3D=3D 0) { + virCPUx86DataItem item =3D { + .type =3D VIR_CPU_X86_DATA_MSR, + .data.msr =3D { + .index =3D index, + .eax =3D msr & 0xffffffff, + .edx =3D msr >> 32, + }, + }; + + if (virCPUx86DataAdd(cpuData, &item) < 0) + return -1; + } + } + ret =3D x86DecodeCPUData(cpu, cpuData, models); cpu->microcodeVersion =3D virHostCPUGetMicrocodeVersion(); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 18:14:05 2024 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 1554713027657493.527627257189; Mon, 8 Apr 2019 01:43:47 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB3D8C130701; Mon, 8 Apr 2019 08:43:45 +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 C75F960FD3; Mon, 8 Apr 2019 08:43:45 +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 8BAC44EBC0; Mon, 8 Apr 2019 08:43:45 +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 x388gxfJ009209 for ; Mon, 8 Apr 2019 04:42:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id B88B65D719; 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 67D045D71E for ; Mon, 8 Apr 2019 08:42:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 59A8C103842; Mon, 8 Apr 2019 10:42:51 +0200 (CEST) From: Jiri Denemark To: libvir-list@redhat.com Date: Mon, 8 Apr 2019 10:42:40 +0200 Message-Id: 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 36/36] cpu_map: Introduce IA32_ARCH_CAPABILITIES MSR features 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 08 Apr 2019 08:43:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" --- This should not be pushed yet as the QEMU interface for MSR features is not complete yet. If a domain with some MSR features enabled would be started, all of them would be marked as disabled in the live domain configuration (even though they were actually enabled by QEMU) and they would disappear during migration. src/cpu_map/x86_features.xml | 17 +++++++++++++++++ .../x86_64-cpuid-Core-i7-7600U-enabled.xml | 1 + .../x86_64-cpuid-Core-i7-7600U-json.xml | 1 + .../x86_64-cpuid-Xeon-Platinum-8268-enabled.xml | 1 + .../x86_64-cpuid-Xeon-Platinum-8268-guest.xml | 3 +++ .../x86_64-cpuid-Xeon-Platinum-8268-host.xml | 3 +++ .../x86_64-cpuid-Xeon-Platinum-8268-json.xml | 3 +++ .../domaincapsschemadata/qemu_3.1.0.x86_64.xml | 1 + .../domaincapsschemadata/qemu_4.0.0.x86_64.xml | 1 + 9 files changed, 31 insertions(+) diff --git a/src/cpu_map/x86_features.xml b/src/cpu_map/x86_features.xml index 02431bea29..d73a30017f 100644 --- a/src/cpu_map/x86_features.xml +++ b/src/cpu_map/x86_features.xml @@ -476,4 +476,21 @@ + + + + + + + + + + + + + + + + + diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml b/tes= ts/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml index b1cdaa802a..58bc84577c 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-enabled.xml @@ -5,4 +5,5 @@ + diff --git a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml b/tests/= cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml index 48089c6003..690081493b 100644 --- a/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Core-i7-7600U-json.xml @@ -10,4 +10,5 @@ + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml = b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml index 434ac1956a..313009b156 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-enabled.xml @@ -5,4 +5,5 @@ + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml b/= tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml index cc1fc90c45..d401230a87 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-guest.xml @@ -29,4 +29,7 @@ + + + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml b/t= ests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml index dfabdc57c7..e96712533a 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-host.xml @@ -30,4 +30,7 @@ + + + diff --git a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml b/t= ests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml index b7d12dced7..78863c61d1 100644 --- a/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml +++ b/tests/cputestdata/x86_64-cpuid-Xeon-Platinum-8268-json.xml @@ -7,4 +7,7 @@ + + + diff --git a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml b/tests/domai= ncapsschemadata/qemu_3.1.0.x86_64.xml index f49da218e2..cd816d816d 100644 --- a/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_3.1.0.x86_64.xml @@ -35,6 +35,7 @@ + qemu64 diff --git a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml b/tests/domai= ncapsschemadata/qemu_4.0.0.x86_64.xml index 84c33437a2..7b563d8dc0 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml @@ -35,6 +35,7 @@ + qemu64 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list