Commit dee9c049 authored by KarimAllah Ahmed's avatar KarimAllah Ahmed Committed by Paolo Bonzini

KVM/nVMX: Use kvm_vcpu_map for accessing the enlightened VMCS

Use kvm_vcpu_map for accessing the enlightened VMCS since using
kvm_vcpu_gpa_to_page() and kmap() will only work for guest memory that has
a "struct page".
Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 88925305
...@@ -193,10 +193,8 @@ static inline void nested_release_evmcs(struct kvm_vcpu *vcpu) ...@@ -193,10 +193,8 @@ static inline void nested_release_evmcs(struct kvm_vcpu *vcpu)
if (!vmx->nested.hv_evmcs) if (!vmx->nested.hv_evmcs)
return; return;
kunmap(vmx->nested.hv_evmcs_page); kvm_vcpu_unmap(vcpu, &vmx->nested.hv_evmcs_map, true);
kvm_release_page_dirty(vmx->nested.hv_evmcs_page);
vmx->nested.hv_evmcs_vmptr = -1ull; vmx->nested.hv_evmcs_vmptr = -1ull;
vmx->nested.hv_evmcs_page = NULL;
vmx->nested.hv_evmcs = NULL; vmx->nested.hv_evmcs = NULL;
} }
...@@ -1786,13 +1784,11 @@ static int nested_vmx_handle_enlightened_vmptrld(struct kvm_vcpu *vcpu, ...@@ -1786,13 +1784,11 @@ static int nested_vmx_handle_enlightened_vmptrld(struct kvm_vcpu *vcpu,
nested_release_evmcs(vcpu); nested_release_evmcs(vcpu);
vmx->nested.hv_evmcs_page = kvm_vcpu_gpa_to_page( if (kvm_vcpu_map(vcpu, gpa_to_gfn(assist_page.current_nested_vmcs),
vcpu, assist_page.current_nested_vmcs); &vmx->nested.hv_evmcs_map))
if (unlikely(is_error_page(vmx->nested.hv_evmcs_page)))
return 0; return 0;
vmx->nested.hv_evmcs = kmap(vmx->nested.hv_evmcs_page); vmx->nested.hv_evmcs = vmx->nested.hv_evmcs_map.hva;
/* /*
* Currently, KVM only supports eVMCS version 1 * Currently, KVM only supports eVMCS version 1
...@@ -4350,7 +4346,7 @@ static int handle_vmclear(struct kvm_vcpu *vcpu) ...@@ -4350,7 +4346,7 @@ static int handle_vmclear(struct kvm_vcpu *vcpu)
return nested_vmx_failValid(vcpu, return nested_vmx_failValid(vcpu,
VMXERR_VMCLEAR_VMXON_POINTER); VMXERR_VMCLEAR_VMXON_POINTER);
if (vmx->nested.hv_evmcs_page) { if (vmx->nested.hv_evmcs_map.hva) {
if (vmptr == vmx->nested.hv_evmcs_vmptr) if (vmptr == vmx->nested.hv_evmcs_vmptr)
nested_release_evmcs(vcpu); nested_release_evmcs(vcpu);
} else { } else {
......
...@@ -172,7 +172,7 @@ struct nested_vmx { ...@@ -172,7 +172,7 @@ struct nested_vmx {
} smm; } smm;
gpa_t hv_evmcs_vmptr; gpa_t hv_evmcs_vmptr;
struct page *hv_evmcs_page; struct kvm_host_map hv_evmcs_map;
struct hv_enlightened_vmcs *hv_evmcs; struct hv_enlightened_vmcs *hv_evmcs;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment