From patchwork Mon Jan 19 16:43:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 43327 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 885A22034D for ; Mon, 19 Jan 2015 16:45:32 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id l18sf3754045wgh.3 for ; Mon, 19 Jan 2015 08:45:31 -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=urZSJHOXVRfymNNEccnoEVWILiLKAaPSuvnwtOyOy00=; b=kZO5yiZlRS5diQRsgNxL9AT0beK0Zjvis9QUUvWwYqXf464zeUU9vBwNxL6B4r4M6t O126GXRZDj53HTGE6IDm4vzMNTyUZ5Ga9lZ/NHuHJabFGwTED7C3t1l48K3mIZtpmn0B ePRzUgBn1s9uCnE2yBapGy20E84ZQNYDEURjK1flf5xpLZI8VB8h8uUNIVeOUcy+Z+LP 9DfMPMD44Cx9tm0Ym2k7FJcqhuqqeiD3RohyjqygQ7iWqe+yoWw+krD19ovtKlb8O+gD BLt5Znpczq0eb8FrUPS4jBn1rV4A3cFVCidUEJOq+XrrXR98nWTRD0VD5e5uwbTuyxYe BbJQ== X-Gm-Message-State: ALoCoQmnsfpwrBFa8DorJFDnKLhmtikPL20ktFT2gZMqfTkSq6TR+yI+vI+DjSSIueBZIsb3BFrR X-Received: by 10.194.178.234 with SMTP id db10mr3727462wjc.2.1421685931864; Mon, 19 Jan 2015 08:45:31 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.27.99 with SMTP id s3ls680912lag.79.gmail; Mon, 19 Jan 2015 08:45:31 -0800 (PST) X-Received: by 10.112.124.166 with SMTP id mj6mr3387629lbb.96.1421685931618; Mon, 19 Jan 2015 08:45:31 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id bj4si12484046lbc.69.2015.01.19.08.45.31 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Jan 2015 08:45:31 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ge10so8790073lab.10 for ; Mon, 19 Jan 2015 08:45:31 -0800 (PST) X-Received: by 10.152.27.8 with SMTP id p8mr26022540lag.69.1421685931326; Mon, 19 Jan 2015 08:45:31 -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 c8csp1148330lbb; Mon, 19 Jan 2015 08:45:30 -0800 (PST) X-Received: by 10.180.211.34 with SMTP id mz2mr36793325wic.18.1421685930604; Mon, 19 Jan 2015 08:45:30 -0800 (PST) Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com. [209.85.212.181]) by mx.google.com with ESMTPS id fk10si22771295wib.26.2015.01.19.08.45.29 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Jan 2015 08:45:29 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.181 as permitted sender) client-ip=209.85.212.181; Received: by mail-wi0-f181.google.com with SMTP id fb4so5151787wid.2 for ; Mon, 19 Jan 2015 08:45:29 -0800 (PST) X-Received: by 10.180.90.104 with SMTP id bv8mr37193200wib.67.1421685927607; Mon, 19 Jan 2015 08:45:27 -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 dp8sm14812495wib.20.2015.01.19.08.45.25 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Jan 2015 08:45:27 -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, gleb@kernel.org, pbonzini@redhat.com Cc: linux-kernel@vger.kernel.org, patches@linaro.org Subject: [PATCH v8 2/5] KVM: introduce kvm_arch_intc_initialized and use it in irqfd Date: Mon, 19 Jan 2015 17:43:10 +0100 Message-Id: <1421685793-3547-3-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421685793-3547-1-git-send-email-eric.auger@linaro.org> References: <1421685793-3547-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.215.51 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 26f1060..7f5858d 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 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;