Skip to content

Commit 181f494

Browse files
mdrothbonzini
authored andcommitted
KVM: x86: fix CPUID entries returned by KVM_GET_CPUID2 ioctl
Recent commit 255cbec modified struct kvm_vcpu_arch to make 'cpuid_entries' a pointer to an array of kvm_cpuid_entry2 entries rather than embedding the array in the struct. KVM_SET_CPUID and KVM_SET_CPUID2 were updated accordingly, but KVM_GET_CPUID2 was missed. As a result, KVM_GET_CPUID2 currently returns random fields from struct kvm_vcpu_arch to userspace rather than the expected CPUID values. Fix this by treating 'cpuid_entries' as a pointer when copying its contents to userspace buffer. Fixes: 255cbec ("KVM: x86: allocate vcpu->arch.cpuid_entries dynamically") Cc: Vitaly Kuznetsov <[email protected]> Signed-off-by: Michael Roth <[email protected]> Message-Id: <[email protected]> Cc: [email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 9a78e15 commit 181f494

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/kvm/cpuid.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
321321
if (cpuid->nent < vcpu->arch.cpuid_nent)
322322
goto out;
323323
r = -EFAULT;
324-
if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
324+
if (copy_to_user(entries, vcpu->arch.cpuid_entries,
325325
vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
326326
goto out;
327327
return 0;

0 commit comments

Comments
 (0)