public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex@shazbot.org>
To: Mahmoud Adam <mngyadam@amazon.de>
Cc: <kvm@vger.kernel.org>, <jgg@ziepe.ca>, <kbusch@kernel.org>,
	<benh@kernel.crashing.org>, David Woodhouse <dwmw@amazon.co.uk>,
	<pravkmr@amazon.de>, <nagy@khwaternagy.com>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH 0/7] vfio: Add alias region uapi for device feature
Date: Wed, 15 Oct 2025 13:36:42 -0600	[thread overview]
Message-ID: <20251015133642.16134684@shazbot.org> (raw)
In-Reply-To: <20250924141018.80202-1-mngyadam@amazon.de>

On Wed, 24 Sep 2025 16:09:51 +0200
Mahmoud Adam <mngyadam@amazon.de> wrote:

> 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.

Sorry for the delayed feedback...

I think these should be described via capabilities returned with the
vfio_region_info rather than flags.  A flag that indicates the region
is an alias is really only useful for the restriction that we don't
want to allow aliases of aliases, but it doesn't provide full
introspection of what region this is actually an alias of.

The WC flag also doesn't allow much extension.  I think we want this to
have natural room to implement further mapping flags, so likely the
same capability that describes the region as being an alias should also
report back the mapping flags for the alias.  Thanks,

Alex

> 
> 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/20250811160710.174ca708.alex.williamson@redhat.com/
> 
> references:
> https://lore.kernel.org/kvm/20250804104012.87915-1-mngyadam@amazon.de/
> https://lore.kernel.org/kvm/20240731155352.3973857-1-kbusch@meta.com/
> 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(-)
> 


  parent reply	other threads:[~2025-10-15 19:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24 14:09 [RFC PATCH 0/7] vfio: Add alias region uapi for device feature Mahmoud Adam
2025-09-24 14:09 ` [RFC PATCH 1/7] vfio/pci: refactor region dereferences for RCU Mahmoud Adam
2025-09-24 14:09 ` [RFC PATCH 2/7] vfio_pci_core: split krealloc to allow use RCU & return index Mahmoud Adam
2025-09-24 14:09 ` [RFC PATCH 3/7] vfio/pci: add RCU locking for regions access Mahmoud Adam
2025-09-24 16:15   ` Mahmoud Nagy Adam
2025-09-24 14:09 ` [RFC PATCH 4/7] vfio: add FEATURE_ALIAS_REGION uapi Mahmoud Adam
2025-09-24 14:09 ` [RFC PATCH 5/7] vfio_pci_core: allow regions with no release op Mahmoud Adam
2025-09-24 14:09 ` [RFC PATCH 6/7] vfio-pci: add alias_region mmap ops Mahmoud Adam
2025-09-24 14:09 ` [RFC PATCH 7/7] vfio-pci-core: implement FEATURE_ALIAS_REGION uapi Mahmoud Adam
2025-10-03 21:58 ` [RFC PATCH 0/7] vfio: Add alias region uapi for device feature David Matlack
2025-10-05 10:16   ` Mahmoud Nagy Adam
2025-10-15 19:36 ` Alex Williamson [this message]
2025-10-27 16:32 ` David Matlack
2025-10-27 18:19   ` Mahmoud Nagy Adam

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=20251015133642.16134684@shazbot.org \
    --to=alex@shazbot.org \
    --cc=benh@kernel.crashing.org \
    --cc=dwmw@amazon.co.uk \
    --cc=jgg@ziepe.ca \
    --cc=kbusch@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mngyadam@amazon.de \
    --cc=nagy@khwaternagy.com \
    --cc=pravkmr@amazon.de \
    /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