From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LWWpa-0002oy-GQ for qemu-devel@nongnu.org; Mon, 09 Feb 2009 09:09:50 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LWWpZ-0002oK-TN for qemu-devel@nongnu.org; Mon, 09 Feb 2009 09:09:50 -0500 Received: from [199.232.76.173] (port=51301 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LWWpZ-0002o9-ON for qemu-devel@nongnu.org; Mon, 09 Feb 2009 09:09:49 -0500 Received: from mx2.redhat.com ([66.187.237.31]:43158) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LWWpY-0000S1-K1 for qemu-devel@nongnu.org; Mon, 09 Feb 2009 09:09:49 -0500 From: Amit Shah Date: Mon, 9 Feb 2009 19:39:23 +0530 Message-Id: <1234188563-32163-4-git-send-email-amit.shah@redhat.com> In-Reply-To: <1234188563-32163-3-git-send-email-amit.shah@redhat.com> References: <1234188563-32163-1-git-send-email-amit.shah@redhat.com> <1234188563-32163-2-git-send-email-amit.shah@redhat.com> <1234188563-32163-3-git-send-email-amit.shah@redhat.com> Subject: [Qemu-devel] [PATCH] KVM: Get all cpuid values from function 2 Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: aliguori@us.ibm.com Cc: Amit Shah , qemu-devel@nongnu.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/target-i386/kvm.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) diff --git a/qemu/target-i386/kvm.c b/qemu/target-i386/kvm.c index a7ff14f..86745b1 100644 --- a/qemu/target-i386/kvm.c +++ b/qemu/target-i386/kvm.c @@ -51,6 +51,33 @@ int kvm_arch_init_vcpu(CPUState *env) struct kvm_cpuid_entry2 *c = &cpuid_data.entries[cpuid_i++]; switch (i) { + case 2: { + /* Keep reading function 2 till all the input is received */ + int times; + + cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx); + times = eax & 0xff; + + c->function = i; + c->flags |= KVM_CPUID_FLAG_STATEFUL_FUNC; + c->flags |= KVM_CPUID_FLAG_STATE_READ_NEXT; + c->eax = eax; + c->ebx = ebx; + c->ecx = ecx; + c->edx = edx; + + for (j = 1; j < times; ++j) { + cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx); + c->function = i; + c->flags |= KVM_CPUID_FLAG_STATEFUL_FUNC; + c->eax = eax; + c->ebx = ebx; + c->ecx = ecx; + c->edx = edx; + c = &cpuid_data.entries[++cpuid_i]; + } + break; + } case 4: case 0xb: case 0xd: -- 1.6.0.6