summaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/vmx.c
diff options
context:
space:
mode:
authorJim Mattson <jmattson@google.com>2017-03-15 07:40:55 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2018-11-27 12:55:46 +0100
commitfca91f6d60b6ee53b8d43c8ad5bad153a758961c (patch)
tree571227308aa6ecedc77e8f75d2580f7e5c9a2d67 /arch/x86/kvm/vmx.c
parent14aa61d0a9eb3ddad06c3a0033f88b5fa7f05613 (diff)
downloadlinux-fca91f6d60b6ee53b8d43c8ad5bad153a758961c.tar.bz2
kvm: nVMX: Set VM instruction error for VMPTRLD of unbacked page
It is never correct for a VMX instruction to fail with "invalid VMCS" if there is, in fact, a current VMCS. Reads from unbacked addresses return all 1's, which means that an unbacked VMCS will not have the correct VMCS revision ID (i.e. VMCS12_REVISION). Fixes: 63846663eac78 ("KVM: nVMX: Implement VMPTRLD") Signed-off-by: Jim Mattson <jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r--arch/x86/kvm/vmx.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index d78fe0abf9ac..c379d0bfdcba 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -9318,9 +9318,17 @@ static int handle_vmptrld(struct kvm_vcpu *vcpu)
struct vmcs12 *new_vmcs12;
struct page *page;
page = kvm_vcpu_gpa_to_page(vcpu, vmptr);
- if (is_error_page(page))
- return nested_vmx_failInvalid(vcpu);
-
+ if (is_error_page(page)) {
+ /*
+ * Reads from an unbacked page return all 1s,
+ * which means that the 32 bits located at the
+ * given physical address won't match the required
+ * VMCS12_REVISION identifier.
+ */
+ nested_vmx_failValid(vcpu,
+ VMXERR_VMPTRLD_INCORRECT_VMCS_REVISION_ID);
+ return kvm_skip_emulated_instruction(vcpu);
+ }
new_vmcs12 = kmap(page);
if (new_vmcs12->hdr.revision_id != VMCS12_REVISION ||
(new_vmcs12->hdr.shadow_vmcs &&