From patchwork Mon May 4 01:52:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47973 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 64AA12121F for ; Mon, 4 May 2015 01:56:20 +0000 (UTC) Received: by wgtl5 with SMTP id l5sf41028091wgt.1 for ; Sun, 03 May 2015 18:56:19 -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=GnHrU+ewKErI5cMS+G9+FIIlIRebQeKAtlM/1+cXJ+J2sgMQHoujFW8CiSri2mT+i5 7l1PGoH8KqTkCm4D4fKajVlfyFV84acIfu6FLhjbVBjacP3Umd5j/DAmZDBotHOdKy5a kT3J6HQI+jJ+tc2HkkhX0jFtZAzIhoRmisIxMVliELTu00Lpu9adgbyzh8GBusCn/Crz Zl7MoHUh8oADKH4dQ0fX6z89r9PUVv+VMXNE7dMCbLgW9kTCUN9moDTQmXcKfdlgzjA+ 0v0/3owW7427siXbNhRi9NffJe+5quSIWHvMi5delvoHkQNxzRC8RLUyVL2xmeiZezob Gmfw== X-Gm-Message-State: ALoCoQlKEA+udO59JHdAg5ze1HdEJv63vEXYCGz5Slo2Geakj73dJPt+/VA9UAH8fui+tdkUM42v X-Received: by 10.194.143.98 with SMTP id sd2mr16949337wjb.6.1430704579695; Sun, 03 May 2015 18:56:19 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.184.8 with SMTP id eq8ls776191lac.91.gmail; Sun, 03 May 2015 18:56:19 -0700 (PDT) X-Received: by 10.152.170.170 with SMTP id an10mr17540067lac.84.1430704579538; Sun, 03 May 2015 18:56:19 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id g1si9071531laf.139.2015.05.03.18.56.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 May 2015 18:56:19 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbcga7 with SMTP id ga7so95754676lbc.1 for ; Sun, 03 May 2015 18:56:19 -0700 (PDT) X-Received: by 10.112.204.6 with SMTP id ku6mr17415620lbc.73.1430704579403; Sun, 03 May 2015 18:56:19 -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.67.65 with SMTP id l1csp1413172lbt; Sun, 3 May 2015 18:56:18 -0700 (PDT) X-Received: by 10.67.7.199 with SMTP id de7mr36237479pad.107.1430704577661; Sun, 03 May 2015 18:56:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix6si17838787pac.46.2015.05.03.18.56.16; Sun, 03 May 2015 18:56:17 -0700 (PDT) Received-SPF: none (google.com: stable-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751970AbbEDB4Q (ORCPT + 2 others); Sun, 3 May 2015 21:56:16 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:32938 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751966AbbEDB4P (ORCPT ); Sun, 3 May 2015 21:56:15 -0400 Received: by pacwv17 with SMTP id wv17so147919520pac.0 for ; Sun, 03 May 2015 18:56:15 -0700 (PDT) X-Received: by 10.68.136.42 with SMTP id px10mr38575713pbb.19.1430704575441; Sun, 03 May 2015 18:56:15 -0700 (PDT) Received: from localhost ([180.150.153.1]) by mx.google.com with ESMTPSA id l14sm11024917pdn.96.2015.05.03.18.56.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 03 May 2015 18:56:14 -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 35/47] arm/arm64: KVM: vgic: Fix error code in kvm_vgic_create() Date: Mon, 4 May 2015 09:52:30 +0800 Message-Id: <1430704362-6292-36-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1430704362-6292-1-git-send-email-shannon.zhao@linaro.org> References: <1430704362-6292-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.169 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;