public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix unlikely kvm_create vs decache_vcpus_on_cpu race
@ 2007-07-23  7:08 Rusty Russell
       [not found] ` <1185174501.6344.138.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Rusty Russell @ 2007-07-23  7:08 UTC (permalink / raw)
  To: kvm-devel

We add the kvm to the vm_list before initializing the vcpu mutexes,
which can be mutex_trylock()'ed by decache_vcpus_on_cpu().

Signed-off-by: Rusty Russell <rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>

diff -r b0134ad0aebe drivers/kvm/kvm_main.c
--- a/drivers/kvm/kvm_main.c	Thu Jul 19 16:37:12 2007 +1000
+++ b/drivers/kvm/kvm_main.c	Thu Jul 19 16:42:26 2007 +1000
@@ -310,9 +310,6 @@ static struct kvm *kvm_create_vm(void)
 	kvm_io_bus_init(&kvm->pio_bus);
 	spin_lock_init(&kvm->lock);
 	INIT_LIST_HEAD(&kvm->active_mmu_pages);
-	spin_lock(&kvm_lock);
-	list_add(&kvm->vm_list, &vm_list);
-	spin_unlock(&kvm_lock);
 	kvm_io_bus_init(&kvm->mmio_bus);
 	for (i = 0; i < KVM_MAX_VCPUS; ++i) {
 		struct kvm_vcpu *vcpu = &kvm->vcpus[i];
@@ -322,6 +319,9 @@ static struct kvm *kvm_create_vm(void)
 		vcpu->kvm = kvm;
 		vcpu->mmu.root_hpa = INVALID_PAGE;
 	}
+	spin_lock(&kvm_lock);
+	list_add(&kvm->vm_list, &vm_list);
+	spin_unlock(&kvm_lock);
 	return kvm;
 }
 



-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix unlikely kvm_create vs decache_vcpus_on_cpu race
       [not found] ` <1185174501.6344.138.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
@ 2007-07-23  8:18   ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2007-07-23  8:18 UTC (permalink / raw)
  To: Rusty Russell; +Cc: kvm-devel

Rusty Russell wrote:
> We add the kvm to the vm_list before initializing the vcpu mutexes,
> which can be mutex_trylock()'ed by decache_vcpus_on_cpu().
>   

Applied this as well as the next one.

Good to see a thorough non-CodingStyle review of the entire code base -- 
thanks!

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-23  8:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-23  7:08 [PATCH] Fix unlikely kvm_create vs decache_vcpus_on_cpu race Rusty Russell
     [not found] ` <1185174501.6344.138.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-07-23  8:18   ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox