From patchwork Mon Dec 15 11:41:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 42243 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B1B1221772 for ; Mon, 15 Dec 2014 11:49:44 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id w7sf3553851lbi.4 for ; Mon, 15 Dec 2014 03:49:43 -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=wYRiYr+yBp6Uq4NM1UjLtftqTkKx81kZnE7RMj+DGyc=; b=c416dN0x8hIAIx/HLL/73b5Bwsj/6KGzzBQ7ekJMICuegj2PBK2KAfhDsHGznpz1g1 IDxwaZaCfaB5fpFjxAiP58jUKJDhqjKKyMrw4mknRkXKA0kqdS50MIo4SVXwidC8cVf7 MnnP5Sw4MRUHM9z/kOHcE6KZfa4eg5KdPRGQTTfr2SGTs2QKN0pevUGIkd7ZvAU3gR4e E/tfvWGOfW88MuBpJLPnBj63y/glgQfLHMIrNCh5TcP9MOJ0NZ6iF4gpoYqTvVEizWQQ QokhuV5qqebf0IOpcpxXtzvoBKq/Ei+yC3gwSaVcIa28wnyFgxix/II/aS7VDDDJO+t6 eZOQ== X-Gm-Message-State: ALoCoQnTOZy51Cv+dt9qdXFqUwsBqB94sL+RL0K/dJTTz3UrwyUFKaIDkzCDeMC66KVJX09Ib1d8 X-Received: by 10.180.105.97 with SMTP id gl1mr2749616wib.7.1418644183429; Mon, 15 Dec 2014 03:49:43 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.170 with SMTP id d10ls634630lad.37.gmail; Mon, 15 Dec 2014 03:49:43 -0800 (PST) X-Received: by 10.112.129.195 with SMTP id ny3mr30387223lbb.10.1418644183204; Mon, 15 Dec 2014 03:49:43 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id f4si10153222lam.117.2014.12.15.03.49.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 03:49:43 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gq15so9274862lab.32 for ; Mon, 15 Dec 2014 03:49:43 -0800 (PST) X-Received: by 10.112.136.69 with SMTP id py5mr16068346lbb.56.1418644183087; Mon, 15 Dec 2014 03:49:43 -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 ru5csp689529lbb; Mon, 15 Dec 2014 03:49:42 -0800 (PST) X-Received: by 10.70.26.35 with SMTP id i3mr51042725pdg.84.1418644181122; Mon, 15 Dec 2014 03:49:41 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ct5si13582961pbc.96.2014.12.15.03.49.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Dec 2014 03:49:41 -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 1Y0U7w-0008Sm-RH; Mon, 15 Dec 2014 11:47:48 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0U2w-000385-Kp for linux-arm-kernel@bombadil.infradead.org; Mon, 15 Dec 2014 11:42:38 +0000 Received: from mail-lb0-f169.google.com ([209.85.217.169]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Y0U2t-0005Cw-Rf for linux-arm-kernel@lists.infradead.org; Mon, 15 Dec 2014 11:42:37 +0000 Received: by mail-lb0-f169.google.com with SMTP id p9so8923861lbv.14 for ; Mon, 15 Dec 2014 03:42:12 -0800 (PST) X-Received: by 10.112.164.240 with SMTP id yt16mr12777668lbb.34.1418643732401; Mon, 15 Dec 2014 03:42:12 -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 ug5sm2616126lac.38.2014.12.15.03.42.11 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 03:42:11 -0800 (PST) From: Christoffer Dall To: Paolo Bonzini , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [GIT PULL 09/12] arm/arm64: KVM: Add (new) vgic_initialized macro Date: Mon, 15 Dec 2014 12:41:56 +0100 Message-Id: <1418643719-25966-10-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1418643719-25966-1-git-send-email-christoffer.dall@linaro.org> References: <1418643719-25966-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141215_064236_040740_87865F96 X-CRM114-Status: GOOD ( 15.43 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.4.0 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.169 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.217.169 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Marc Zyngier , 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.45 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 4edb257..d862ea5 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -1780,6 +1780,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; } /* @@ -1793,7 +1794,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);