aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Mattson <jmattson@google.com>2017-07-06 19:33:07 -0400
committerRadim Krčmář <rkrcmar@redhat.com>2017-07-12 12:41:12 -0400
commit5fa99cbe7b666dce6dd8ac55b253778893b9c5df (patch)
tree07f4e3fb2a1b6f2a7157dde29dacedd7d12df9c7
parent56a205100d3933f785ca970c58aecedd94ff90b2 (diff)
kvm: nVMX: Fix nested_vmx_check_msr_bitmap_controls
Allow the L1 guest to specify the last page of addressable guest physical memory for an L2 MSR permission bitmap. Also remove the vmcs12_read_any() check that should never fail. Fixes: 3af18d9c5fe95 ("KVM: nVMX: Prepare for using hardware MSR bitmap") Signed-off-by: Jim Mattson <jmattson@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--arch/x86/kvm/vmx.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 22034ac4b5f2..e02c7004b64b 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4634,6 +4634,11 @@ static bool guest_state_valid(struct kvm_vcpu *vcpu)
4634 return true; 4634 return true;
4635} 4635}
4636 4636
4637static bool page_address_valid(struct kvm_vcpu *vcpu, gpa_t gpa)
4638{
4639 return PAGE_ALIGNED(gpa) && !(gpa >> cpuid_maxphyaddr(vcpu));
4640}
4641
4637static int init_rmode_tss(struct kvm *kvm) 4642static int init_rmode_tss(struct kvm *kvm)
4638{ 4643{
4639 gfn_t fn; 4644 gfn_t fn;
@@ -9611,20 +9616,10 @@ static int nested_vmx_check_io_bitmap_controls(struct kvm_vcpu *vcpu,
9611static int nested_vmx_check_msr_bitmap_controls(struct kvm_vcpu *vcpu, 9616static int nested_vmx_check_msr_bitmap_controls(struct kvm_vcpu *vcpu,
9612 struct vmcs12 *vmcs12) 9617 struct vmcs12 *vmcs12)
9613{ 9618{
9614 int maxphyaddr;
9615 u64 addr;
9616
9617 if (!nested_cpu_has(vmcs12, CPU_BASED_USE_MSR_BITMAPS)) 9619 if (!nested_cpu_has(vmcs12, CPU_BASED_USE_MSR_BITMAPS))
9618 return 0; 9620 return 0;
9619 9621
9620 if (vmcs12_read_any(vcpu, MSR_BITMAP, &addr)) { 9622 if (!page_address_valid(vcpu, vmcs12->msr_bitmap))
9621 WARN_ON(1);
9622 return -EINVAL;
9623 }
9624 maxphyaddr = cpuid_maxphyaddr(vcpu);
9625
9626 if (!PAGE_ALIGNED(vmcs12->msr_bitmap) ||
9627 ((addr + PAGE_SIZE) >> maxphyaddr))
9628 return -EINVAL; 9623 return -EINVAL;
9629 9624
9630 return 0; 9625 return 0;