diff options
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r-- | arch/x86/kvm/vmx.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index ad36447e696e..94ea724638fd 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -638,6 +638,7 @@ static void setup_msrs(struct vcpu_vmx *vmx) | |||
638 | { | 638 | { |
639 | int save_nmsrs; | 639 | int save_nmsrs; |
640 | 640 | ||
641 | vmx_load_host_state(vmx); | ||
641 | save_nmsrs = 0; | 642 | save_nmsrs = 0; |
642 | #ifdef CONFIG_X86_64 | 643 | #ifdef CONFIG_X86_64 |
643 | if (is_long_mode(&vmx->vcpu)) { | 644 | if (is_long_mode(&vmx->vcpu)) { |
@@ -1477,7 +1478,7 @@ static int alloc_apic_access_page(struct kvm *kvm) | |||
1477 | struct kvm_userspace_memory_region kvm_userspace_mem; | 1478 | struct kvm_userspace_memory_region kvm_userspace_mem; |
1478 | int r = 0; | 1479 | int r = 0; |
1479 | 1480 | ||
1480 | down_write(¤t->mm->mmap_sem); | 1481 | down_write(&kvm->slots_lock); |
1481 | if (kvm->arch.apic_access_page) | 1482 | if (kvm->arch.apic_access_page) |
1482 | goto out; | 1483 | goto out; |
1483 | kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT; | 1484 | kvm_userspace_mem.slot = APIC_ACCESS_PAGE_PRIVATE_MEMSLOT; |
@@ -1487,9 +1488,12 @@ static int alloc_apic_access_page(struct kvm *kvm) | |||
1487 | r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); | 1488 | r = __kvm_set_memory_region(kvm, &kvm_userspace_mem, 0); |
1488 | if (r) | 1489 | if (r) |
1489 | goto out; | 1490 | goto out; |
1491 | |||
1492 | down_read(¤t->mm->mmap_sem); | ||
1490 | kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00); | 1493 | kvm->arch.apic_access_page = gfn_to_page(kvm, 0xfee00); |
1494 | up_read(¤t->mm->mmap_sem); | ||
1491 | out: | 1495 | out: |
1492 | up_write(¤t->mm->mmap_sem); | 1496 | up_write(&kvm->slots_lock); |
1493 | return r; | 1497 | return r; |
1494 | } | 1498 | } |
1495 | 1499 | ||
@@ -1602,9 +1606,6 @@ static int vmx_vcpu_setup(struct vcpu_vmx *vmx) | |||
1602 | vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL); | 1606 | vmcs_writel(CR0_GUEST_HOST_MASK, ~0UL); |
1603 | vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK); | 1607 | vmcs_writel(CR4_GUEST_HOST_MASK, KVM_GUEST_CR4_MASK); |
1604 | 1608 | ||
1605 | if (vm_need_virtualize_apic_accesses(vmx->vcpu.kvm)) | ||
1606 | if (alloc_apic_access_page(vmx->vcpu.kvm) != 0) | ||
1607 | return -ENOMEM; | ||
1608 | 1609 | ||
1609 | return 0; | 1610 | return 0; |
1610 | } | 1611 | } |
@@ -2534,6 +2535,9 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) | |||
2534 | put_cpu(); | 2535 | put_cpu(); |
2535 | if (err) | 2536 | if (err) |
2536 | goto free_vmcs; | 2537 | goto free_vmcs; |
2538 | if (vm_need_virtualize_apic_accesses(kvm)) | ||
2539 | if (alloc_apic_access_page(kvm) != 0) | ||
2540 | goto free_vmcs; | ||
2537 | 2541 | ||
2538 | return &vmx->vcpu; | 2542 | return &vmx->vcpu; |
2539 | 2543 | ||