From patchwork Thu Nov 6 11:47:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 40275 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1520A2404A for ; Thu, 6 Nov 2014 11:49:20 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id d17sf2030189eek.7 for ; Thu, 06 Nov 2014 03:49:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=4onG/dwG+DTz9vMEdpNgjN/vj360hkoWzI6M0DLcou4=; b=fKE7IKuEo9hriaBV/Ni/jVGY4sRBKeDk2pyI+yaeZbFE/zx3714xJHlRS8g4tLm6Yn LC8mAgMckIQKlR36soBIWN6tfF0+maIICYwwdTqrQJWc1v7jGmoHkI/srKe4Rt+qkwK2 pMdybiw32uFqfxd9ifaDzrU1fCwHLl7XY/oKLHPYn1aMP/Z8+ECIMFNm85DYBsJFunWJ 0hujI6n8VgdLwTzHYGkMDWoAt5j+69dcdRMKFKfcOOd6Jz2rELvzO2gGOqtqr8PwqgVp eovyGm/WqqDNr+V8i7/jE7cn6ucoxBV4XuG93NdVbjy6GOf791kbtYjBBID5FjdhdneR z/Yg== X-Gm-Message-State: ALoCoQlgWOTb0rf0Swylbb7PGBJdJrwlEBK8/krgJ7s0kZ7QiRKzo7yR1Iy/5upV5vbjsYUVPvr9 X-Received: by 10.181.8.194 with SMTP id dm2mr6448302wid.2.1415274559353; Thu, 06 Nov 2014 03:49:19 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.203.202 with SMTP id ks10ls72312lac.72.gmail; Thu, 06 Nov 2014 03:49:18 -0800 (PST) X-Received: by 10.112.138.39 with SMTP id qn7mr4484617lbb.57.1415274558609; Thu, 06 Nov 2014 03:49:18 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id s6si11121456laj.90.2014.11.06.03.49.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 06 Nov 2014 03:49:18 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id q1so2472518lam.10 for ; Thu, 06 Nov 2014 03:49:18 -0800 (PST) X-Received: by 10.152.5.38 with SMTP id p6mr4584232lap.44.1415274558173; Thu, 06 Nov 2014 03:49:18 -0800 (PST) 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.184.201 with SMTP id ew9csp31190lbc; Thu, 6 Nov 2014 03:49:17 -0800 (PST) X-Received: by 10.68.206.98 with SMTP id ln2mr3662105pbc.83.1415274556547; Thu, 06 Nov 2014 03:49:16 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id v3si5558481pdo.232.2014.11.06.03.49.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Nov 2014 03:49:16 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XmLXn-0004WL-SW; Thu, 06 Nov 2014 11:48:03 +0000 Received: from mail-la0-f44.google.com ([209.85.215.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XmLXk-00035O-UK for linux-arm-kernel@lists.infradead.org; Thu, 06 Nov 2014 11:48:01 +0000 Received: by mail-la0-f44.google.com with SMTP id gf13so2410323lab.31 for ; Thu, 06 Nov 2014 03:47:36 -0800 (PST) X-Received: by 10.112.171.6 with SMTP id aq6mr4664609lbc.28.1415274456546; Thu, 06 Nov 2014 03:47:36 -0800 (PST) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id d9sm2433312lbp.49.2014.11.06.03.47.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Nov 2014 03:47:35 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm/arm64: kvm: vgic: Fix error code in kvm_vgic_create() Date: Thu, 6 Nov 2014 12:47:39 +0100 Message-Id: <1415274459-28018-1-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141106_034801_157270_574A3002 X-CRM114-Status: GOOD ( 12.85 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.44 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.44 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Andre Przywara , Christoffer Dall X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@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.51 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 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 --- 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 3aaca49..aacdb59 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1933,7 +1933,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); @@ -1948,6 +1948,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; @@ -1955,11 +1956,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.in_kernel = true;