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: Auger Eric X-Patchwork-Id: 35915 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ig0-f199.google.com (mail-ig0-f199.google.com [209.85.213.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5125820565 for ; Mon, 25 Aug 2014 13:28:51 +0000 (UTC) Received: by mail-ig0-f199.google.com with SMTP id l13sf14594041iga.2 for ; Mon, 25 Aug 2014 06:28:50 -0700 (PDT) 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=WmdyzRcRM9LYjZjN54a+u8Y0QARqytV4nk/nhIFher4=; b=F/WM25vCD9ZVY3F0MdG3/lMHFrnVwHhHhbpdl0fSD3l3fL/nh30cBTG4U6GMTWwTYz em01Y5LyUNfJE9K1j2JhBZW44k2rekJsg1CDIZvwhwnwYpQjjxrN3BKz+2q0mYLiLAhJ s+jwGmJiFkwlZI+C5xiQuSsoLMbblVSRR3/j03soxOJQlOKcSYWk+VeYx2QWhMbRtWzd YQc+ZK2xwjX6/Ld+q08WF94X0K6ffkU9IDg9tT3AvQt+imhGsVB6JnKuB0L3d1owTZbj z7W2AayYFxoRXUX0kSEu47kyU2NT6OJzBExfKESxDbq8GMMPIxvnVVstpBRfOmt45HgY I1Jw== X-Gm-Message-State: ALoCoQnyhgiBkJ2XcZeMVp7U1C8znMRwGqHeP9zEnz1o0KtoRUnryx0fZdmUfD6hOLf8zoPPiHAL X-Received: by 10.182.32.1 with SMTP id e1mr14723915obi.11.1408973330917; Mon, 25 Aug 2014 06:28:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.138 with SMTP id h10ls643771qgh.87.gmail; Mon, 25 Aug 2014 06:28:50 -0700 (PDT) X-Received: by 10.220.184.70 with SMTP id cj6mr18801216vcb.5.1408973330755; Mon, 25 Aug 2014 06:28:50 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id ts3si1565155vcb.36.2014.08.25.06.28.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28:50 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id hy4so15053937vcb.36 for ; Mon, 25 Aug 2014 06:28:50 -0700 (PDT) X-Received: by 10.52.120.51 with SMTP id kz19mr527613vdb.95.1408973330673; Mon, 25 Aug 2014 06:28:50 -0700 (PDT) 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.221.45.67 with SMTP id uj3csp117330vcb; Mon, 25 Aug 2014 06:28:50 -0700 (PDT) X-Received: by 10.180.10.166 with SMTP id j6mr15635624wib.73.1408973329771; Mon, 25 Aug 2014 06:28:49 -0700 (PDT) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) by mx.google.com with ESMTPS id ef9si55884525wjd.82.2014.08.25.06.28.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 25 Aug 2014 06:28:49 -0700 (PDT) Received-SPF: pass (google.com: domain of eric.auger@linaro.org designates 74.125.82.48 as permitted sender) client-ip=74.125.82.48; Received: by mail-wg0-f48.google.com with SMTP id x13so13053164wgg.19 for ; Mon, 25 Aug 2014 06:28:49 -0700 (PDT) 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 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 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-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.220.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 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; }