From: sashiko-bot@kernel.org
To: "Piórkowski, Piotr" <piotr.piorkowski@intel.com>, kvm@vger.kernel.org
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [RFC PATCH 2/4] vfio/pci: Allow hiding BAR ranges from the VFIO user
Date: Thu, 05 Nov 2026 16:24:56 +0000 [thread overview]
Message-ID: <sashiko-outbox-199483@kernel.org> (raw)
In-Reply-To: <20261105153738.1938345-3-piotr.piorkowski@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] vfio/pci: MSIX_MAPPABLE cap added before vfio_pci_hidden_add_sparse_mmap()
--
commit 34f058d0ce2fee9063501ec235bccdb3f8fe57f0
Author: Piotr Piórkowski <piotr.piorkowski@intel.com>
vfio/pci: Allow hiding BAR ranges from the VFIO user
This commit adds vfio_pci_core_hide_bar_ranges() to allow VFIO PCI drivers
to hide parts of their memory BARs from userspace across region reads and
writes, mmap, ioeventfd, and dma-buf operations, while listing the hidden
ranges in sysfs.
> diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c
> index fcbb2da860e2a..cd6cb3d829b51 100644
> --- a/drivers/vfio/pci/vfio_pci_core.c
> +++ b/drivers/vfio/pci/vfio_pci_core.c
> @@ -1147,6 +1147,10 @@ int vfio_pci_ioctl_get_region_info(struct vfio_device *core_vdev,
> if (ret)
> return ret;
> }
> +
> + ret = vfio_pci_hidden_add_sparse_mmap(vdev, info, caps);
> + if (ret)
> + return ret;
> }
>
> break;
[Severity: Medium]
Does calling msix_mmappable_cap() before vfio_pci_hidden_add_sparse_mmap()
report inconsistent region capabilities when hidden ranges are present on
vdev->msix_bar?
In vfio_pci_ioctl_get_region_info(), when vdev->bar_mmap_supported[info->index]
is true and info->index == vdev->msix_bar, msix_mmappable_cap() appends
VFIO_REGION_INFO_CAP_MSIX_MAPPABLE to caps before
vfio_pci_hidden_add_sparse_mmap() runs:
drivers/vfio/pci/vfio_pci_core.c:vfio_pci_ioctl_get_region_info() {
if (vdev->bar_mmap_supported[info->index]) {
info->flags |= VFIO_REGION_INFO_FLAG_MMAP;
if (info->index == vdev->msix_bar) {
ret = msix_mmappable_cap(vdev, caps);
if (ret)
return ret;
}
ret = vfio_pci_hidden_add_sparse_mmap(vdev, info, caps);
if (ret)
return ret;
}
}
If hidden ranges cover all pages of that BAR, vfio_pci_hidden_add_sparse_mmap()
computes nr_areas == 0 and clears VFIO_REGION_INFO_FLAG_MMAP:
drivers/vfio/pci/vfio_pci_hidden_bar_ranges.c:vfio_pci_hidden_add_sparse_mmap() {
if (!nr_areas) {
info->flags &= ~VFIO_REGION_INFO_FLAG_MMAP;
goto out;
}
}
Because VFIO_REGION_INFO_CAP_MSIX_MAPPABLE was already added to caps,
VFIO_DEVICE_GET_REGION_INFO will return a region with
VFIO_REGION_INFO_FLAG_MMAP cleared while still advertising
VFIO_REGION_INFO_FLAG_CAPS and VFIO_REGION_INFO_CAP_MSIX_MAPPABLE.
Similarly, even when nr_areas > 0, if a hidden range overlaps the page(s)
containing the MSI-X table (vdev->msix_offset to vdev->msix_offset +
vdev->msix_size), those pages are excluded from
VFIO_REGION_INFO_CAP_SPARSE_MMAP and faulting them in
vfio_pci_mmap_huge_fault() returns VM_FAULT_SIGBUS, while
VFIO_REGION_INFO_CAP_MSIX_MAPPABLE still tells userspace the MSI-X range is
mmappable.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105153738.1938345-1-piotr.piorkowski@intel.com?part=2
next prev parent reply other threads:[~2026-11-05 16:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 15:37 [RFC PATCH 0/4] vfio/pci: Allow hiding BAR ranges from the VFIO user Piórkowski, Piotr
2026-11-05 15:37 ` [RFC PATCH 1/4] vfio/pci: Move the excluded range handling out of vfio_pci_core_do_io_rw() Piórkowski, Piotr
2026-11-05 15:37 ` [RFC PATCH 2/4] vfio/pci: Allow hiding BAR ranges from the VFIO user Piórkowski, Piotr
2026-11-05 16:24 ` sashiko-bot [this message]
2026-11-05 15:37 ` [RFC PATCH 3/4] vfio/pci: Allow configuring hidden BAR ranges through configfs Piórkowski, Piotr
2026-11-05 15:37 ` [RFC PATCH 4/4] vfio/xe: Hide BAR ranges by default per device ID Piórkowski, Piotr
2026-11-05 15:55 ` Alex Williamson
2026-11-05 17:50 ` Piotr Piórkowski
2026-11-05 15:50 ` [RFC PATCH 0/4] vfio/pci: Allow hiding BAR ranges from the VFIO user 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=sashiko-outbox-199483@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=kvm@vger.kernel.org \
--cc=piotr.piorkowski@intel.com \
--cc=sashiko-reviews@lists.linux.dev \
/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