From patchwork Tue Jun 30 10:48:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 50458 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2E2D2229DF for ; Tue, 30 Jun 2015 10:50:50 +0000 (UTC) Received: by wgjx7 with SMTP id x7sf2453388wgj.3 for ; Tue, 30 Jun 2015 03:50:49 -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=Ocngs3qMUZxJjeIlza6nUrEMCWW3xcSU2/cxHapf8Ei/2fBcFHRS2x5gzF4wIiZOyW N+NOhTDD4xSnrzmG/bPpVBi0fWFr7IdtiGQKQsYvO38mWNetbzt0+XUipIxmTJsu1NL+ Wae9z2DlNRgsotdTntouMwOEwcBlWncrj4szkJwxjEgFneh6LUTE5x23g5cnI173BKll 4JdNmnP2vpuWHA84PHvtfHT6ZqUP8EEg7TlFmUbu7celxM+Y5oSv3zgR7Y/yxa7eN9Pa H1kw87M1UoNKqtVw6kzriZPFMZ1fyWT9yUU1Z17KhwhBfUrZtYnrsWcs2Gh7DfS34Ld8 +Cog== X-Gm-Message-State: ALoCoQlrMDJYBXB1FoW/TEzy62JNpIAMG9Lp7Jo1kR8D2Nlz9PUgYmQH0hEY/an51wz76MRiehAL X-Received: by 10.112.55.104 with SMTP id r8mr13778321lbp.18.1435661449480; Tue, 30 Jun 2015 03:50:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.204.9 with SMTP id ku9ls29633lac.37.gmail; Tue, 30 Jun 2015 03:50:49 -0700 (PDT) X-Received: by 10.112.161.197 with SMTP id xu5mr18862223lbb.69.1435661449266; Tue, 30 Jun 2015 03:50:49 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id jl8si8767547lbc.66.2015.06.30.03.50.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Jun 2015 03:50:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by lagx9 with SMTP id x9so8154263lag.1 for ; Tue, 30 Jun 2015 03:50:48 -0700 (PDT) X-Received: by 10.152.22.99 with SMTP id c3mr19386240laf.32.1435661448554; Tue, 30 Jun 2015 03:50:48 -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 hn6csp2352921lbb; Tue, 30 Jun 2015 03:50:47 -0700 (PDT) X-Received: by 10.70.134.70 with SMTP id pi6mr42059042pdb.100.1435661447487; Tue, 30 Jun 2015 03:50:47 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5si66313267par.87.2015.06.30.03.50.46; Tue, 30 Jun 2015 03:50:47 -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 S1751643AbbF3Kuq (ORCPT + 2 others); Tue, 30 Jun 2015 06:50:46 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:36702 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752229AbbF3Kup (ORCPT ); Tue, 30 Jun 2015 06:50:45 -0400 Received: by paceq1 with SMTP id eq1so3785752pac.3 for ; Tue, 30 Jun 2015 03:50:45 -0700 (PDT) X-Received: by 10.70.17.66 with SMTP id m2mr42602367pdd.49.1435661444995; Tue, 30 Jun 2015 03:50:44 -0700 (PDT) Received: from localhost ([120.136.36.232]) by mx.google.com with ESMTPSA id db1sm45229774pdb.50.2015.06.30.03.50.42 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 30 Jun 2015 03:50:43 -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 10/22] arm/arm64: KVM: vgic: Fix error code in kvm_vgic_create() Date: Tue, 30 Jun 2015 18:48:58 +0800 Message-Id: <1435661350-8060-11-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1435661350-8060-1-git-send-email-shannon.zhao@linaro.org> References: <1435661350-8060-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.215.44 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;