From mboxrd@z Thu Jan 1 00:00:00 1970 From: Muli Ben-Yehuda Subject: Re: [PATCH] KVM: x86: Store multiple cpuid entries for a single function Date: Mon, 12 Jan 2009 22:39:31 +0200 Message-ID: <20090112203931.GC13839@il.ibm.com> References: <1231757365-15717-1-git-send-email-amit.shah@redhat.com> <1231757365-15717-2-git-send-email-amit.shah@redhat.com> <1231757365-15717-3-git-send-email-amit.shah@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, kvm@vger.kernel.org To: Amit Shah Return-path: Received: from mtagate2.uk.ibm.com ([194.196.100.162]:59008 "EHLO mtagate2.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbZALUkM (ORCPT ); Mon, 12 Jan 2009 15:40:12 -0500 Received: from d06nrmr1407.portsmouth.uk.ibm.com (d06nrmr1407.portsmouth.uk.ibm.com [9.149.38.185]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id n0CKeAW8017688 for ; Mon, 12 Jan 2009 20:40:10 GMT Received: from d06av03.portsmouth.uk.ibm.com (d06av03.portsmouth.uk.ibm.com [9.149.37.213]) by d06nrmr1407.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v9.1) with ESMTP id n0CKeAPD2883722 for ; Mon, 12 Jan 2009 20:40:10 GMT Received: from d06av03.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av03.portsmouth.uk.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n0CKeAVP007594 for ; Mon, 12 Jan 2009 20:40:10 GMT Content-Disposition: inline In-Reply-To: <1231757365-15717-3-git-send-email-amit.shah@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Jan 12, 2009 at 10:49:25AM +0000, Amit Shah wrote: > 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++; Isn't this using count uninitialized? Cheers, Muli -- SYSTOR 2009---The Israeli Experimental Systems Conference May 4-6, 2009, Haifa, Israel http://www.haifa.il.ibm.com/conferences/systor2009/