Skip to content

Commit

Permalink
KVM: nVMX: Release shadow vmcs
Browse files Browse the repository at this point in the history
Unmap vmcs12 and release the corresponding shadow vmcs

Signed-off-by: Abel Gordon <abelg@il.ibm.com>
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
Signed-off-by: Gleb Natapov <gleb@redhat.com>
  • Loading branch information
Abel Gordon authored and Gleb Natapov committed Apr 22, 2013
1 parent 8de4883 commit e7953d7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions arch/x86/kvm/vmx.c
Original file line number Diff line number Diff line change
Expand Up @@ -5607,6 +5607,12 @@ static int nested_vmx_check_permission(struct kvm_vcpu *vcpu)
return 1;
}

static inline void nested_release_vmcs12(struct vcpu_vmx *vmx)
{
kunmap(vmx->nested.current_vmcs12_page);
nested_release_page(vmx->nested.current_vmcs12_page);
}

/*
* Free whatever needs to be freed from vmx->nested when L1 goes down, or
* just stops using VMX.
Expand All @@ -5617,11 +5623,12 @@ static void free_nested(struct vcpu_vmx *vmx)
return;
vmx->nested.vmxon = false;
if (vmx->nested.current_vmptr != -1ull) {
kunmap(vmx->nested.current_vmcs12_page);
nested_release_page(vmx->nested.current_vmcs12_page);
nested_release_vmcs12(vmx);
vmx->nested.current_vmptr = -1ull;
vmx->nested.current_vmcs12 = NULL;
}
if (enable_shadow_vmcs)
free_vmcs(vmx->nested.current_shadow_vmcs);
/* Unpin physical memory we referred to in current vmcs02 */
if (vmx->nested.apic_access_page) {
nested_release_page(vmx->nested.apic_access_page);
Expand Down Expand Up @@ -5762,8 +5769,7 @@ static int handle_vmclear(struct kvm_vcpu *vcpu)
}

if (vmptr == vmx->nested.current_vmptr) {
kunmap(vmx->nested.current_vmcs12_page);
nested_release_page(vmx->nested.current_vmcs12_page);
nested_release_vmcs12(vmx);
vmx->nested.current_vmptr = -1ull;
vmx->nested.current_vmcs12 = NULL;
}
Expand Down Expand Up @@ -6045,10 +6051,8 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
skip_emulated_instruction(vcpu);
return 1;
}
if (vmx->nested.current_vmptr != -1ull) {
kunmap(vmx->nested.current_vmcs12_page);
nested_release_page(vmx->nested.current_vmcs12_page);
}
if (vmx->nested.current_vmptr != -1ull)
nested_release_vmcs12(vmx);

vmx->nested.current_vmptr = vmptr;
vmx->nested.current_vmcs12 = new_vmcs12;
Expand Down

0 comments on commit e7953d7

Please sign in to comment.