diff mbox

[1/2] KVM: nVMX: Fix nested_vmx_check_msr_bitmap_controls

Message ID 20170525180114.131500-1-jmattson@google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jim Mattson May 25, 2017, 6:01 p.m. UTC
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(-)

Comments

kernel test robot May 25, 2017, 8:41 p.m. UTC | #1
Hi Jim,

[auto build test ERROR on kvm/linux-next]
[also build test ERROR on v4.12-rc2 next-20170525]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Jim-Mattson/KVM-nVMX-Fix-nested_vmx_check_msr_bitmap_controls/20170526-042341
base:   https://git.kernel.org/pub/scm/virt/kvm/kvm.git linux-next
config: x86_64-randconfig-x018-201721 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

Note: the linux-review/Jim-Mattson/KVM-nVMX-Fix-nested_vmx_check_msr_bitmap_controls/20170526-042341 HEAD 23051b8d9722709205bf8450e1d1a18a0cd48a05 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   arch/x86/kvm/vmx.c: In function 'nested_vmx_check_msr_bitmap_controls':
>> arch/x86/kvm/vmx.c:9593:41: error: 'addr' undeclared (first use in this function)
     if (vmcs12_read_any(vcpu, MSR_BITMAP, &addr)) {
                                            ^~~~
   arch/x86/kvm/vmx.c:9593:41: note: each undeclared identifier is reported only once for each function it appears in

vim +/addr +9593 arch/x86/kvm/vmx.c

3af18d9c Wincy Van 2015-02-03  9587  static int nested_vmx_check_msr_bitmap_controls(struct kvm_vcpu *vcpu,
3af18d9c Wincy Van 2015-02-03  9588  						struct vmcs12 *vmcs12)
3af18d9c Wincy Van 2015-02-03  9589  {
3af18d9c Wincy Van 2015-02-03  9590  	if (!nested_cpu_has(vmcs12, CPU_BASED_USE_MSR_BITMAPS))
3af18d9c Wincy Van 2015-02-03  9591  		return 0;
3af18d9c Wincy Van 2015-02-03  9592  
3af18d9c Wincy Van 2015-02-03 @9593  	if (vmcs12_read_any(vcpu, MSR_BITMAP, &addr)) {
3af18d9c Wincy Van 2015-02-03  9594  		WARN_ON(1);
3af18d9c Wincy Van 2015-02-03  9595  		return -EINVAL;
3af18d9c Wincy Van 2015-02-03  9596  	}

:::::: The code at line 9593 was first introduced by commit
:::::: 3af18d9c5fe95a6b377dca7b9ff9c6d3ab7f0969 KVM: nVMX: Prepare for using hardware MSR bitmap

:::::: TO: Wincy Van <fanwenyi0529@gmail.com>
:::::: CC: Paolo Bonzini <pbonzini@redhat.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

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;