From patchwork Mon Aug 25 13:27:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 4774941 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6356B9F2A9 for ; Mon, 25 Aug 2014 13:37:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 564D52012E for ; Mon, 25 Aug 2014 13:37:55 +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 4504A2012B for ; Mon, 25 Aug 2014 13:37:54 +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 1XLuQg-0004zX-Mk; Mon, 25 Aug 2014 13:35:26 +0000 Received: from mail-wg0-f42.google.com ([74.125.82.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XLuQd-0003mY-W3 for linux-arm-kernel@lists.infradead.org; Mon, 25 Aug 2014 13:35:24 +0000 Received: by mail-wg0-f42.google.com with SMTP id l18so12991287wgh.25 for ; Mon, 25 Aug 2014 06:35:00 -0700 (PDT) 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=WmdyzRcRM9LYjZjN54a+u8Y0QARqytV4nk/nhIFher4=; b=TQdtsF8kcU71btNS4bcjErpowk/HiTwGvrtQ+324dGeEkx+G9+58UWftVnZRiUzq5j HSA4SOpAlHjm4/pSAmGdx8Hah9YBaCBwnggY/ed2Iwwc9ohZCeE7JG6omMAgfGa+GBfC NZGnT3YYBpI11layXpcHB7WOmx/e5WKNIk/zV9iXuMuTzXAXkM7VdFThKiwDtsaLis80 wCCMFQ0RtucW/P6k+t5xBUyLIN3lrJFeukTL8tOcx/yMkTKEbjsiLkxDA/u/9Y0nWMb2 T0uQalrg/iI6DD7W3Phm0JRo9KXREA4dRW/RkAJG9XeWolzTQa9HZXABNLKx7OuyL8WB bL2g== X-Gm-Message-State: ALoCoQk4AyYh2VSOeYuJU5+I2DdEo4f6Jbdh9aWmxedzZzxPLZavY09X5jF4cm4/bpoUElXLB6wy X-Received: by 10.194.95.66 with SMTP id di2mr22459492wjb.47.1408973329276; Mon, 25 Aug 2014 06:28:49 -0700 (PDT) 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 co6sm100101595wjb.31.2014.08.25.06.28.47 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28:48 -0700 (PDT) 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, alex.williamson@redhat.com, joel.schopp@amd.com, kim.phillips@freescale.com Subject: [RFC 6/9] KVM: KVM-VFIO: allow arch specific implementation Date: Mon, 25 Aug 2014 15:27:41 +0200 Message-Id: <1408973264-30384-7-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408973264-30384-1-git-send-email-eric.auger@linaro.org> References: <1408973264-30384-1-git-send-email-eric.auger@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140825_063524_183580_93A2AF61 X-CRM114-Status: GOOD ( 11.02 ) X-Spam-Score: -0.7 (/) Cc: patches@linaro.org, john.liuli@huawei.com, will.deacon@arm.com, a.rigo@virtualopensystems.com, linux-kernel@vger.kernel.org, a.motakis@virtualopensystems.com 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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 a new option __KVM_HAVE_ARCH_KVM_VFIO option. When set the generic KVM-VFIO code calls architecture dependent code. the architecture dependent hooks are - kvm_arch_vfio_has_attr - kvm_arch_vfio_set_attr - kvm_arch_vfio_init - kvm_arch_vfio_destroy Signed-off-by: Eric Auger --- include/linux/kvm_host.h | 30 ++++++++++++++++++++++++++++++ virt/kvm/vfio.c | 9 +++++++++ 2 files changed, 39 insertions(+) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index a4c33b3..c4ce4af 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -1075,6 +1075,36 @@ extern struct kvm_device_ops kvm_vfio_ops; extern struct kvm_device_ops kvm_arm_vgic_v2_ops; extern struct kvm_device_ops kvm_flic_ops; +#ifdef __KVM_HAVE_ARCH_KVM_VFIO + +int kvm_arch_vfio_has_attr(struct kvm_device *dev, + struct kvm_device_attr *attr); +int kvm_arch_vfio_set_attr(struct kvm_device *dev, + struct kvm_device_attr *attr); +int kvm_arch_vfio_init(struct kvm_device *dev); + +void kvm_arch_vfio_destroy(struct kvm_device *dev); + +#else +static inline int kvm_arch_vfio_has_attr(struct kvm_device *dev, + struct kvm_device_attr *attr) +{ + return -ENXIO; +} +static inline int kvm_arch_vfio_set_attr(struct kvm_device *dev, + struct kvm_device_attr *attr) +{ + return -ENXIO; +} +static inline int kvm_arch_vfio_init(struct kvm_device *dev) +{ + return 0; +} +static inline void kvm_arch_vfio_destroy(struct kvm_device *dev) +{ +} +#endif + #ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT static inline void kvm_vcpu_set_in_spin_loop(struct kvm_vcpu *vcpu, bool val) diff --git a/virt/kvm/vfio.c b/virt/kvm/vfio.c index ba1a93f..89d3b75 100644 --- a/virt/kvm/vfio.c +++ b/virt/kvm/vfio.c @@ -207,6 +207,8 @@ static int kvm_vfio_set_attr(struct kvm_device *dev, switch (attr->group) { case KVM_DEV_VFIO_GROUP: return kvm_vfio_set_group(dev, attr->attr, attr->addr); + default: + return kvm_arch_vfio_set_attr(dev, attr); } return -ENXIO; @@ -224,6 +226,9 @@ static int kvm_vfio_has_attr(struct kvm_device *dev, } break; + + default: + kvm_arch_vfio_has_attr(dev, attr); } return -ENXIO; @@ -234,6 +239,8 @@ static void kvm_vfio_destroy(struct kvm_device *dev) struct kvm_vfio *kv = dev->private; struct kvm_vfio_group *kvg, *tmp; + kvm_arch_vfio_destroy(dev); + list_for_each_entry_safe(kvg, tmp, &kv->group_list, node) { kvm_vfio_group_put_external_user(kvg->vfio_group); list_del(&kvg->node); @@ -265,6 +272,8 @@ static int kvm_vfio_create(struct kvm_device *dev, u32 type) dev->private = kv; + kvm_arch_vfio_init(dev); + return 0; }