KVM: VMX: Check for automatic switch msr table overflow
authorGleb Natapov <gleb@redhat.com>
Wed, 5 Oct 2011 12:01:24 +0000 (14:01 +0200)
committerAvi Kivity <avi@redhat.com>
Thu, 17 Nov 2011 14:28:09 +0000 (16:28 +0200)
Signed-off-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/vmx.c

index 98f4b0bcc660214696f0316a3f3492a11ddca8eb..579a0b51696ac560b1768ae445bb8f2084172f8c 100644 (file)
@@ -1280,7 +1280,11 @@ static void add_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr,
                if (m->guest[i].index == msr)
                        break;
 
-       if (i == m->nr) {
+       if (i == NR_AUTOLOAD_MSRS) {
+               printk_once(KERN_WARNING"Not enough mst switch entries. "
+                               "Can't add msr %x\n", msr);
+               return;
+       } else if (i == m->nr) {
                ++m->nr;
                vmcs_write32(VM_ENTRY_MSR_LOAD_COUNT, m->nr);
                vmcs_write32(VM_EXIT_MSR_LOAD_COUNT, m->nr);