]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: x86: fix KVM_SET_XCRS loop
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 17 Oct 2013 14:50:47 +0000 (16:50 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 31 Oct 2013 10:31:19 +0000 (11:31 +0100)
The loop was always using 0 as the index.  This means that
any rubbish after the first element of the array went undetected.
It seems reasonable to assume that no KVM userspace did that.

Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c

index 296154956399d830b74db531a07e646c2a888034..6d16fc5302460c3e2bcc71f81b0607c56cf86c5b 100644 (file)
@@ -3064,9 +3064,9 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
 
        for (i = 0; i < guest_xcrs->nr_xcrs; i++)
                /* Only support XCR0 currently */
-               if (guest_xcrs->xcrs[0].xcr == XCR_XFEATURE_ENABLED_MASK) {
+               if (guest_xcrs->xcrs[i].xcr == XCR_XFEATURE_ENABLED_MASK) {
                        r = __kvm_set_xcr(vcpu, XCR_XFEATURE_ENABLED_MASK,
-                               guest_xcrs->xcrs[0].value);
+                               guest_xcrs->xcrs[i].value);
                        break;
                }
        if (r)