From patchwork Sat Dec 13 11:17:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 42207 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D43B921772 for ; Sat, 13 Dec 2014 11:19:03 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id q1sf5820105lam.10 for ; Sat, 13 Dec 2014 03:19:02 -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 :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version :content-type:content-transfer-encoding:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list; bh=y0g0t7U5pvte2avzV6JOl1Jmp+Pk++Ke98Sp8RV6dhI=; b=N5ijbOHXrZc6YRkSLphk6aJrUGw2ZPWXRfkN035qQAF6E4g5YgaCcSv+PUVcMoFuzO 28OiTa/0eO1Lo4HlYFet6r2jZvv98LDS7xF5tIhO+sKam4CWTn7w8xrBVNQ+56JC/TIF HFbtfJ33tvLI4/5v+7EAXrNEXKCPmJWdiGE4eGX4NdaDMc7JPOTNQtjMyzwvE0/P2L57 CequnsQyMoo92up3aiXQ0olNgxSKNw2oO8SxqYPJgEDCHkvQ29jxw+kHk436P53uyAZS i8nHkV+6tsd8X/86nYx3EYioBWHqol75dHqJcrsw6oRXIWlxYzyFgIp9HO3mCXU71M+I n5og== X-Gm-Message-State: ALoCoQnSwcOx667a9UWzeGzX267qAPy+SsghMs0DRPYe4fGeQOI9DZeMY8n/YLguD7JenPSBQ+48 X-Received: by 10.180.8.9 with SMTP id n9mr1424771wia.6.1418469542762; Sat, 13 Dec 2014 03:19:02 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.41 with SMTP id t9ls549637lal.51.gmail; Sat, 13 Dec 2014 03:19:02 -0800 (PST) X-Received: by 10.112.95.133 with SMTP id dk5mr19981796lbb.55.1418469542061; Sat, 13 Dec 2014 03:19:02 -0800 (PST) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id k1si4185984lah.55.2014.12.13.03.19.01 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Dec 2014 03:19:01 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-la0-f54.google.com with SMTP id pv20so7305672lab.27 for ; Sat, 13 Dec 2014 03:19:01 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr19820382lbc.23.1418469541771; Sat, 13 Dec 2014 03:19:01 -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.142.69 with SMTP id ru5csp231859lbb; Sat, 13 Dec 2014 03:19:00 -0800 (PST) X-Received: by 10.68.218.231 with SMTP id pj7mr20350924pbc.95.1418469539996; Sat, 13 Dec 2014 03:18:59 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id tt6si5725509pbc.112.2014.12.13.03.18.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Dec 2014 03:18:59 -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 1Xzkhh-0006Ym-0N; Sat, 13 Dec 2014 11:17:41 +0000 Received: from mail-la0-f47.google.com ([209.85.215.47]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Xzkgy-0006Gm-Bn for linux-arm-kernel@lists.infradead.org; Sat, 13 Dec 2014 11:16:57 +0000 Received: by mail-la0-f47.google.com with SMTP id hz20so7451936lab.34 for ; Sat, 13 Dec 2014 03:16:34 -0800 (PST) X-Received: by 10.112.141.42 with SMTP id rl10mr20033166lbb.98.1418469394327; Sat, 13 Dec 2014 03:16:34 -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 b4sm1096765lbp.17.2014.12.13.03.16.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 13 Dec 2014 03:16:33 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/6] arm/arm64: KVM: Add (new) vgic_initialized macro Date: Sat, 13 Dec 2014 12:17:26 +0100 Message-Id: <1418469449-13277-4-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1418469449-13277-1-git-send-email-christoffer.dall@linaro.org> References: <1418469449-13277-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141213_031656_623082_820727ED X-CRM114-Status: GOOD ( 12.58 ) 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.47 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.215.47 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Christoffer Dall , kvm@vger.kernel.org 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.54 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 Some code paths will need to check to see if the internal state of the vgic has been initialized (such as when creating new VCPUs), so introduce such a macro that checks the nr_cpus field which is set when the vgic has been initialized. Also set nr_cpus = 0 in kvm_vgic_destroy, because the error path in vgic_init() will call this function, and code should never errornously assume the vgic to be properly initialized after an error. Acked-by: Marc Zyngier Reviewed-by: Eric Auger Signed-off-by: Christoffer Dall --- include/kvm/arm_vgic.h | 6 ++++++ virt/kvm/arm/vgic.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/kvm/arm_vgic.h b/include/kvm/arm_vgic.h index 3e262b9..ac4888d 100644 --- a/include/kvm/arm_vgic.h +++ b/include/kvm/arm_vgic.h @@ -287,6 +287,7 @@ bool vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run, struct kvm_exit_mmio *mmio); #define irqchip_in_kernel(k) (!!((k)->arch.vgic.in_kernel)) +#define vgic_initialized(k) (!!((k)->arch.vgic.nr_cpus)) #define vgic_ready(k) ((k)->arch.vgic.ready) int vgic_v2_probe(struct device_node *vgic_node, @@ -369,6 +370,11 @@ static inline int irqchip_in_kernel(struct kvm *kvm) return 0; } +static inline bool vgic_initialized(struct kvm *kvm) +{ + return true; +} + static inline bool vgic_ready(struct kvm *kvm) { return true; diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 22c8304..e1bef68 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1774,6 +1774,7 @@ void kvm_vgic_destroy(struct kvm *kvm) dist->irq_spi_cpu = NULL; dist->irq_spi_target = NULL; dist->irq_pending_on_cpu = NULL; + dist->nr_cpus = 0; } /* @@ -1787,7 +1788,7 @@ static int vgic_init(struct kvm *kvm) int nr_cpus, nr_irqs; int ret, i, vcpu_id; - if (dist->nr_cpus) /* Already allocated */ + if (vgic_initialized(kvm)) return 0; nr_cpus = dist->nr_cpus = atomic_read(&kvm->online_vcpus);