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: Auger Eric X-Patchwork-Id: 45395 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f200.google.com (mail-we0-f200.google.com [74.125.82.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D106D21486 for ; Wed, 4 Mar 2015 10:17:20 +0000 (UTC) Received: by wesu56 with SMTP id u56sf33188870wes.1 for ; Wed, 04 Mar 2015 02:17:20 -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=tj+x8w86QiVYzLPycR84WpeheCHgyIvGjJfuoGr0B8c=; b=EVR9tRE1Z6GsHx7d5bWqq22hp9fGCABrlhXR7605wDcjXfG9Oyn8lrbpsy0SE/W0yI BsZQL+iQhjrTOL/v2ZCsqFhu3HTGrBP0+iCBNyk4i3QVt8D60uoX5BmAE8j1AwDxVIx3 MACEEbvm3Eiw7X2e1T+h87gcI6HST2NAFE2js9gbtUhrZCRNReqjjbtGT1spyofb6Xso vWv1z2HXUgnhDEwXPlALQFjmvuuJDV3+zKY0oX0xXlBY1cGq8JJ5utrqYpC5hXzvoEgZ 2OYOu5o7OoMgZ6Si1Y/E1raF/r48rBgEx66RThlFPyaTo3z1AEehs8mWyFw5pQjlyEqB FtNg== X-Gm-Message-State: ALoCoQmMRnadSSvrmGldHT3GCAsCkqzBykCV52sf8QrQpefVF0RVFeOgdsTovAlrGUlNu+330dD3 X-Received: by 10.152.4.229 with SMTP id n5mr527917lan.1.1425464240127; Wed, 04 Mar 2015 02:17:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.131 with SMTP id k3ls157624lak.21.gmail; Wed, 04 Mar 2015 02:17:20 -0800 (PST) X-Received: by 10.152.29.102 with SMTP id j6mr2864904lah.12.1425464239946; Wed, 04 Mar 2015 02:17:19 -0800 (PST) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id kz5si2222902lab.65.2015.03.04.02.17.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2015 02:17:19 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbiz11 with SMTP id z11so17197131lbi.13 for ; Wed, 04 Mar 2015 02:17:19 -0800 (PST) X-Received: by 10.152.1.135 with SMTP id 7mr2620039lam.41.1425464239863; Wed, 04 Mar 2015 02:17:19 -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.35.133 with SMTP id h5csp1122957lbj; Wed, 4 Mar 2015 02:17:19 -0800 (PST) X-Received: by 10.181.13.148 with SMTP id ey20mr11144096wid.18.1425464239165; Wed, 04 Mar 2015 02:17:19 -0800 (PST) Received: from mail-we0-f174.google.com (mail-we0-f174.google.com. [74.125.82.174]) by mx.google.com with ESMTPS id fs7si7583062wic.22.2015.03.04.02.17.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2015 02:17:19 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.174 as permitted sender) client-ip=74.125.82.174; Received: by wesq59 with SMTP id q59so8338264wes.3 for ; Wed, 04 Mar 2015 02:17:18 -0800 (PST) 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 Cc: andre.przywara@arm.com, linux-kernel@vger.kernel.org, patches@linaro.org, gleb@kernel.org, pbonzini@redhat.com 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-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.174 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 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;