KVM: take kvm_lock for hardware_disable() during cpu hotplug
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Tue, 16 Nov 2010 08:35:02 +0000 (17:35 +0900)
committerAvi Kivity <avi@redhat.com>
Wed, 12 Jan 2011 09:29:28 +0000 (11:29 +0200)
In kvm_cpu_hotplug(), only CPU_STARTING case is protected by kvm_lock.
This patch adds missing protection for CPU_DYING case.

Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
virt/kvm/kvm_main.c

index 4023264c4cd5cccc33f1779b0c6c27e92a37e559..f69fca7a88b55116f1b43073612a1783924d084a 100644 (file)
@@ -2140,7 +2140,9 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val,
        case CPU_DYING:
                printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n",
                       cpu);
+               spin_lock(&kvm_lock);
                hardware_disable(NULL);
+               spin_unlock(&kvm_lock);
                break;
        case CPU_STARTING:
                printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n",