From patchwork Mon Jan 12 10:49:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Shah X-Patchwork-Id: 1855 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 n0CAjomc004420 for ; Mon, 12 Jan 2009 02:45:51 -0800 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750986AbZALKtq (ORCPT ); Mon, 12 Jan 2009 05:49:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752148AbZALKtq (ORCPT ); Mon, 12 Jan 2009 05:49:46 -0500 Received: from hera.kernel.org ([140.211.167.34]:32958 "EHLO hera.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752247AbZALKto (ORCPT ); Mon, 12 Jan 2009 05:49:44 -0500 Received: from hera.kernel.org (IDENT:U2FsdGVkX19RhmijnZdDOBpsz4RlxD3nelfPCoC/cDQ@localhost [127.0.0.1]) by hera.kernel.org (8.14.2/8.14.2) with ESMTP id n0CAnTdR013431 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 12 Jan 2009 10:49:29 GMT Received: (from amit@localhost) by hera.kernel.org (8.14.2/8.13.1/Submit) id n0CAnTjP013430; Mon, 12 Jan 2009 10:49:29 GMT From: Amit Shah To: avi@redhat.com Cc: kvm@vger.kernel.org, Amit Shah Subject: [PATCH] KVM: x86: Store multiple cpuid entries for a single function Date: Mon, 12 Jan 2009 10:49:25 +0000 Message-Id: <1231757365-15717-3-git-send-email-amit.shah@redhat.com> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1231757365-15717-2-git-send-email-amit.shah@redhat.com> References: <1231757365-15717-1-git-send-email-amit.shah@redhat.com> <1231757365-15717-2-git-send-email-amit.shah@redhat.com> X-Virus-Scanned: ClamAV 0.93.3/8853/Mon Jan 12 00:26:44 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]); Mon, 12 Jan 2009 10:49:31 +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 behave differently for different values of ECX. Store these values if userspace passes them. Signed-off-by: Amit Shah --- arch/x86/kvm/x86.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 06b44fb..8dc4b29 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1126,7 +1126,7 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, struct kvm_cpuid *cpuid, struct kvm_cpuid_entry __user *entries) { - int r, i; + int r, i, count; struct kvm_cpuid_entry *cpuid_entries; r = -E2BIG; @@ -1146,8 +1146,20 @@ static int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, vcpu->arch.cpuid_entries[i].ebx = cpuid_entries[i].ebx; vcpu->arch.cpuid_entries[i].ecx = cpuid_entries[i].ecx; vcpu->arch.cpuid_entries[i].edx = cpuid_entries[i].edx; - vcpu->arch.cpuid_entries[i].index = 0; - vcpu->arch.cpuid_entries[i].flags = 0; + switch (cpuid_entries[i].function) { + case 4: + case 0xb: + case 0xd: + vcpu->arch.cpuid_entries[i].index = count++; + vcpu->arch.cpuid_entries[i].flags = + KVM_CPUID_FLAG_SIGNIFICANT_INDEX; + break; + default: + vcpu->arch.cpuid_entries[i].index = 0; + vcpu->arch.cpuid_entries[i].flags = 0; + } + if (cpuid_entries[i].function != cpuid_entries[i+1].function) + count = 0; vcpu->arch.cpuid_entries[i].padding[0] = 0; vcpu->arch.cpuid_entries[i].padding[1] = 0; vcpu->arch.cpuid_entries[i].padding[2] = 0;