RFC vfio: Add alias region uapi for device feature
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest7 patches 6 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/7 | vfio/pci: refactor region dereferences for RCU.drivers/ drivers/ | +26 | 0 replies | |
| 2/7 | vfio_pci_core: split krealloc to allow use RCU & return indexdrivers/ drivers/ | +24 | 0 replies | |
| 3/7 | vfio/pci: add RCU locking for regions accessdrivers/ drivers/ include/ | +55 | 1 reply | |
| 4/7 | vfio: add FEATURE_ALIAS_REGION uapiinclude/ | +24 | 0 replies | |
| 5/7 | vfio_pci_core: allow regions with no release opdrivers/ | +2 | 0 replies | |
| 6/7 | vfio-pci: add alias_region mmap opsdrivers/ | +27 | 0 replies | |
| 7/7 | vfio-pci-core: implement FEATURE_ALIAS_REGION uapidrivers/ | +161 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 0/7] vfio: Add alias region uapi for device feature
This RFC proposes a new uapi VFIO DEVICE_FEATURE to create per-region aliases with selectable attributes, initially enabling write-combine (WC) where supported by the underlying region. The goal is to expose a UAPI for userspace to request an alias of an existing VFIO region with extra flags, then interact with it via a stable alias index through existing ioctls and mmap where applicable.
This proposal is following Alex's suggestion [1]. This uapi allows creating a region alias where the user could specify to enable certain attributes through the alias. And then could use the alias index to get the region info and grab the offset to operate on.
One example is to create a new Alias for bar 0 or similar BAR with WC enabled. Then you can use the alias offset to mmap to the region with WC enabled.
The uapi allows the user to request a region index to alias and the extra flags to be set. Users can PROBE to get which flags are supported by this region. The flags are the same to the region flags in the region_info uapi.
This adds two new region flags:
- VFIO_REGION_INFO_FLAG_ALIAS: set on alias regions.
- VFIO_REGION_INFO_FLAG_WC: indicates WC is in effect for that region.
Then this series implement this uapi on vfio-pci. For vfio-pci, Alias regions are only (for now) possible for mmap supported regions. There could be future usages for these alias regions other than mmaps (like I think we could use it to also allow to use read & write on pci_iomap_wc version of the region?). In case if similar alias region already exist return the current alias index to the user.
To mmap the region alias, we use the mmap region ops. Through that we translate the vm_pgoff to its aliased region and call vfio_device mmap with the alias pgoff. This enables us to mmap the original region then update the pgrot for WC afterwards.
The call path would be:vfio_pci_core_mmap (index >= VFIO_PCI_NUM_REGIONS)
vfio_pci_alias_region_mmap (update vm_pgoff)
vfio_pci_core_mmap
This series also adds required locking for region array accessing. Since now regions are added after initial setup.
[1]: https://lore.kernel.org/kvm/[email protected]/
references:
https://lore.kernel.org/kvm/[email protected]/
https://lore.kernel.org/kvm/[email protected]/
https://lore.kernel.org/kvm/lrkyq4ivccb6x.fsf@dev-dsk-mngyadam-1c-cb3f7548.eu-west-1.amazon.com/
Mahmoud Adam (7):
vfio/pci: refactor region dereferences for RCU.
vfio_pci_core: split krealloc to allow use RCU & return index vfio/pci: add RCU locking for regions access
vfio: add FEATURE_ALIAS_REGION uapi
vfio_pci_core: allow regions with no release op
vfio-pci: add alias_region mmap ops
vfio-pci-core: implement FEATURE_ALIAS_REGION uapi
drivers/vfio/pci/vfio_pci_core.c | 289 +++++++++++++++++++++++++++---- drivers/vfio/pci/vfio_pci_igd.c | 34 +++- include/linux/vfio_pci_core.h | 1 + include/uapi/linux/vfio.h | 24 +++ 4 files changed, 301 insertions(+), 47 deletions(-)
Signature · 12 lines
2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christian Schlaeger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597