From patchwork Thu Oct 17 14:50:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 3061331 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 06AE89F3E2 for ; Thu, 17 Oct 2013 14:51:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 064A32029B for ; Thu, 17 Oct 2013 14:51:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7703920220 for ; Thu, 17 Oct 2013 14:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757254Ab3JQOvT (ORCPT ); Thu, 17 Oct 2013 10:51:19 -0400 Received: from mail-ee0-f48.google.com ([74.125.83.48]:48675 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756506Ab3JQOu6 (ORCPT ); Thu, 17 Oct 2013 10:50:58 -0400 Received: by mail-ee0-f48.google.com with SMTP id e50so194989eek.21 for ; Thu, 17 Oct 2013 07:50:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=VnKdCu6mUoZJoj2LWZXWeF3DyeoZlUFVNfyepVn81yM=; b=k1sEfDSAjDMHzUgw8sE5abDEnOKLfLG3G33B4QfsjOXI1ZUe183h3JG+RkmJMLyxzc rjm7QISBEbaamMznoY4o1ZVbw45od/pUXvHS027Xw7Ej+yAzsYdpjP6y8R4mPKBT6doC JxQin0Qw0vGx3srFjEqpFzxzthobKJCFkjDL5CqSyFWSM5j2ymlHmxMncIDxEpZVSJZc qe9n1gKdCic96+HKwU9x+3q9tFAm2GccK/L1PvvP9a8k/0qfHVtGTixT28T8NrLq1wAh Cf+Z8ba/TY/Q5OEHK+PJM4T/AT+iAwoBfALmPyt+b3XBLO2/uhKErFpjVKsgMEGg6XEq HNoA== X-Received: by 10.15.44.202 with SMTP id z50mr4166920eev.68.1382021457786; Thu, 17 Oct 2013 07:50:57 -0700 (PDT) Received: from playground.lan (net-37-116-196-7.cust.dsl.vodafone.it. [37.116.196.7]) by mx.google.com with ESMTPSA id i1sm193733166eeg.0.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 17 Oct 2013 07:50:56 -0700 (PDT) From: Paolo Bonzini To: linux-kernel@vger.kernel.org Cc: gleb@redhat.com, agraf@suse.de, chao.zhou@intel.com, magnus@boden.cx, kvm@vger.kernel.org Subject: [PATCH 2/2] KVM: x86: fix KVM_SET_XCRS loop Date: Thu, 17 Oct 2013 16:50:47 +0200 Message-Id: <1382021447-20216-3-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1382021447-20216-1-git-send-email-pbonzini@redhat.com> References: <1382021447-20216-1-git-send-email-pbonzini@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Paolo Bonzini --- arch/x86/kvm/x86.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f4e1391..f91dff2 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -3062,9 +3062,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)