From patchwork Tue Jun 2 14:48:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 49395 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6471920C3B for ; Tue, 2 Jun 2015 14:51:09 +0000 (UTC) Received: by wifx6 with SMTP id x6sf31799071wif.1 for ; Tue, 02 Jun 2015 07:51:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=5F0rUPcSp0ZEkgDCOAu2emhZ+cPFAAK8y4K/5j3ze7g=; b=FyqS7O41Ybr/w9xj27qVVglFgSPK65fw1f8AGVH1z/+pxLlw/nhX845Lj17C0IuR6e /Gb9sIuPyiftZoNHKjXQlb20MxPIBLLmt8kcvkMzbHkA8o4j9bTiJWSLrXszUq/5bfS4 S2LsnMd59kxMlE72Dux5IZciS1d8o8Djlt6ol9frO8QyKWuukPi8ERUCdju/rh2p3MPN QOVgtwLE1aK221E+vvsuSJjUrdtrxav0RhCciRZEaB208Z3YQ/8+eW71S5j++iiIPzHR UbbG9G0+d2/Oao59cEZWTnqu9yAf/BDKAOtA3XTOHll00Sktm1JTjYe53U1FDMaKI8vR y+Qw== X-Gm-Message-State: ALoCoQn+lgcvuQWmUPk4Pqagyf4kw6ATqJdtaHEMCPFKucXnCgXeMTmwutbTOz79Y+Q22yt3sAIu X-Received: by 10.152.37.101 with SMTP id x5mr26147031laj.5.1433256668729; Tue, 02 Jun 2015 07:51:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.7 with SMTP id js7ls729909lab.34.gmail; Tue, 02 Jun 2015 07:51:08 -0700 (PDT) X-Received: by 10.112.155.197 with SMTP id vy5mr26276453lbb.29.1433256668578; Tue, 02 Jun 2015 07:51:08 -0700 (PDT) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id n4si12067949lbc.63.2015.06.02.07.51.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jun 2015 07:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by lbbqq2 with SMTP id qq2so106014749lbb.3 for ; Tue, 02 Jun 2015 07:51:08 -0700 (PDT) X-Received: by 10.112.220.7 with SMTP id ps7mr26185036lbc.72.1433256668450; Tue, 02 Jun 2015 07:51:08 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3129487lbb; Tue, 2 Jun 2015 07:51:07 -0700 (PDT) X-Received: by 10.68.209.130 with SMTP id mm2mr13124122pbc.88.1433256666099; Tue, 02 Jun 2015 07:51:06 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id po1si26750474pac.52.2015.06.02.07.51.05; Tue, 02 Jun 2015 07:51:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759361AbbFBOvD (ORCPT + 2 others); Tue, 2 Jun 2015 10:51:03 -0400 Received: from mail-oi0-f42.google.com ([209.85.218.42]:35252 "EHLO mail-oi0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758907AbbFBOvC (ORCPT ); Tue, 2 Jun 2015 10:51:02 -0400 Received: by oihd6 with SMTP id d6so127428433oih.2 for ; Tue, 02 Jun 2015 07:51:02 -0700 (PDT) X-Received: by 10.182.102.2 with SMTP id fk2mr23210049obb.35.1433256662400; Tue, 02 Jun 2015 07:51:02 -0700 (PDT) Received: from localhost ([167.160.116.34]) by mx.google.com with ESMTPSA id bq1sm9574163obb.0.2015.06.02.07.51.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 02 Jun 2015 07:51:01 -0700 (PDT) From: shannon.zhao@linaro.org To: stable@vger.kernel.org Cc: gregkh@linuxfoundation.org, christoffer.dall@linaro.org, shannon.zhao@linaro.org, Andre Przywara , Marc Zyngier , Paolo Bonzini Subject: [PATCH for 3.14.y stable 20/32] arm/arm64: KVM: vgic: Fix error code in kvm_vgic_create() Date: Tue, 2 Jun 2015 22:48:15 +0800 Message-Id: <1433256507-7856-21-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1433256507-7856-1-git-send-email-shannon.zhao@linaro.org> References: <1433256507-7856-1-git-send-email-shannon.zhao@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: stable@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: shannon.zhao@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Christoffer Dall commit 6b50f54064a02b77a7b990032b80234fee59bcd6 upstream. If we detect another vCPU is running we just exit and return 0 as if we succesfully created the VGIC, but the VGIC wouldn't actual be created. This shouldn't break in-kernel behavior because the kernel will not observe the failed the attempt to create the VGIC, but userspace could be rightfully confused. Cc: Andre Przywara Signed-off-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Paolo Bonzini Signed-off-by: Shannon Zhao --- virt/kvm/arm/vgic.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 5309a1d..c324a52 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1611,7 +1611,7 @@ out: int kvm_vgic_create(struct kvm *kvm) { - int i, vcpu_lock_idx = -1, ret = 0; + int i, vcpu_lock_idx = -1, ret; struct kvm_vcpu *vcpu; mutex_lock(&kvm->lock); @@ -1626,6 +1626,7 @@ int kvm_vgic_create(struct kvm *kvm) * vcpu->mutex. By grabbing the vcpu->mutex of all VCPUs we ensure * that no other VCPUs are run while we create the vgic. */ + ret = -EBUSY; kvm_for_each_vcpu(i, vcpu, kvm) { if (!mutex_trylock(&vcpu->mutex)) goto out_unlock; @@ -1633,11 +1634,10 @@ int kvm_vgic_create(struct kvm *kvm) } kvm_for_each_vcpu(i, vcpu, kvm) { - if (vcpu->arch.has_run_once) { - ret = -EBUSY; + if (vcpu->arch.has_run_once) goto out_unlock; - } } + ret = 0; spin_lock_init(&kvm->arch.vgic.lock); kvm->arch.vgic.vctrl_base = vgic_vctrl_base;