aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c26
1 files changed, 5 insertions, 21 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 65c9a31f1d9..bf8b8f03019 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -367,7 +367,7 @@ static void free_pio_guest_pages(struct kvm_vcpu *vcpu)
367 367
368static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu) 368static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
369{ 369{
370 if (!vcpu->vmcs) 370 if (!vcpu->valid)
371 return; 371 return;
372 372
373 vcpu_load(vcpu); 373 vcpu_load(vcpu);
@@ -377,7 +377,7 @@ static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
377 377
378static void kvm_free_vcpu(struct kvm_vcpu *vcpu) 378static void kvm_free_vcpu(struct kvm_vcpu *vcpu)
379{ 379{
380 if (!vcpu->vmcs) 380 if (!vcpu->valid)
381 return; 381 return;
382 382
383 vcpu_load(vcpu); 383 vcpu_load(vcpu);
@@ -1645,24 +1645,6 @@ void kvm_resched(struct kvm_vcpu *vcpu)
1645} 1645}
1646EXPORT_SYMBOL_GPL(kvm_resched); 1646EXPORT_SYMBOL_GPL(kvm_resched);
1647 1647
1648void load_msrs(struct vmx_msr_entry *e, int n)
1649{
1650 int i;
1651
1652 for (i = 0; i < n; ++i)
1653 wrmsrl(e[i].index, e[i].data);
1654}
1655EXPORT_SYMBOL_GPL(load_msrs);
1656
1657void save_msrs(struct vmx_msr_entry *e, int n)
1658{
1659 int i;
1660
1661 for (i = 0; i < n; ++i)
1662 rdmsrl(e[i].index, e[i].data);
1663}
1664EXPORT_SYMBOL_GPL(save_msrs);
1665
1666void kvm_emulate_cpuid(struct kvm_vcpu *vcpu) 1648void kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
1667{ 1649{
1668 int i; 1650 int i;
@@ -2401,7 +2383,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
2401 2383
2402 mutex_lock(&vcpu->mutex); 2384 mutex_lock(&vcpu->mutex);
2403 2385
2404 if (vcpu->vmcs) { 2386 if (vcpu->valid) {
2405 mutex_unlock(&vcpu->mutex); 2387 mutex_unlock(&vcpu->mutex);
2406 return -EEXIST; 2388 return -EEXIST;
2407 } 2389 }
@@ -2449,6 +2431,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n)
2449 kvm->nvcpus = n + 1; 2431 kvm->nvcpus = n + 1;
2450 spin_unlock(&kvm_lock); 2432 spin_unlock(&kvm_lock);
2451 2433
2434 vcpu->valid = 1;
2435
2452 return r; 2436 return r;
2453 2437
2454out_free_vcpus: 2438out_free_vcpus: