From: Jonathan Cameron via <qemu-devel@nongnu.org>
To: Shameer Kolothum <skolothumtho@nvidia.com>
Cc: "qemu-arm@nongnu.org" <qemu-arm@nongnu.org>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"peter.maydell@linaro.org" <peter.maydell@linaro.org>,
Jason Gunthorpe <jgg@nvidia.com>,
Nicolin Chen <nicolinc@nvidia.com>,
"ddutile@redhat.com" <ddutile@redhat.com>,
"berrange@redhat.com" <berrange@redhat.com>,
"Nathan Chen" <nathanc@nvidia.com>, Matt Ochs <mochs@nvidia.com>,
"smostafa@google.com" <smostafa@google.com>,
"wangzhou1@hisilicon.com" <wangzhou1@hisilicon.com>,
"jiangkunkun@huawei.com" <jiangkunkun@huawei.com>,
"zhangfei.gao@linaro.org" <zhangfei.gao@linaro.org>,
"zhenzhong.duan@intel.com" <zhenzhong.duan@intel.com>,
"yi.l.liu@intel.com" <yi.l.liu@intel.com>,
"shameerkolothum@gmail.com" <shameerkolothum@gmail.com>
Subject: Re: [PATCH v4 26/27] vfio: Synthesize vPASID capability to VM
Date: Thu, 2 Oct 2025 10:58:24 +0100 [thread overview]
Message-ID: <20251002105824.00005ddd@huawei.com> (raw)
In-Reply-To: <CH3PR12MB75485C98CAB78552EC4C1597ABE7A@CH3PR12MB7548.namprd12.prod.outlook.com>
On Thu, 2 Oct 2025 08:03:09 +0000
Shameer Kolothum <skolothumtho@nvidia.com> wrote:
> > -----Original Message-----
> > From: Jonathan Cameron <jonathan.cameron@huawei.com>
> > Sent: 01 October 2025 14:58
> > To: Shameer Kolothum <skolothumtho@nvidia.com>
> > Cc: qemu-arm@nongnu.org; qemu-devel@nongnu.org;
> > eric.auger@redhat.com; peter.maydell@linaro.org; Jason Gunthorpe
> > <jgg@nvidia.com>; Nicolin Chen <nicolinc@nvidia.com>; ddutile@redhat.com;
> > berrange@redhat.com; Nathan Chen <nathanc@nvidia.com>; Matt Ochs
> > <mochs@nvidia.com>; smostafa@google.com; wangzhou1@hisilicon.com;
> > jiangkunkun@huawei.com; zhangfei.gao@linaro.org;
> > zhenzhong.duan@intel.com; yi.l.liu@intel.com;
> > shameerkolothum@gmail.com
> > Subject: Re: [PATCH v4 26/27] vfio: Synthesize vPASID capability to VM
> >
> > External email: Use caution opening links or attachments
> >
> >
> > On Mon, 29 Sep 2025 14:36:42 +0100
> > Shameer Kolothum <skolothumtho@nvidia.com> wrote:
> >
> > > From: Yi Liu <yi.l.liu@intel.com>
> > >
> > > If user wants to expose PASID capability in vIOMMU, then VFIO would also
> > > report the PASID cap for this device if the underlying hardware supports
> > > it as well.
> > >
> > > As a start, this chooses to put the vPASID cap in the last 8 bytes of the
> > > vconfig space. This is a choice in the good hope of no conflict with any
> > > existing cap or hidden registers. For the devices that has hidden registers,
> > > user should figure out a proper offset for the vPASID cap. This may require
> > > an option for user to config it. Here we leave it as a future extension.
> > > There are more discussions on the mechanism of finding the proper offset.
> > >
> > >
> > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.
> > kernel.org%2Fkvm%2FBN9PR11MB5276318969A212AD0649C7BE8CBE2%4
> > 0BN9PR11MB5276.namprd11.prod.outlook.com%2F&data=05%7C02%7Csk
> > olothumtho%40nvidia.com%7Cfc027ec76e294ee3db4808de00f29861%7C4
> > 3083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C63894923913220611
> > 4%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjA
> > uMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7
> > C%7C%7C&sdata=Qjerx3fDhLranvJPSoif4z0ue%2FcVgFYvFjroPgCjOQQ%3D&
> > reserved=0
> > >
> > > Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> > > Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com>
> > > ---
> > > hw/vfio/pci.c | 31 +++++++++++++++++++++++++++++++
> > > include/hw/iommu.h | 1 +
> > > 2 files changed, 32 insertions(+)
> > >
> > > diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> > > index 5b022da19e..f54ebd0111 100644
> > > --- a/hw/vfio/pci.c
> > > +++ b/hw/vfio/pci.c
> > > @@ -24,6 +24,7 @@
> > > #include <sys/ioctl.h>
> > >
> > > #include "hw/hw.h"
> > > +#include "hw/iommu.h"
> > > #include "hw/pci/msi.h"
> > > #include "hw/pci/msix.h"
> > > #include "hw/pci/pci_bridge.h"
> > > @@ -2500,7 +2501,12 @@ static int vfio_setup_rebar_ecap(VFIOPCIDevice
> > *vdev, uint16_t pos)
> > >
> > > static void vfio_add_ext_cap(VFIOPCIDevice *vdev)
> > > {
> > > + HostIOMMUDevice *hiod = vdev->vbasedev.hiod;
> > > + HostIOMMUDeviceClass *hiodc =
> > HOST_IOMMU_DEVICE_GET_CLASS(hiod);
> > > PCIDevice *pdev = PCI_DEVICE(vdev);
> > > + uint8_t max_pasid_log2 = 0;
> > > + bool pasid_cap_added = false;
> > > + uint64_t hw_caps;
> > > uint32_t header;
> > > uint16_t cap_id, next, size;
> > > uint8_t cap_ver;
> > > @@ -2578,12 +2584,37 @@ static void vfio_add_ext_cap(VFIOPCIDevice
> > *vdev)
> > > pcie_add_capability(pdev, cap_id, cap_ver, next, size);
> > > }
> > > break;
> > > + case PCI_EXT_CAP_ID_PASID:
> > > + pasid_cap_added = true;
> > > + /* fallthrough */
> > > default:
> > > pcie_add_capability(pdev, cap_id, cap_ver, next, size);
> > > }
> > >
> > > }
> > >
> > > + /*
> > > + * If PCI_EXT_CAP_ID_PASID not present, try to get information from the
> > host
> >
> > Say why it might or might not be present...
> >
> > > + */
> > > + if (!pasid_cap_added && hiodc->get_pasid) {
> > > + max_pasid_log2 = hiodc->get_pasid(hiod, &hw_caps);
> > > + }
> > > +
> > > + /*
> > > + * If supported, adds the PASID capability in the end of the PCIE config
> > > + * space. TODO: Add option for enabling pasid at a safe offset.
> >
> > What are you thinking needs doing to make it safe? If it's at the end and there
> > is space isn't that enough?
>
> That is based on this discussion thread (mentioned in commit log as well)
> https://lore.kernel.org/kvm/BN9PR11MB5276318969A212AD0649C7BE8CBE2@BN9PR11MB5276.namprd11.prod.outlook.com/
>
>
> " - Some devices are known to place registers in configuration space,
> outside of the capability chains, which historically makes it
> difficult to place a purely virtual capability without potentially
> masking such hidden registers."
Yuk. I know this is sometimes done to chicken bit certain capabilities. Some of the
CXL ones only surface in root ports (on one platform anyway) if the link is trained up
as CXL. The registers are there anyway, just the chain pointers that are edited.
Anything truely hidden that is need for operation and in my view they are on
their own!
>
> However, in this series we're trying to limit the impact by only placing the PASID
> capability for devices that are behind the vIOMMU and where the user has explicitly
> enabled PASID support for vIOMMU.
Make sense. So this TODO is more of a do it if anyone ever needs it.
Jonathan
>
> Thanks,
> Shameer
>
>
> >
> > > + */
> > > + if (max_pasid_log2 && (pci_device_get_viommu_flags(pdev) &
> > > + VIOMMU_FLAG_PASID_SUPPORTED)) {
> > > + bool exec_perm = (hw_caps & IOMMU_HW_CAP_PCI_PASID_EXEC) ?
> > true : false;
> > > + bool priv_mod = (hw_caps & IOMMU_HW_CAP_PCI_PASID_PRIV) ?
> > true : false;
> > > +
> > > + pcie_pasid_init(pdev, PCIE_CONFIG_SPACE_SIZE -
> > PCI_EXT_CAP_PASID_SIZEOF,
> > > + max_pasid_log2, exec_perm, priv_mod);
> > > + /* PASID capability is fully emulated by QEMU */
> > > + memset(vdev->emulated_config_bits + pdev->exp.pasid_cap, 0xff, 8);
> > > + }
> > > +
> > > /* Cleanup chain head ID if necessary */
> > > if (pci_get_word(pdev->config + PCI_CONFIG_SPACE_SIZE) == 0xFFFF) {
> > > pci_set_word(pdev->config + PCI_CONFIG_SPACE_SIZE, 0);
>
>
next prev parent reply other threads:[~2025-10-02 10:00 UTC|newest]
Thread overview: 166+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 13:36 [PATCH v4 00/27] hw/arm/virt: Add support for user-creatable accelerated SMMUv3 Shameer Kolothum
2025-09-29 13:36 ` [PATCH v4 01/27] backends/iommufd: Introduce iommufd_backend_alloc_viommu Shameer Kolothum
2025-09-29 15:35 ` Jonathan Cameron via
2025-10-17 12:21 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 02/27] backends/iommufd: Introduce iommufd_vdev_alloc Shameer Kolothum
2025-09-29 15:40 ` Jonathan Cameron via
2025-09-29 17:52 ` Nicolin Chen
2025-09-30 8:14 ` Shameer Kolothum
2025-09-29 13:36 ` [PATCH v4 03/27] hw/arm/smmu-common: Factor out common helper functions and export Shameer Kolothum
2025-09-29 15:43 ` Jonathan Cameron via
2025-09-29 13:36 ` [PATCH v4 04/27] hw/arm/smmu-common:Make iommu ops part of SMMUState Shameer Kolothum
2025-09-29 15:45 ` Jonathan Cameron via
2025-09-29 21:53 ` Nicolin Chen via
2025-10-01 16:11 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 05/27] hw/arm/smmuv3-accel: Introduce smmuv3 accel device Shameer Kolothum
2025-09-29 15:53 ` Jonathan Cameron via
2025-09-29 22:24 ` Nicolin Chen
2025-10-01 16:25 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 06/27] hw/arm/smmuv3-accel: Restrict accelerated SMMUv3 to vfio-pci endpoints with iommufd Shameer Kolothum
2025-09-29 16:08 ` Jonathan Cameron via
2025-09-30 8:03 ` Shameer Kolothum
2025-10-01 16:38 ` Eric Auger
2025-10-02 8:16 ` Shameer Kolothum
2025-09-30 0:11 ` Nicolin Chen
2025-10-02 7:29 ` Shameer Kolothum
2025-10-01 17:32 ` Eric Auger
2025-10-02 9:30 ` Shameer Kolothum
2025-10-17 12:47 ` Eric Auger
2025-10-17 13:15 ` Shameer Kolothum
2025-10-17 17:19 ` Eric Auger
2025-10-20 16:31 ` Eric Auger
2025-10-20 18:25 ` Nicolin Chen
2025-10-20 18:59 ` Shameer Kolothum
2025-10-21 15:28 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 07/27] hw/arm/smmuv3: Implement get_viommu_cap() callback Shameer Kolothum
2025-09-29 16:13 ` Jonathan Cameron via
2025-10-01 17:36 ` Eric Auger
2025-10-02 9:38 ` Shameer Kolothum
2025-10-02 12:31 ` Eric Auger
2025-10-02 9:39 ` Jonathan Cameron via
2025-09-29 13:36 ` [PATCH v4 08/27] hw/arm/smmuv3-accel: Add set/unset_iommu_device callback Shameer Kolothum
2025-09-29 16:25 ` Jonathan Cameron via
2025-09-30 8:13 ` Shameer Kolothum
2025-10-02 6:52 ` Eric Auger
2025-10-02 11:34 ` Shameer Kolothum
2025-10-02 16:44 ` Nicolin Chen
2025-10-02 18:35 ` Jason Gunthorpe
2025-10-17 12:06 ` Eric Auger
2025-10-27 11:56 ` Shameer Kolothum
2025-10-27 14:10 ` Eric Auger
2025-10-17 12:23 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 09/27] hw/arm/smmuv3-accel: Support nested STE install/uninstall support Shameer Kolothum
2025-09-29 16:41 ` Jonathan Cameron via
2025-10-02 10:04 ` Eric Auger
2025-10-02 12:08 ` Shameer Kolothum
2025-10-02 12:27 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 10/27] hw/arm/smmuv3-accel: Allocate a vDEVICE object for device Shameer Kolothum
2025-09-29 16:42 ` Jonathan Cameron via
2025-10-17 13:08 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 11/27] hw/pci/pci: Introduce optional get_msi_address_space() callback Shameer Kolothum
2025-09-29 16:48 ` Jonathan Cameron via
2025-10-16 22:30 ` Nicolin Chen
2025-10-20 16:14 ` Eric Auger
2025-10-20 18:00 ` Nicolin Chen
2025-10-21 16:26 ` Eric Auger
2025-10-21 18:56 ` Nicolin Chen
2025-10-22 16:25 ` Eric Auger
2025-10-22 16:56 ` Shameer Kolothum
2025-10-20 16:21 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 12/27] hw/arm/smmuv3-accel: Make use of " Shameer Kolothum
2025-09-29 16:51 ` Jonathan Cameron via
2025-10-02 7:33 ` Shameer Kolothum
2025-10-16 23:28 ` Nicolin Chen
2025-10-20 16:43 ` Eric Auger
2025-10-21 8:15 ` Shameer Kolothum
2025-10-21 16:16 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 13/27] hw/arm/smmuv3-accel: Add support to issue invalidation cmd to host Shameer Kolothum
2025-09-29 16:53 ` Jonathan Cameron via
2025-10-16 22:59 ` Nicolin Chen via
2025-10-27 10:13 ` Eric Auger
2025-10-27 12:20 ` Shameer Kolothum
2025-10-27 14:05 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 14/27] hw/arm/smmuv3-accel: Get host SMMUv3 hw info and validate Shameer Kolothum
2025-10-01 12:56 ` Jonathan Cameron via
2025-10-02 7:37 ` Shameer Kolothum
2025-10-02 9:54 ` Jonathan Cameron via
2025-10-27 10:41 ` Eric Auger
2025-10-27 12:23 ` Shameer Kolothum
2025-10-27 10:46 ` Eric Auger
2025-10-27 12:24 ` Shameer Kolothum
2025-09-29 13:36 ` [PATCH v4 15/27] acpi/gpex: Fix PCI Express Slot Information function 0 returned value Shameer Kolothum
2025-10-01 12:59 ` Jonathan Cameron via
2025-10-02 7:39 ` Shameer Kolothum
2025-10-21 15:32 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 16/27] hw/pci-host/gpex: Allow to generate preserve boot config DSM #5 Shameer Kolothum
2025-10-01 13:05 ` Jonathan Cameron via
2025-10-27 11:14 ` Eric Auger
2025-10-27 11:10 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 17/27] hw/arm/virt: Set PCI preserve_config for accel SMMUv3 Shameer Kolothum
2025-10-01 13:06 ` Jonathan Cameron via
2025-10-27 11:21 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 18/27] hw/arm/virt-acpi-build: Add IORT RMR regions to handle MSI nested binding Shameer Kolothum
2025-10-01 13:30 ` Jonathan Cameron via
2025-09-29 13:36 ` [PATCH v4 19/27] hw/arm/smmuv3-accel: Install S1 bypass hwpt on reset Shameer Kolothum
2025-10-01 13:32 ` Jonathan Cameron via
2025-10-16 23:19 ` Nicolin Chen
2025-10-20 14:22 ` Shameer Kolothum
2025-10-27 14:26 ` Eric Auger
2025-10-27 14:51 ` Shameer Kolothum
2025-10-29 4:26 ` Nicolin Chen
2025-10-29 18:19 ` Shameer Kolothum
2025-10-30 5:28 ` Nicolin Chen
2025-10-30 7:35 ` Nicolin Chen
2025-10-30 13:02 ` Jason Gunthorpe
2025-10-27 16:34 ` Nicolin Chen
2025-10-27 14:22 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 20/27] hw/arm/smmuv3: Add accel property for SMMUv3 device Shameer Kolothum
2025-10-16 21:48 ` Nicolin Chen
2025-10-27 14:28 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 21/27] hw/arm/smmuv3-accel: Add a property to specify RIL support Shameer Kolothum
2025-10-01 13:39 ` Jonathan Cameron via
2025-10-17 8:48 ` Zhangfei Gao
2025-10-17 9:40 ` Shameer Kolothum
2025-10-17 14:05 ` Zhangfei Gao
2025-10-27 14:44 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 22/27] hw/arm/smmuv3-accel: Add support for ATS Shameer Kolothum
2025-10-01 13:43 ` Jonathan Cameron via
2025-10-27 16:59 ` Eric Auger
2025-10-27 17:13 ` Nicolin Chen via
2025-10-27 17:38 ` Eric Auger
2025-10-27 17:53 ` Nicolin Chen
2025-10-28 12:16 ` Jason Gunthorpe
2025-10-28 13:21 ` Eric Auger
2025-10-28 13:41 ` Jason Gunthorpe
2025-10-28 13:51 ` Eric Auger
2025-10-28 14:03 ` Jason Gunthorpe
2025-10-28 14:44 ` Shameer Kolothum
2025-10-28 14:46 ` Eric Auger
2025-10-28 14:59 ` Eric Auger
2025-10-28 15:06 ` Jason Gunthorpe
2025-10-27 17:54 ` Shameer Kolothum
2025-10-27 18:02 ` Eric Auger
2025-10-28 14:03 ` Shameer Kolothum
2025-10-27 17:13 ` Shameer Kolothum
2025-09-29 13:36 ` [PATCH v4 23/27] hw/arm/smmuv3-accel: Add property to specify OAS bits Shameer Kolothum
2025-10-01 13:46 ` Jonathan Cameron via
2025-10-27 14:57 ` Eric Auger
2025-10-27 14:55 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 24/27] backends/iommufd: Retrieve PASID width from iommufd_backend_get_device_info() Shameer Kolothum
2025-10-01 13:50 ` Jonathan Cameron via
2025-10-27 17:00 ` Eric Auger
2025-10-27 17:10 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 25/27] backends/iommufd: Add a callback helper to retrieve PASID support Shameer Kolothum
2025-10-01 13:52 ` Jonathan Cameron via
2025-10-27 17:28 ` Eric Auger
2025-09-29 13:36 ` [PATCH v4 26/27] vfio: Synthesize vPASID capability to VM Shameer Kolothum
2025-10-01 13:58 ` Jonathan Cameron via
2025-10-02 8:03 ` Shameer Kolothum
2025-10-02 9:58 ` Jonathan Cameron via [this message]
2025-09-29 13:36 ` [PATCH v4 27/27] hw.arm/smmuv3: Add support for PASID enable Shameer Kolothum
2025-10-01 14:01 ` Jonathan Cameron via
2025-10-27 18:15 ` Eric Auger
2025-10-27 18:40 ` Shameer Kolothum
2025-10-28 10:31 ` Eric Auger
2025-10-17 6:25 ` [PATCH v4 00/27] hw/arm/virt: Add support for user-creatable accelerated SMMUv3 Zhangfei Gao
2025-10-17 9:43 ` Shameer Kolothum
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=20251002105824.00005ddd@huawei.com \
--to=qemu-devel@nongnu.org \
--cc=berrange@redhat.com \
--cc=ddutile@redhat.com \
--cc=eric.auger@redhat.com \
--cc=jgg@nvidia.com \
--cc=jiangkunkun@huawei.com \
--cc=jonathan.cameron@huawei.com \
--cc=mochs@nvidia.com \
--cc=nathanc@nvidia.com \
--cc=nicolinc@nvidia.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=shameerkolothum@gmail.com \
--cc=skolothumtho@nvidia.com \
--cc=smostafa@google.com \
--cc=wangzhou1@hisilicon.com \
--cc=yi.l.liu@intel.com \
--cc=zhangfei.gao@linaro.org \
--cc=zhenzhong.duan@intel.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;
as well as URLs for NNTP newsgroup(s).