public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] KVM: nVMX: Fix nested_vmx_check_msr_bitmap_controls
@ 2017-05-25 18:01 Jim Mattson
  2017-05-25 18:01 ` [PATCH 2/2] KVM: nVMX: Check host support for MSR bitmaps Jim Mattson
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jim Mattson @ 2017-05-25 18:01 UTC (permalink / raw)
  To: kvm, Wincy Van; +Cc: Jim Mattson

Allow the L1 guest to specify the last page of addressable guest
physical memory for an L2 MSR permission bitmap.

Fixes: 3af18d9c5fe95 ("KVM: nVMX: Prepare for using hardware MSR bitmap")
Signed-off-by: Jim Mattson <jmattson@google.com>
---
 arch/x86/kvm/vmx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index c6f4ad44aa95..ae641c8d4284 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4624,6 +4624,11 @@ static bool guest_state_valid(struct kvm_vcpu *vcpu)
 	return true;
 }
 
+static bool page_address_valid(struct kvm_vcpu *vcpu, gpa_t gpa)
+{
+	return PAGE_ALIGNED(gpa) && !(gpa >> cpuid_maxphyaddr(vcpu));
+}
+
 static int init_rmode_tss(struct kvm *kvm)
 {
 	gfn_t fn;
@@ -9582,9 +9587,6 @@ static void vmx_start_preemption_timer(struct kvm_vcpu *vcpu)
 static int nested_vmx_check_msr_bitmap_controls(struct kvm_vcpu *vcpu,
 						struct vmcs12 *vmcs12)
 {
-	int maxphyaddr;
-	u64 addr;
-
 	if (!nested_cpu_has(vmcs12, CPU_BASED_USE_MSR_BITMAPS))
 		return 0;
 
@@ -9592,10 +9594,8 @@ static int nested_vmx_check_msr_bitmap_controls(struct kvm_vcpu *vcpu,
 		WARN_ON(1);
 		return -EINVAL;
 	}
-	maxphyaddr = cpuid_maxphyaddr(vcpu);
 
-	if (!PAGE_ALIGNED(vmcs12->msr_bitmap) ||
-	   ((addr + PAGE_SIZE) >> maxphyaddr))
+	if (!page_address_valid(vcpu, vmcs12->msr_bitmap))
 		return -EINVAL;
 
 	return 0;
-- 
2.13.0.219.gdb65acc882-goog

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-19 22:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-25 18:01 [PATCH 1/2] KVM: nVMX: Fix nested_vmx_check_msr_bitmap_controls Jim Mattson
2017-05-25 18:01 ` [PATCH 2/2] KVM: nVMX: Check host support for MSR bitmaps Jim Mattson
2017-05-26  0:04   ` [PATCH v2 " Jim Mattson
2017-06-07 14:21     ` Radim Krčmář
2017-06-19 22:23       ` [PATCH v2] KVM: nVMX: Fix nested_vmx_check_msr_bitmap_controls Jim Mattson
2017-05-25 20:41 ` [PATCH 1/2] " kbuild test robot
2017-05-26  0:02 ` [PATCH v2 " Jim Mattson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox