From: Alex Williamson <alex@shazbot.org>
To: "Piórkowski, Piotr" <piotr.piorkowski@intel.com>,
"Shameer Kolothum" <skolothumtho@nvidia.com>
Cc: kvm@vger.kernel.org, intel-xe@lists.freedesktop.org,
"Michał Winiarski" <michal.winiarski@intel.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"Yishai Hadas" <yishaih@nvidia.com>,
"Kevin Tian" <kevin.tian@intel.com>,
alex@shazbot.org
Subject: Re: [RFC PATCH 4/4] vfio/xe: Hide BAR ranges by default per device ID
Date: Thu, 5 Nov 2026 08:55:58 -0700 [thread overview]
Message-ID: <20261105085558.75666f25@shazbot.org> (raw)
In-Reply-To: <20261105153738.1938345-5-piotr.piorkowski@intel.com>
On Thu, 5 Nov 2026 16:37:38 +0100
"Piórkowski, Piotr" <piotr.piorkowski@intel.com> wrote:
> From: Piotr Piórkowski <piotr.piorkowski@intel.com>
>
> xe-vfio-pci accesses the BARs only through vfio-pci-core, so opt in to
> hidden BAR ranges.
>
> Let each entry of the PCI ID table describe the ranges to hide by
> default. The description is always looked up in the static table, so
> binding through new_id or driver_override can't skip them.
>
> No device defines any ranges yet.
We don't merge dead code, so the whole series is to justify the
configfs mechanism to introduce excluded ranges without publishing them
to the community? Hard no. Thanks,
Alex
>
> Cc: Michał Winiarski <michal.winiarski@intel.com>
> Cc: Alex Williamson <alex@shazbot.org>
> Cc: Jason Gunthorpe <jgg@ziepe.ca>
> Cc: Yishai Hadas <yishaih@nvidia.com>
> Cc: Shameer Kolothum <skolothumtho@nvidia.com>
> Cc: Kevin Tian <kevin.tian@intel.com>
> Signed-off-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
> ---
> drivers/vfio/pci/xe/main.c | 60 ++++++++++++++++++++++++++++----------
> 1 file changed, 45 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/vfio/pci/xe/main.c b/drivers/vfio/pci/xe/main.c
> index 7dab3e024aa8a..e63af6123f598 100644
> --- a/drivers/vfio/pci/xe/main.c
> +++ b/drivers/vfio/pci/xe/main.c
> @@ -24,6 +24,16 @@ struct xe_vfio_pci_migration_file {
> u8 disabled:1;
> };
>
> +/**
> + * struct xe_vfio_pci_desc - device specific description
> + * @hidden_ranges: BAR ranges hidden from the VFIO user by default
> + * @num_hidden_ranges: number of entries in @hidden_ranges
> + */
> +struct xe_vfio_pci_desc {
> + const struct vfio_pci_bar_range *hidden_ranges;
> + unsigned int num_hidden_ranges;
> +};
> +
> struct xe_vfio_pci_core_device {
> struct vfio_pci_core_device core_device;
> struct xe_device *xe;
> @@ -543,8 +553,32 @@ static const struct vfio_device_ops xe_vfio_pci_ops = {
> .detach_ioas = vfio_iommufd_physical_detach_ioas,
> };
>
> +#define INTEL_PCI_VFIO_DEVICE(_id, _desc) { \
> + PCI_DRIVER_OVERRIDE_DEVICE_VFIO(PCI_VENDOR_ID_INTEL, (_id)), \
> + .driver_data = (kernel_ulong_t)(_desc), \
> +}
> +
> +static const struct pci_device_id xe_vfio_pci_table[] = {
> + INTEL_BMG_IDS(INTEL_PCI_VFIO_DEVICE, NULL),
> + INTEL_CRI_IDS(INTEL_PCI_VFIO_DEVICE, NULL),
> + INTEL_NVLS_IDS(INTEL_PCI_VFIO_DEVICE, NULL),
> + INTEL_NVLP_IDS(INTEL_PCI_VFIO_DEVICE, NULL),
> + INTEL_PTL_IDS(INTEL_PCI_VFIO_DEVICE, NULL),
> + INTEL_WCL_IDS(INTEL_PCI_VFIO_DEVICE, NULL),
> + {}
> +};
> +MODULE_DEVICE_TABLE(pci, xe_vfio_pci_table);
> +
> static int xe_vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> {
> + /*
> + * Dynamic IDs added through new_id are matched before the static ones
> + * and carry no driver data, look the description up in the static
> + * table so that they can't bypass the default hidden ranges.
> + */
> + const struct pci_device_id *match = pci_match_id(xe_vfio_pci_table, pdev);
> + const struct xe_vfio_pci_desc *desc =
> + match ? (const void *)match->driver_data : NULL;
> struct xe_vfio_pci_core_device *xe_vdev;
> int ret;
>
> @@ -554,6 +588,17 @@ static int xe_vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
> return PTR_ERR(xe_vdev);
>
> dev_set_drvdata(&pdev->dev, xe_vdev);
> + xe_vdev->core_device.hidden_ranges_supported = true;
> +
> + if (desc) {
> + ret = vfio_pci_core_hide_bar_ranges(&xe_vdev->core_device,
> + desc->hidden_ranges,
> + desc->num_hidden_ranges);
> + if (ret) {
> + vfio_put_device(&xe_vdev->core_device.vdev);
> + return ret;
> + }
> + }
>
> ret = vfio_pci_core_register_device(&xe_vdev->core_device);
> if (ret) {
> @@ -572,21 +617,6 @@ static void xe_vfio_pci_remove(struct pci_dev *pdev)
> vfio_put_device(&xe_vdev->core_device.vdev);
> }
>
> -#define INTEL_PCI_VFIO_DEVICE(_id) { \
> - PCI_DRIVER_OVERRIDE_DEVICE_VFIO(PCI_VENDOR_ID_INTEL, (_id)) \
> -}
> -
> -static const struct pci_device_id xe_vfio_pci_table[] = {
> - INTEL_BMG_IDS(INTEL_PCI_VFIO_DEVICE),
> - INTEL_CRI_IDS(INTEL_PCI_VFIO_DEVICE),
> - INTEL_NVLS_IDS(INTEL_PCI_VFIO_DEVICE),
> - INTEL_NVLP_IDS(INTEL_PCI_VFIO_DEVICE),
> - INTEL_PTL_IDS(INTEL_PCI_VFIO_DEVICE),
> - INTEL_WCL_IDS(INTEL_PCI_VFIO_DEVICE),
> - {}
> -};
> -MODULE_DEVICE_TABLE(pci, xe_vfio_pci_table);
> -
> static struct pci_driver xe_vfio_pci_driver = {
> .name = "xe-vfio-pci",
> .id_table = xe_vfio_pci_table,
next prev parent reply other threads:[~2026-11-05 15:56 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
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 [this message]
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=20261105085558.75666f25@shazbot.org \
--to=alex@shazbot.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jgg@ziepe.ca \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=michal.winiarski@intel.com \
--cc=piotr.piorkowski@intel.com \
--cc=skolothumtho@nvidia.com \
--cc=yishaih@nvidia.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