From patchwork Tue Dec 9 15:44:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 42057 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2419425E75 for ; Tue, 9 Dec 2014 15:45:46 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf689212lab.3 for ; Tue, 09 Dec 2014 07:45:44 -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=MZi0XUsbhlMoXSkX6Kck8cid4YmDr12vWwTQLKp1tWk=; b=kUoh6me7t9/HyNOHDtSfgoeHI6oA2nNKf7U1+fePI+qERBNIYLo40a5FZzGZXeELmj 5v1Wrt/qA4PSLR/V/lLZhEluLWd1q4bF8a/aEk1wUm1rqgowPyB9fjhwj5+0tEBje3R6 FmVug5xuCEiX9oZ0gPqKA+3JdsNV0CG5kB8o2KhcDnNst7H3AaCzvDhWCULmpmKSCmeT V5uBvelSMz1gso3TdccGdBHoq/B/nk83Sd5MeUG4yLoLeXRNNhAc6erlg2kQn6ES9XRC 6miRRu6quzyq6DebVoPQj6TZl7r6DlEixcQC4IpU+vdB7lAc/jXh0mAMkrVrkMTindq1 x/MQ== X-Gm-Message-State: ALoCoQn5dKpYhLNt+fxIX3Ue9oKviJggiGp1LWWhfIB0ypzMwGpAotfI+w/HHD/QFGSEwybnS8eR X-Received: by 10.112.89.195 with SMTP id bq3mr643937lbb.9.1418139944514; Tue, 09 Dec 2014 07:45:44 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.206.37 with SMTP id ll5ls56985lac.53.gmail; Tue, 09 Dec 2014 07:45:44 -0800 (PST) X-Received: by 10.112.91.43 with SMTP id cb11mr766015lbb.63.1418139944373; Tue, 09 Dec 2014 07:45:44 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id li1si1661483lab.112.2014.12.09.07.45.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 09 Dec 2014 07:45:44 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id u10so727367lbd.34 for ; Tue, 09 Dec 2014 07:45:44 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr22490989laz.71.1418139943950; Tue, 09 Dec 2014 07:45: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.184.201 with SMTP id ew9csp769765lbc; Tue, 9 Dec 2014 07:45:42 -0800 (PST) X-Received: by 10.70.65.105 with SMTP id w9mr32193569pds.58.1418139942067; Tue, 09 Dec 2014 07:45:42 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id ch4si2457208pdb.68.2014.12.09.07.45.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Dec 2014 07:45:42 -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 1XyMxO-0004zs-WC; Tue, 09 Dec 2014 15:44:10 +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 1XyMwu-0004kE-Aa for linux-arm-kernel@lists.infradead.org; Tue, 09 Dec 2014 15:43:41 +0000 Received: by mail-la0-f44.google.com with SMTP id gd6so751816lab.17 for ; Tue, 09 Dec 2014 07:43:18 -0800 (PST) X-Received: by 10.112.189.10 with SMTP id ge10mr22144009lbc.23.1418139798288; Tue, 09 Dec 2014 07:43:18 -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 i2sm180810lae.40.2014.12.09.07.43.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Dec 2014 07:43:17 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/5] arm/arm64: KVM: Add (new) vgic_initialized macro Date: Tue, 9 Dec 2014 16:44:02 +0100 Message-Id: <1418139844-27892-4-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.1.2.330.g565301e.dirty In-Reply-To: <1418139844-27892-1-git-send-email-christoffer.dall@linaro.org> References: <1418139844-27892-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141209_074340_576050_15A045AF X-CRM114-Status: GOOD ( 12.32 ) 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: 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.217.175 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. Signed-off-by: Christoffer Dall Reviewed-by: Eric Auger --- include/kvm/arm_vgic.h | 6 ++++++ virt/kvm/arm/vgic.c | 1 + 2 files changed, 7 insertions(+) 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 6293349..c98cc6b 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; } /*