From patchwork Tue Jan 13 07:09:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 2090 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 n0D75WN3003201 for ; Mon, 12 Jan 2009 23:05:32 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752241AbZAMHJa (ORCPT ); Tue, 13 Jan 2009 02:09:30 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752460AbZAMHJa (ORCPT ); Tue, 13 Jan 2009 02:09:30 -0500 Received: from hera.kernel.org ([140.211.167.34]:36832 "EHLO hera.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752241AbZAMHJ3 (ORCPT ); Tue, 13 Jan 2009 02:09:29 -0500 Received: from hera.kernel.org (IDENT:U2FsdGVkX1/yf3qmY7C2HhGCwYM9g77N42OcNdOaBkU@localhost [127.0.0.1]) by hera.kernel.org (8.14.2/8.14.2) with ESMTP id n0D799YZ002331 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 13 Jan 2009 07:09:09 GMT Received: (from amit@localhost) by hera.kernel.org (8.14.2/8.13.1/Submit) id n0D7993w002330; Tue, 13 Jan 2009 07:09:09 GMT From: Amit Shah To: qemu-devel@nongnu.org Cc: avi@redhat.com, kvm@vger.kernel.org, aliguori@us.ibm.com, Amit Shah Subject: [PATCH] KVM: Fetch sub-leaf cpuid values for functions 4, 0xb, 0xd. Date: Tue, 13 Jan 2009 07:09:05 +0000 Message-Id: <1231830545-1788-3-git-send-email-amit.shah@redhat.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1231830545-1788-2-git-send-email-amit.shah@redhat.com> References: <1231830545-1788-1-git-send-email-amit.shah@redhat.com> <1231830545-1788-2-git-send-email-amit.shah@redhat.com> X-Virus-Scanned: ClamAV 0.93.3/8856/Mon Jan 12 16:36:19 2009 on hera.kernel.org X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on hera.kernel.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (hera.kernel.org [127.0.0.1]); Tue, 13 Jan 2009 07:09:11 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org CPUID functions 4, 0xb and 0xd have sub-leaf values which depend on the input value of ECX. Store these values as well. Signed-off-by: Amit Shah --- qemu/target-i386/kvm.c | 34 ++++++++++++++++++++++++++-------- 1 files changed, 26 insertions(+), 8 deletions(-) diff --git a/qemu/target-i386/kvm.c b/qemu/target-i386/kvm.c index bef3150..c17e58b 100644 --- a/qemu/target-i386/kvm.c +++ b/qemu/target-i386/kvm.c @@ -39,7 +39,7 @@ int kvm_arch_init_vcpu(CPUState *env) struct kvm_cpuid cpuid; struct kvm_cpuid_entry entries[100]; } __attribute__((packed)) cpuid_data; - uint32_t limit, i, cpuid_i; + uint32_t limit, i, j, cpuid_i; uint32_t eax, ebx, ecx, edx; cpuid_i = 0; @@ -50,14 +50,32 @@ int kvm_arch_init_vcpu(CPUState *env) for (i = 0; i <= limit; i++) { struct kvm_cpuid_entry *c = &cpuid_data.entries[cpuid_i++]; - cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx); - c->function = i; - c->eax = eax; - c->ebx = ebx; - c->ecx = ecx; - c->edx = edx; + if (i == 4 || i == 0xb || i == 0xd) { + for (j = 0; ; j++) { + cpu_x86_cpuid(env, i, j, &eax, &ebx, &ecx, &edx); + c->function = i; + c->eax = eax; + c->ebx = ebx; + c->ecx = ecx; + c->edx = edx; + c = &cpuid_data.entries[++cpuid_i]; + + if (i == 4 && eax == 0) + break; + if (i == 0xb && !(ecx & 0xff00)) + break; + if (i == 0xd && eax == 0) + break; + } + } else { + cpu_x86_cpuid(env, i, 0, &eax, &ebx, &ecx, &edx); + c->function = i; + c->eax = eax; + c->ebx = ebx; + c->ecx = ecx; + c->edx = edx; + } } - cpu_x86_cpuid(env, 0x80000000, 0, &eax, &ebx, &ecx, &edx); limit = eax;