From patchwork Thu Jan 15 14:47:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 43184 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 8BB3A240BA for ; Thu, 15 Jan 2015 14:49:57 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e49sf2166370eek.3 for ; Thu, 15 Jan 2015 06:49:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=ZO/Fws5uP8TDqtlfuavw0TLZTt5+MDyX4sTQgMzCgBQ=; b=OAZh9kkFprUuJSAVarfySp+Jwu3rzZqLBoKIWeRU6fN6uXDJawt7Yeqo5LfolFNTgo +aLYE4eq0eH+IXGNWwxx+6UoI0Ek5ZKClJfuq2zt0clfPuFf51SijLAjKX55bZ57j01e eednnWlxhPNN0Wnyf2gcjztUE3sP+Rh4zO3ypJS+MB4SWQm7GKctxeo2LUcmRaUKwolQ xL8B+aH0I5kvsEv1dN9vsPClO5e9M3/1p27rD44K68pWXOqxn4LWq5gw/g8aPxCHI6s0 g/qQYQqH5MXh8bupKqiUBt4SLN/Bh+jzbumgFPSI2j8m3XWDb+1Yecdn+UtiZjSwdlYS 7q4Q== X-Gm-Message-State: ALoCoQnTmQlCJVZuWFLeJyjnTWCxSUMsJAxr39hcrfZYYcUSxa3/yVBXpEvQWsaLRS0G+j0xOfoD X-Received: by 10.180.19.70 with SMTP id c6mr3101990wie.0.1421333396802; Thu, 15 Jan 2015 06:49:56 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.115.193 with SMTP id jq1ls236269lab.85.gmail; Thu, 15 Jan 2015 06:49:56 -0800 (PST) X-Received: by 10.112.132.2 with SMTP id oq2mr10198280lbb.11.1421333396605; Thu, 15 Jan 2015 06:49:56 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id ll1si1653350lac.41.2015.01.15.06.49.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 06:49:56 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id b6so13576704lbj.8 for ; Thu, 15 Jan 2015 06:49:56 -0800 (PST) X-Received: by 10.112.180.135 with SMTP id do7mr10007915lbc.23.1421333396513; Thu, 15 Jan 2015 06:49:56 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.9.200 with SMTP id c8csp6372lbb; Thu, 15 Jan 2015 06:49:56 -0800 (PST) X-Received: by 10.180.97.106 with SMTP id dz10mr20267227wib.6.1421333395856; Thu, 15 Jan 2015 06:49:55 -0800 (PST) Received: from mail-we0-f177.google.com (mail-we0-f177.google.com. [74.125.82.177]) by mx.google.com with ESMTPS id q3si9795677wia.78.2015.01.15.06.49.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 06:49:55 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.177 as permitted sender) client-ip=74.125.82.177; Received: by mail-we0-f177.google.com with SMTP id q59so15089822wes.8 for ; Thu, 15 Jan 2015 06:49:55 -0800 (PST) X-Received: by 10.194.206.70 with SMTP id lm6mr19127712wjc.30.1421333395429; Thu, 15 Jan 2015 06:49:55 -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 i3sm2389150wjw.2.2015.01.15.06.49.53 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 15 Jan 2015 06:49:54 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, christoffer.dall@linaro.org, marc.zyngier@arm.com, andre.przywara@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, alex.williamson@redhat.com, agraf@suse.de, gleb@kernel.org, pbonzini@redhat.com, borntraeger@de.ibm.com, cornelia.huck@de.ibm.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org, will.deacon@arm.com, a.motakis@virtualopensystems.com Subject: [PATCH v7 2/4] KVM: introduce kvm_arch_intc_initialized and use it in irqfd Date: Thu, 15 Jan 2015 15:47:45 +0100 Message-Id: <1421333267-15287-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421333267-15287-1-git-send-email-eric.auger@linaro.org> References: <1421333267-15287-1-git-send-email-eric.auger@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: eric.auger@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.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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 26f1060..702036a 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -706,6 +706,20 @@ static inline wait_queue_head_t *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu) #endif } +#ifdef __KVM_HAVE_ARCH_INTC_INITIALIZED +/* + * returns trues 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;