From nobody Sun Feb 8 17:37:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) client-ip=209.132.183.25; envelope-from=libvir-list-bounces@redhat.com; helo=mx4-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.25 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by mx.zohomail.com with SMTPS id 1487801459870382.0534742576275; Wed, 22 Feb 2017 14:10:59 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MM7NtQ001418; Wed, 22 Feb 2017 17:07:23 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1MM7MIt030728 for ; Wed, 22 Feb 2017 17:07:22 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4E8DA1587B; Wed, 22 Feb 2017 22:07:22 +0000 (UTC) Received: from localhost (ovpn-116-33.gru2.redhat.com [10.97.116.33]) by smtp.corp.redhat.com (Postfix) with ESMTP id D37C02D654; Wed, 22 Feb 2017 22:07:21 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Wed, 22 Feb 2017 19:07:07 -0300 Message-Id: <20170222220709.3707-2-ehabkost@redhat.com> In-Reply-To: <20170222220709.3707-1-ehabkost@redhat.com> References: <20170222220709.3707-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: libvir-list@redhat.com Cc: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/3] i386: host_vendor_fms() helper 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Helper function for code that needs to check the host CPU vendor/family/model/stepping values. Signed-off-by: Eduardo Habkost --- Changes v1 -> v2: * Coding style fix (split long lines) --- target/i386/cpu.h | 1 + target/i386/cpu.c | 29 +++++++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 5f75ab1b15..647435a1d9 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1431,6 +1431,7 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, = uint32_t count, void cpu_clear_apic_feature(CPUX86State *env); void host_cpuid(uint32_t function, uint32_t count, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx= ); +void host_vendor_fms(char *vendor, int *family, int *model, int *stepping); =20 /* helper.c */ int x86_cpu_handle_mmu_fault(CPUState *cpu, vaddr addr, diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 7a04e6ff34..a8e4f37e27 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -682,6 +682,25 @@ void host_cpuid(uint32_t function, uint32_t count, *edx =3D vec[3]; } =20 +void host_vendor_fms(char *vendor, int *family, int *model, int *stepping) +{ + uint32_t eax, ebx, ecx, edx; + + host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); + x86_cpu_vendor_words2str(vendor, ebx, edx, ecx); + + host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); + if (family) { + *family =3D ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); + } + if (model) { + *model =3D ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12); + } + if (stepping) { + *stepping =3D eax & 0x0F; + } +} + /* CPU class name definitions: */ =20 #define X86_CPU_TYPE_SUFFIX "-" TYPE_X86_CPU @@ -1547,18 +1566,12 @@ static void host_x86_cpu_class_init(ObjectClass *oc= , void *data) { DeviceClass *dc =3D DEVICE_CLASS(oc); X86CPUClass *xcc =3D X86_CPU_CLASS(oc); - uint32_t eax =3D 0, ebx =3D 0, ecx =3D 0, edx =3D 0; =20 xcc->kvm_required =3D true; xcc->ordering =3D 9; =20 - host_cpuid(0x0, 0, &eax, &ebx, &ecx, &edx); - x86_cpu_vendor_words2str(host_cpudef.vendor, ebx, edx, ecx); - - host_cpuid(0x1, 0, &eax, &ebx, &ecx, &edx); - host_cpudef.family =3D ((eax >> 8) & 0x0F) + ((eax >> 20) & 0xFF); - host_cpudef.model =3D ((eax >> 4) & 0x0F) | ((eax & 0xF0000) >> 12); - host_cpudef.stepping =3D eax & 0x0F; + host_vendor_fms(host_cpudef.vendor, &host_cpudef.family, + &host_cpudef.model, &host_cpudef.stepping); =20 cpu_x86_fill_model_id(host_cpudef.model_id); =20 --=20 2.11.0.259.g40922b1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list