From patchwork Tue Jan 13 17:33:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Auger Eric X-Patchwork-Id: 43074 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BD40926CFB for ; Tue, 13 Jan 2015 17:35:50 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id n3sf2695523wiv.1 for ; Tue, 13 Jan 2015 09:35:50 -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=HzlsIRBq6vllSfbKmYyvgWLe3OoGvk/tqRPVZV/zQRE=; b=BkV06f+p4dTALs+MMaJasULlsBYbrotally1YFCrI4nbngN+TTVu08e8o+hq8TN/ZB o7TrtbD7KaeAWEADKEt4fjU4If2OEqllEjd1Is1pT1bCbrrpdhQNUTT/Kffe36xSLNTx V4s+DAp267fmkOJJt4ZtkZcMIq5THLo3TCRk8PpAUr4tM/xkTEgrOitLHzAY9rVV8lsx C8xyWNw8KgBs4b52hiDVeyri/hJDhipQlrzZ6bBAP4UfNjvgiq8xEFlrQFyoVezItwxd loZVoVopI9gMVilv6O7ho/TZnkToey1g9/NBMbGj+gTuCVmQD+T8/afbJaXIVJtEOBkS tIfw== X-Gm-Message-State: ALoCoQmiGlixwYY2V2TOCjCzQbBTRhExHmpd9bhYjhzSpEtKP9bbehM7RlcZKz2/xAyzufn5TKa+ X-Received: by 10.180.85.230 with SMTP id k6mr2590922wiz.1.1421170550113; Tue, 13 Jan 2015 09:35:50 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.100 with SMTP id p4ls27131laj.24.gmail; Tue, 13 Jan 2015 09:35:49 -0800 (PST) X-Received: by 10.152.29.193 with SMTP id m1mr43387240lah.84.1421170549957; Tue, 13 Jan 2015 09:35:49 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id xb8si24833666lbb.109.2015.01.13.09.35.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 09:35:49 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id u14so3792323lbd.9 for ; Tue, 13 Jan 2015 09:35:49 -0800 (PST) X-Received: by 10.112.131.1 with SMTP id oi1mr42728635lbb.2.1421170549541; Tue, 13 Jan 2015 09:35:49 -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 c8csp1451449lbb; Tue, 13 Jan 2015 09:35:48 -0800 (PST) X-Received: by 10.194.24.103 with SMTP id t7mr71852088wjf.15.1421170548386; Tue, 13 Jan 2015 09:35:48 -0800 (PST) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com. [209.85.212.174]) by mx.google.com with ESMTPS id i2si21328284wiy.102.2015.01.13.09.35.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 09:35:48 -0800 (PST) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 209.85.212.174 as permitted sender) client-ip=209.85.212.174; Received: by mail-wi0-f174.google.com with SMTP id h11so22954642wiw.1 for ; Tue, 13 Jan 2015 09:35:48 -0800 (PST) X-Received: by 10.180.101.98 with SMTP id ff2mr42367852wib.83.1421170547459; Tue, 13 Jan 2015 09:35:47 -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 fw6sm2660487wib.1.2015.01.13.09.35.44 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 Jan 2015 09:35:46 -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, joel.schopp@amd.com, kim.phillips@freescale.com, paulus@samba.org, 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, a.rigo@virtualopensystems.com, john.liuli@huawei.com, ming.lei@canonical.com, feng.wu@intel.com, b.reynal@virtualopensystems.com Subject: [PATCH v6 3/4] KVM: arm/arm64: implement kvm_arch_intc_initialized and use it in irqfd Date: Tue, 13 Jan 2015 18:33:39 +0100 Message-Id: <1421170420-30617-4-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421170420-30617-1-git-send-email-eric.auger@linaro.org> References: <1421170420-30617-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.178 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: , On arm/arm64 the VGIC is dynamically instantiated and it is useful to expose its state, especially for irqfd setup. This patch defines __KVM_HAVE_ARCH_INTC_INITIALIZED and implements kvm_arch_intc_initialized. 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 --- v5 -> v6: - remove kvm_arch_intc_initialized declaration from architecture specific kvm_host.h since it is now in generic kvm_host.h - squash v5 patch files 3 & 4 --- arch/arm/include/asm/kvm_host.h | 2 ++ arch/arm/kvm/arm.c | 5 +++++ arch/arm64/include/asm/kvm_host.h | 2 ++ virt/kvm/eventfd.c | 3 +++ 4 files changed, 12 insertions(+) diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h index 254e065..8f87259 100644 --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -27,6 +27,8 @@ #include #include +#define __KVM_HAVE_ARCH_INTC_INITIALIZED + #if defined(CONFIG_KVM_ARM_MAX_VCPUS) #define KVM_MAX_VCPUS CONFIG_KVM_ARM_MAX_VCPUS #else diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 2d6d910..9c905b4 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c @@ -454,6 +454,11 @@ static int kvm_vcpu_first_run_init(struct kvm_vcpu *vcpu) return 0; } +bool kvm_arch_intc_initialized(struct kvm *kvm) +{ + return vgic_initialized(kvm); +} + static void vcpu_pause(struct kvm_vcpu *vcpu) { wait_queue_head_t *wq = kvm_arch_vcpu_wq(vcpu); diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 0b7dfdb..dfb6135 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -28,6 +28,8 @@ #include #include +#define __KVM_HAVE_ARCH_INTC_INITIALIZED + #if defined(CONFIG_KVM_ARM_MAX_VCPUS) #define KVM_MAX_VCPUS CONFIG_KVM_ARM_MAX_VCPUS #else 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;