]> Pileus Git - ~andy/linux/blobdiff - arch/x86/kvm/cpuid.c
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[~andy/linux] / arch / x86 / kvm / cpuid.c
index 86d5756dda07b5d15c4e761e37d469f8f2d251c7..c6976257eff51281e023c264b355f166ce56dd5c 100644 (file)
@@ -564,6 +564,7 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries,
                                 __u32 num_entries, unsigned int ioctl_type)
 {
        int i;
+       __u32 pad[3];
 
        if (ioctl_type != KVM_GET_EMULATED_CPUID)
                return false;
@@ -577,9 +578,10 @@ static bool sanity_check_entries(struct kvm_cpuid_entry2 __user *entries,
         * sheds a tear.
         */
        for (i = 0; i < num_entries; i++) {
-               if (entries[i].padding[0] ||
-                   entries[i].padding[1] ||
-                   entries[i].padding[2])
+               if (copy_from_user(pad, entries[i].padding, sizeof(pad)))
+                       return true;
+
+               if (pad[0] || pad[1] || pad[2])
                        return true;
        }
        return false;
@@ -756,6 +758,7 @@ void kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx)
                *edx = best->edx;
        } else
                *eax = *ebx = *ecx = *edx = 0;
+       trace_kvm_cpuid(function, *eax, *ebx, *ecx, *edx);
 }
 EXPORT_SYMBOL_GPL(kvm_cpuid);
 
@@ -771,6 +774,5 @@ void kvm_emulate_cpuid(struct kvm_vcpu *vcpu)
        kvm_register_write(vcpu, VCPU_REGS_RCX, ecx);
        kvm_register_write(vcpu, VCPU_REGS_RDX, edx);
        kvm_x86_ops->skip_emulated_instruction(vcpu);
-       trace_kvm_cpuid(function, eax, ebx, ecx, edx);
 }
 EXPORT_SYMBOL_GPL(kvm_emulate_cpuid);