From patchwork Mon Feb 16 12:26:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 7446 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n1GCQW12018739 for ; Mon, 16 Feb 2009 12:26:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754406AbZBPM03 (ORCPT ); Mon, 16 Feb 2009 07:26:29 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754745AbZBPM03 (ORCPT ); Mon, 16 Feb 2009 07:26:29 -0500 Received: from mx2.redhat.com ([66.187.237.31]:51869 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754406AbZBPM02 (ORCPT ); Mon, 16 Feb 2009 07:26:28 -0500 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n1GCQSwB000997 for ; Mon, 16 Feb 2009 07:26:28 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n1GCQSZD009111; Mon, 16 Feb 2009 07:26:28 -0500 Received: from localhost (vpn-10-24.str.redhat.com [10.32.10.24]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n1GCQP4x000419; Mon, 16 Feb 2009 07:26:26 -0500 From: Amit Shah To: avi@redhat.com Cc: kvm@vger.kernel.org, Amit Shah Subject: [PATCH] kvm: userspace: Get all cpuid values from function 2 Date: Mon, 16 Feb 2009 17:56:41 +0530 Message-Id: <1234787201-25703-1-git-send-email-amit.shah@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org cpuid function 2 can have multiple values to describe cache behaviour. Loop till we have fetched all the values. Signed-off-by: Amit Shah --- qemu/qemu-kvm-x86.c | 27 +++++++++++++++++++++++++-- 1 files changed, 25 insertions(+), 2 deletions(-) diff --git a/qemu/qemu-kvm-x86.c b/qemu/qemu-kvm-x86.c index 5264015..9a175a8 100644 --- a/qemu/qemu-kvm-x86.c +++ b/qemu/qemu-kvm-x86.c @@ -538,7 +538,27 @@ int kvm_arch_qemu_init_env(CPUState *cenv) limit = copy.regs[R_EAX]; for (i = 0; i <= limit; ++i) { - if (i == 4 || i == 0xb || i == 0xd) { + switch (i) { + case 2: { + /* Keep reading function 2 till all the input is received */ + int times; + + do_cpuid_ent(&cpuid_ent[cpuid_nent], i, 0, ©); + times = cpuid_ent[cpuid_nent].eax & 0xff; + + cpuid_ent[cpuid_nent].flags |= KVM_CPUID_FLAG_STATEFUL_FUNC; + cpuid_ent[cpuid_nent].flags |= KVM_CPUID_FLAG_STATE_READ_NEXT; + + for (j = 1; j < times; ++j) { + do_cpuid_ent(&cpuid_ent[++cpuid_nent], i, 0, ©); + cpuid_ent[cpuid_nent].flags |= KVM_CPUID_FLAG_STATEFUL_FUNC; + } + cpuid_nent++; + break; + } + case 4: + case 0xb: + case 0xd: for (j = 0; ; ++j) { do_cpuid_ent(&cpuid_ent[cpuid_nent], i, j, ©); @@ -554,8 +574,11 @@ int kvm_arch_qemu_init_env(CPUState *cenv) if (i == 0xd && copy.regs[R_EAX] == 0) break; } - } else + break; + + default: do_cpuid_ent(&cpuid_ent[cpuid_nent++], i, 0, ©); + } } copy.regs[R_EAX] = 0x80000000;