From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 3/3] kvm common: verify that cpu slot is available when creating new vcpu Date: Sun, 8 Feb 2009 04:26:16 -0200 Message-ID: <20090208062616.GD4437@amt.cnet> References: <20090205170124.46fee96b@cotte.boeblingen.de.ibm.com> <20090205170501.2a964172@cotte.boeblingen.de.ibm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Avi Kivity , KVM mailing list To: Carsten Otte Return-path: Received: from mx2.redhat.com ([66.187.237.31]:55942 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751591AbZBHG0t (ORCPT ); Sun, 8 Feb 2009 01:26:49 -0500 Content-Disposition: inline In-Reply-To: <20090205170501.2a964172@cotte.boeblingen.de.ibm.com> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, Feb 05, 2009 at 05:05:01PM +0100, Carsten Otte wrote: > KVM common code should'nt try to create the same virtual cpu twice. > In case of s390, it crashes badly in kvm_arch_vcpu_create. > > Reported-by: Mijo Safradin > Signed-off-by: Carsten Otte > --- > virt/kvm/kvm_main.c | 3 +++ > 1 file changed, 3 insertions(+) > > Index: kvm/virt/kvm/kvm_main.c > =================================================================== > --- kvm.orig/virt/kvm/kvm_main.c > +++ kvm/virt/kvm/kvm_main.c > @@ -1605,6 +1605,9 @@ static int kvm_vm_ioctl_create_vcpu(stru > if (!valid_vcpu(n)) > return -EINVAL; > > + if (kvm->vcpus[i]) > + return -EEXIST; > + > vcpu = kvm_arch_vcpu_create(kvm, n); > if (IS_ERR(vcpu)) > return PTR_ERR(vcpu); Its confusing that there is the exact same check below, with kvm->lock held, and that both are needed since assignment happens under the lock. Can you also make it straightforward while fixing the bug please. Probably just hold it all the way through kvm_vm_ioctl_create_vcpu? Or is that not possible?