Commit 2e408936 authored by KarimAllah Ahmed's avatar KarimAllah Ahmed Committed by Paolo Bonzini

X86/nVMX: handle_vmon: Read 4 bytes from guest memory

Read the data directly from guest memory instead of the map->read->unmap
sequence. This also avoids using kvm_vcpu_gpa_to_page() and kmap() which
assumes that there is a "struct page" for guest memory.
Suggested-by: default avatarJim Mattson <jmattson@google.com>
Signed-off-by: default avatarKarimAllah Ahmed <karahmed@amazon.de>
Reviewed-by: default avatarJim Mattson <jmattson@google.com>
Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
Reviewed-by: default avatarKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 191c8137
...@@ -4264,7 +4264,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu) ...@@ -4264,7 +4264,7 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
{ {
int ret; int ret;
gpa_t vmptr; gpa_t vmptr;
struct page *page; uint32_t revision;
struct vcpu_vmx *vmx = to_vmx(vcpu); struct vcpu_vmx *vmx = to_vmx(vcpu);
const u64 VMXON_NEEDED_FEATURES = FEATURE_CONTROL_LOCKED const u64 VMXON_NEEDED_FEATURES = FEATURE_CONTROL_LOCKED
| FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX; | FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX;
...@@ -4313,18 +4313,10 @@ static int handle_vmon(struct kvm_vcpu *vcpu) ...@@ -4313,18 +4313,10 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
if (!PAGE_ALIGNED(vmptr) || (vmptr >> cpuid_maxphyaddr(vcpu))) if (!PAGE_ALIGNED(vmptr) || (vmptr >> cpuid_maxphyaddr(vcpu)))
return nested_vmx_failInvalid(vcpu); return nested_vmx_failInvalid(vcpu);
page = kvm_vcpu_gpa_to_page(vcpu, vmptr); if (kvm_read_guest(vcpu->kvm, vmptr, &revision, sizeof(revision)) ||
if (is_error_page(page)) revision != VMCS12_REVISION)
return nested_vmx_failInvalid(vcpu); return nested_vmx_failInvalid(vcpu);
if (*(u32 *)kmap(page) != VMCS12_REVISION) {
kunmap(page);
kvm_release_page_clean(page);
return nested_vmx_failInvalid(vcpu);
}
kunmap(page);
kvm_release_page_clean(page);
vmx->nested.vmxon_ptr = vmptr; vmx->nested.vmxon_ptr = vmptr;
ret = enter_vmx_operation(vcpu); ret = enter_vmx_operation(vcpu);
if (ret) if (ret)
......
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