diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-03 16:43:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-08-03 16:43:59 -0400 |
commit | 0b5b1f9a78b5e1bb3c3972fcd27dc013367550f8 (patch) | |
tree | 13aa83993f5119ae70b19023abcecb594b5aa612 | |
parent | f6229c395874a37ea72137337242055dcaf30112 (diff) | |
parent | 63aff65573d73eb8dda4732ad4ef222dd35e4862 (diff) |
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull KVM fixes from Paolo Bonzini:
"Two vmx bugfixes"
* tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
kvm: x86: vmx: fix vpid leak
KVM: vmx: use local variable for current_vmptr when emulating VMPTRST
-rw-r--r-- | arch/x86/kvm/vmx.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index e30da9a2430c..5d8e317c2b04 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -7893,6 +7893,8 @@ static int enter_vmx_operation(struct kvm_vcpu *vcpu) | |||
7893 | HRTIMER_MODE_REL_PINNED); | 7893 | HRTIMER_MODE_REL_PINNED); |
7894 | vmx->nested.preemption_timer.function = vmx_preemption_timer_fn; | 7894 | vmx->nested.preemption_timer.function = vmx_preemption_timer_fn; |
7895 | 7895 | ||
7896 | vmx->nested.vpid02 = allocate_vpid(); | ||
7897 | |||
7896 | vmx->nested.vmxon = true; | 7898 | vmx->nested.vmxon = true; |
7897 | return 0; | 7899 | return 0; |
7898 | 7900 | ||
@@ -8480,21 +8482,20 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu) | |||
8480 | /* Emulate the VMPTRST instruction */ | 8482 | /* Emulate the VMPTRST instruction */ |
8481 | static int handle_vmptrst(struct kvm_vcpu *vcpu) | 8483 | static int handle_vmptrst(struct kvm_vcpu *vcpu) |
8482 | { | 8484 | { |
8483 | unsigned long exit_qualification = vmcs_readl(EXIT_QUALIFICATION); | 8485 | unsigned long exit_qual = vmcs_readl(EXIT_QUALIFICATION); |
8484 | u32 vmx_instruction_info = vmcs_read32(VMX_INSTRUCTION_INFO); | 8486 | u32 instr_info = vmcs_read32(VMX_INSTRUCTION_INFO); |
8485 | gva_t vmcs_gva; | 8487 | gpa_t current_vmptr = to_vmx(vcpu)->nested.current_vmptr; |
8486 | struct x86_exception e; | 8488 | struct x86_exception e; |
8489 | gva_t gva; | ||
8487 | 8490 | ||
8488 | if (!nested_vmx_check_permission(vcpu)) | 8491 | if (!nested_vmx_check_permission(vcpu)) |
8489 | return 1; | 8492 | return 1; |
8490 | 8493 | ||
8491 | if (get_vmx_mem_address(vcpu, exit_qualification, | 8494 | if (get_vmx_mem_address(vcpu, exit_qual, instr_info, true, &gva)) |
8492 | vmx_instruction_info, true, &vmcs_gva)) | ||
8493 | return 1; | 8495 | return 1; |
8494 | /* *_system ok, nested_vmx_check_permission has verified cpl=0 */ | 8496 | /* *_system ok, nested_vmx_check_permission has verified cpl=0 */ |
8495 | if (kvm_write_guest_virt_system(vcpu, vmcs_gva, | 8497 | if (kvm_write_guest_virt_system(vcpu, gva, (void *)¤t_vmptr, |
8496 | (void *)&to_vmx(vcpu)->nested.current_vmptr, | 8498 | sizeof(gpa_t), &e)) { |
8497 | sizeof(u64), &e)) { | ||
8498 | kvm_inject_page_fault(vcpu, &e); | 8499 | kvm_inject_page_fault(vcpu, &e); |
8499 | return 1; | 8500 | return 1; |
8500 | } | 8501 | } |
@@ -10370,11 +10371,9 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) | |||
10370 | goto free_vmcs; | 10371 | goto free_vmcs; |
10371 | } | 10372 | } |
10372 | 10373 | ||
10373 | if (nested) { | 10374 | if (nested) |
10374 | nested_vmx_setup_ctls_msrs(&vmx->nested.msrs, | 10375 | nested_vmx_setup_ctls_msrs(&vmx->nested.msrs, |
10375 | kvm_vcpu_apicv_active(&vmx->vcpu)); | 10376 | kvm_vcpu_apicv_active(&vmx->vcpu)); |
10376 | vmx->nested.vpid02 = allocate_vpid(); | ||
10377 | } | ||
10378 | 10377 | ||
10379 | vmx->nested.posted_intr_nv = -1; | 10378 | vmx->nested.posted_intr_nv = -1; |
10380 | vmx->nested.current_vmptr = -1ull; | 10379 | vmx->nested.current_vmptr = -1ull; |
@@ -10391,7 +10390,6 @@ static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id) | |||
10391 | return &vmx->vcpu; | 10390 | return &vmx->vcpu; |
10392 | 10391 | ||
10393 | free_vmcs: | 10392 | free_vmcs: |
10394 | free_vpid(vmx->nested.vpid02); | ||
10395 | free_loaded_vmcs(vmx->loaded_vmcs); | 10393 | free_loaded_vmcs(vmx->loaded_vmcs); |
10396 | free_msrs: | 10394 | free_msrs: |
10397 | kfree(vmx->guest_msrs); | 10395 | kfree(vmx->guest_msrs); |