aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 7b27af9a14d8..ad3957e5f2e8 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5607,6 +5607,12 @@ static int nested_vmx_check_permission(struct kvm_vcpu *vcpu)
5607 return 1; 5607 return 1;
5608} 5608}
5609 5609
5610static inline void nested_release_vmcs12(struct vcpu_vmx *vmx)
5611{
5612 kunmap(vmx->nested.current_vmcs12_page);
5613 nested_release_page(vmx->nested.current_vmcs12_page);
5614}
5615
5610/* 5616/*
5611 * Free whatever needs to be freed from vmx->nested when L1 goes down, or 5617 * Free whatever needs to be freed from vmx->nested when L1 goes down, or
5612 * just stops using VMX. 5618 * just stops using VMX.
@@ -5617,11 +5623,12 @@ static void free_nested(struct vcpu_vmx *vmx)
5617 return; 5623 return;
5618 vmx->nested.vmxon = false; 5624 vmx->nested.vmxon = false;
5619 if (vmx->nested.current_vmptr != -1ull) { 5625 if (vmx->nested.current_vmptr != -1ull) {
5620 kunmap(vmx->nested.current_vmcs12_page); 5626 nested_release_vmcs12(vmx);
5621 nested_release_page(vmx->nested.current_vmcs12_page);
5622 vmx->nested.current_vmptr = -1ull; 5627 vmx->nested.current_vmptr = -1ull;
5623 vmx->nested.current_vmcs12 = NULL; 5628 vmx->nested.current_vmcs12 = NULL;
5624 } 5629 }
5630 if (enable_shadow_vmcs)
5631 free_vmcs(vmx->nested.current_shadow_vmcs);
5625 /* Unpin physical memory we referred to in current vmcs02 */ 5632 /* Unpin physical memory we referred to in current vmcs02 */
5626 if (vmx->nested.apic_access_page) { 5633 if (vmx->nested.apic_access_page) {
5627 nested_release_page(vmx->nested.apic_access_page); 5634 nested_release_page(vmx->nested.apic_access_page);
@@ -5762,8 +5769,7 @@ static int handle_vmclear(struct kvm_vcpu *vcpu)
5762 } 5769 }
5763 5770
5764 if (vmptr == vmx->nested.current_vmptr) { 5771 if (vmptr == vmx->nested.current_vmptr) {
5765 kunmap(vmx->nested.current_vmcs12_page); 5772 nested_release_vmcs12(vmx);
5766 nested_release_page(vmx->nested.current_vmcs12_page);
5767 vmx->nested.current_vmptr = -1ull; 5773 vmx->nested.current_vmptr = -1ull;
5768 vmx->nested.current_vmcs12 = NULL; 5774 vmx->nested.current_vmcs12 = NULL;
5769 } 5775 }
@@ -6045,10 +6051,8 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
6045 skip_emulated_instruction(vcpu); 6051 skip_emulated_instruction(vcpu);
6046 return 1; 6052 return 1;
6047 } 6053 }
6048 if (vmx->nested.current_vmptr != -1ull) { 6054 if (vmx->nested.current_vmptr != -1ull)
6049 kunmap(vmx->nested.current_vmcs12_page); 6055 nested_release_vmcs12(vmx);
6050 nested_release_page(vmx->nested.current_vmcs12_page);
6051 }
6052 6056
6053 vmx->nested.current_vmptr = vmptr; 6057 vmx->nested.current_vmptr = vmptr;
6054 vmx->nested.current_vmcs12 = new_vmcs12; 6058 vmx->nested.current_vmcs12 = new_vmcs12;