From: Alex Williamson <alex.williamson@redhat.com>
To: kvm@vger.kernel.org, gleb@redhat.com
Cc: aik@ozlabs.ru, benh@kernel.crashing.org, bsd@redhat.com,
linux-kernel@vger.kernel.org, mst@redhat.com
Subject: [RFC PATCH 2/3] vfio: Add check extension interface to external user support
Date: Thu, 12 Sep 2013 15:23:08 -0600 [thread overview]
Message-ID: <20130912212308.8542.97753.stgit@bling.home> (raw)
In-Reply-To: <20130912211401.8542.82932.stgit@bling.home>
This adds the ability for an external user to check VFIO extensions.
The first one we care about is support for IOMMU cache coherency.
Without this, external users, like KVM, would need to assume the IOMMU
allows No-Snoop transactions which are not coherent with processor
cache.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/vfio/vfio.c | 8 ++++++++
drivers/vfio/vfio_iommu_type1.c | 4 ++++
include/linux/vfio.h | 2 ++
include/uapi/linux/vfio.h | 1 +
4 files changed, 15 insertions(+)
diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
index 1eab4ac..b55979e 100644
--- a/drivers/vfio/vfio.c
+++ b/drivers/vfio/vfio.c
@@ -1414,6 +1414,14 @@ int vfio_external_user_iommu_id(struct vfio_group *group)
}
EXPORT_SYMBOL_GPL(vfio_external_user_iommu_id);
+int vfio_external_user_check_extension(struct vfio_group *group,
+ unsigned long arg)
+{
+ return vfio_ioctl_check_extension(group->container, arg);
+
+}
+EXPORT_SYMBOL_GPL(vfio_external_user_check_extension);
+
/**
* Module/class support
*/
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index a9807de..b88b9f7 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -840,6 +840,10 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
switch (arg) {
case VFIO_TYPE1_IOMMU:
return 1;
+ case VFIO_IOMMU_CAP_CACHE_COHERENCY:
+ return !iommu ? 0 :
+ iommu_domain_has_cap(iommu->domain,
+ IOMMU_CAP_CACHE_COHERENCY);
default:
return 0;
}
diff --git a/include/linux/vfio.h b/include/linux/vfio.h
index 24579a0..fe528e8 100644
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -96,5 +96,7 @@ extern void vfio_unregister_iommu_driver(
extern struct vfio_group *vfio_group_get_external_user(struct file *filep);
extern void vfio_group_put_external_user(struct vfio_group *group);
extern int vfio_external_user_iommu_id(struct vfio_group *group);
+extern int vfio_external_user_check_extension(struct vfio_group *group,
+ unsigned long arg);
#endif /* VFIO_H */
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 0fd47f5..1c8bad6 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -23,6 +23,7 @@
#define VFIO_TYPE1_IOMMU 1
#define VFIO_SPAPR_TCE_IOMMU 2
+#define VFIO_IOMMU_CAP_CACHE_COHERENCY 3
/*
* The IOCTL interface is designed for extensibility by embedding the
next prev parent reply other threads:[~2013-09-12 21:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-12 21:22 [RFC PATCH 0/3] kvm/vfio: Manage KVM IOMMU coherency with virtual VFIO device Alex Williamson
2013-09-12 21:23 ` [RFC PATCH 1/3] kvm: Destroy & free KVM devices on release Alex Williamson
2013-09-12 21:23 ` Alex Williamson [this message]
2013-09-12 21:23 ` [RFC PATCH 3/3] kvm: Add VFIO device for handling IOMMU cache coherency Alex Williamson
2013-09-13 8:49 ` Alexey Kardashevskiy
2013-09-13 16:25 ` Alex Williamson
2013-09-15 12:40 ` Alexey Kardashevskiy
2013-09-25 20:19 ` Alex Williamson
2013-09-26 4:31 ` Alexey Kardashevskiy
2013-09-13 12:39 ` Michael S. Tsirkin
2013-09-13 14:13 ` Alex Williamson
2013-09-13 14:52 ` Michael S. Tsirkin
2013-09-13 15:29 ` Alex Williamson
2013-09-29 13:16 ` Gleb Natapov
2013-09-29 13:52 ` Alex Williamson
2013-09-29 14:44 ` Gleb Natapov
2013-09-29 15:55 ` Alex Williamson
2013-09-30 13:23 ` Gleb Natapov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130912212308.8542.97753.stgit@bling.home \
--to=alex.williamson@redhat.com \
--cc=aik@ozlabs.ru \
--cc=benh@kernel.crashing.org \
--cc=bsd@redhat.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).