From patchwork Wed Mar 4 10:14:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 5935061 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 927809F318 for ; Wed, 4 Mar 2015 10:22:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BDB6420265 for ; Wed, 4 Mar 2015 10:21:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E691920222 for ; Wed, 4 Mar 2015 10:21:56 +0000 (UTC) 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 1YT6OR-0005Pq-Ul; Wed, 04 Mar 2015 10:19:07 +0000 Received: from mail-wi0-f177.google.com ([209.85.212.177]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YT6N4-0004C8-KW for linux-arm-kernel@lists.infradead.org; Wed, 04 Mar 2015 10:17:43 +0000 Received: by wivz2 with SMTP id z2so9899716wiv.4 for ; Wed, 04 Mar 2015 02:17:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tj+x8w86QiVYzLPycR84WpeheCHgyIvGjJfuoGr0B8c=; b=ITjoT3/Q3imzUoE/jrylaXDjWW6Lw68RO4/3x5lO66GGYdOnq0BKgF3wxF6dlWIrun Mx2d/HE7pOg0FAkTC5eEr+ENVa2E73dMT0KDia1dQedBwJJnbolWFlA6RNQNrU0lxwQQ ehYWAZD6udOJ5VdmSmpLCUYGIGtYFlWYNinnB5BLPIJF2cAAyzietcDZ2IdfPkl+wu/D eesspXNG7LUqHJfYiqlIqoIluSJvoy8OivKiNhORWypWuBDCb2lFWXlHCkwMkQkVKCrv tXqxOkacbtRxhYYjdS1UKLYt1yytpwfctKpfMdfwfLSriAcbO+sHaxOBT1DkvlKVyqfB Ghww== X-Gm-Message-State: ALoCoQmh1GRG0Y/cuWzIZn8KBCcJPxjqFOeXiD7HyNhLNGztxBj2eCzKiOHbt8Z/g+i3LdZg9smV X-Received: by 10.181.8.75 with SMTP id di11mr54533955wid.26.1425464238903; Wed, 04 Mar 2015 02:17:18 -0800 (PST) Received: from gnx2579.gnb.st.com (LCaen-156-56-7-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by mx.google.com with ESMTPSA id j7sm6415582wix.4.2015.03.04.02.17.16 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 04 Mar 2015 02:17:18 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Subject: [PATCH v9 2/5] KVM: introduce kvm_arch_intc_initialized and use it in irqfd Date: Wed, 4 Mar 2015 11:14:33 +0100 Message-Id: <1425464076-20558-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425464076-20558-1-git-send-email-eric.auger@linaro.org> References: <1425464076-20558-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150304_021742_861317_0DC1B24E X-CRM114-Status: GOOD ( 11.69 ) X-Spam-Score: -0.7 (/) Cc: gleb@kernel.org, andre.przywara@arm.com, pbonzini@redhat.com, linux-kernel@vger.kernel.org, patches@linaro.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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Introduce __KVM_HAVE_ARCH_INTC_INITIALIZED define and associated kvm_arch_intc_initialized function. This latter allows to test whether the virtual interrupt controller is initialized and ready to accept virtual IRQ injection. On some architectures, the virtual interrupt controller is dynamically instantiated, justifying that kind of check. The new function can now be used by irqfd to check whether the virtual interrupt controller is ready on KVM_IRQFD request. If not, KVM_IRQFD returns -EAGAIN. Signed-off-by: Eric Auger Acked-by: Christoffer Dall Reviewed-by: Andre Przywara --- v7 -> v8: - correct typo in comment - add Andre's Reviewed-by v6 -> v7: - From now on, kvm_irqfd_assign calls kvm_arch_intc_initialized (previously introduced in subsequent patch file). - add Christoffer's ack v5 -> v6: - rename function name and macro - add kvm_arch_intc_initialized declaration in case the archi defines the macro --- include/linux/kvm_host.h | 14 ++++++++++++++ virt/kvm/eventfd.c | 3 +++ 2 files changed, 17 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index d12b210..ae9c720 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -700,6 +700,20 @@ static inline wait_queue_head_t *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu) #endif } +#ifdef __KVM_HAVE_ARCH_INTC_INITIALIZED +/* + * returns true if the virtual interrupt controller is initialized and + * ready to accept virtual IRQ. On some architectures the virtual interrupt + * controller is dynamically instantiated and this is not always true. + */ +bool kvm_arch_intc_initialized(struct kvm *kvm); +#else +static inline bool kvm_arch_intc_initialized(struct kvm *kvm) +{ + return true; +} +#endif + int kvm_arch_init_vm(struct kvm *kvm, unsigned long type); void kvm_arch_destroy_vm(struct kvm *kvm); void kvm_arch_sync_events(struct kvm *kvm); diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 148b239..fc5f43e 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -311,6 +311,9 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) unsigned int events; int idx; + if (!kvm_arch_intc_initialized(kvm)) + return -EAGAIN; + irqfd = kzalloc(sizeof(*irqfd), GFP_KERNEL); if (!irqfd) return -ENOMEM;