From: Alex Williamson <alex.williamson@redhat.com>
To: kvm@vger.kernel.org
Cc: alex.williamson@redhat.com, allen.m.kay@intel.com,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 03/11] vfio: Define sparse mmap capability for regions
Date: Fri, 12 Feb 2016 17:02:15 -0700 [thread overview]
Message-ID: <20160213000215.17047.70709.stgit@gimli.home> (raw)
In-Reply-To: <20160212235331.17047.56669.stgit@gimli.home>
We can't always support mmap across an entire device region, for
example we deny mmaps covering the MSI-X table of PCI devices, but
we don't really have a way to report it. We expect the user to
implicitly know this restriction. We also can't split the region
because vfio-pci defines an API with fixed region index to BAR
number mapping. We therefore define a new capability which lists
areas within the region that may be mmap'd. In addition to the
MSI-X case, this potentially enables in-kernel emulation and
extensions to devices.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
include/uapi/linux/vfio.h | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index d508adf..fde7b1e 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -221,13 +221,37 @@ struct vfio_region_info {
#define VFIO_REGION_INFO_FLAG_READ (1 << 0) /* Region supports read */
#define VFIO_REGION_INFO_FLAG_WRITE (1 << 1) /* Region supports write */
#define VFIO_REGION_INFO_FLAG_MMAP (1 << 2) /* Region supports mmap */
+#define VFIO_REGION_INFO_FLAG_CAPS (1 << 3) /* Info supports caps */
__u32 index; /* Region index */
- __u32 resv; /* Reserved for alignment */
+ __u32 cap_offset; /* Offset within info struct of first cap */
__u64 size; /* Region size (bytes) */
__u64 offset; /* Region offset from start of device fd */
};
#define VFIO_DEVICE_GET_REGION_INFO _IO(VFIO_TYPE, VFIO_BASE + 8)
+/*
+ * The sparse mmap capability allows finer granularity of specifying areas
+ * within a region with mmap support. When specified, the user should only
+ * mmap the offset ranges specified by the areas array. mmaps outside of the
+ * areas specified may fail (such as the range covering a PCI MSI-X table) or
+ * may result in improper device behavior.
+ *
+ * The structures below define version 1 of this capability.
+ */
+#define VFIO_REGION_INFO_CAP_SPARSE_MMAP 1
+
+struct vfio_region_sparse_mmap_area {
+ __u64 offset; /* Offset of mmap'able area within region */
+ __u64 size; /* Size of mmap'able area */
+};
+
+struct vfio_region_info_cap_sparse_mmap {
+ struct vfio_info_cap_header header;
+ __u32 nr_areas;
+ __u32 reserved;
+ struct vfio_region_sparse_mmap_area areas[];
+};
+
/**
* VFIO_DEVICE_GET_IRQ_INFO - _IOWR(VFIO_TYPE, VFIO_BASE + 9,
* struct vfio_irq_info)
next prev parent reply other threads:[~2016-02-13 0:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-13 0:01 [PATCH v2 00/11] vfio: capability chains, sparse mmaps, device specific regions, IGD support Alex Williamson
2016-02-13 0:02 ` [PATCH v2 01/11] vfio: Define capability chains Alex Williamson
2016-02-13 0:02 ` [PATCH v2 02/11] vfio: Add capability chain helpers Alex Williamson
2016-02-13 0:02 ` Alex Williamson [this message]
2016-02-13 0:02 ` [PATCH v2 04/11] vfio/pci: Include sparse mmap capability for MSI-X table regions Alex Williamson
2016-02-13 0:02 ` [PATCH v2 05/11] vfio: Define device specific region type capability Alex Williamson
2016-02-13 0:02 ` [PATCH v2 06/11] vfio/pci: Add infrastructure for additional device specific regions Alex Williamson
2016-02-13 0:02 ` [PATCH v2 07/11] vfio/pci: Enable virtual register in PCI config space Alex Williamson
2016-02-13 0:02 ` [PATCH v2 08/11] vfio/pci: Intel IGD OpRegion support Alex Williamson
2016-02-13 0:02 ` [PATCH v2 09/11] vfio/pci: Intel IGD host and LCP bridge config space access Alex Williamson
2016-02-13 0:02 ` [PATCH v2 10/11] vfio/pci: Hide stolen memory from the user Alex Williamson
2016-02-13 0:03 ` [PATCH v2 11/11] vfio/pci: Expose shadow ROM as PCI option ROM Alex Williamson
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=20160213000215.17047.70709.stgit@gimli.home \
--to=alex.williamson@redhat.com \
--cc=allen.m.kay@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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).