[PATCH 0/3] vfio/pci: add vfio-pci ATS control property

Nathan Chen posted 3 patches 1 month, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260612014322.2918836-1-nathanc@nvidia.com
Maintainers: Yi Liu <yi.l.liu@intel.com>, Eric Auger <eric.auger@redhat.com>, Zhenzhong Duan <zhenzhong.duan@intel.com>, "Philippe Mathieu-Daudé" <philmd@mailo.com>, Zhao Liu <zhao1.liu@intel.com>, Alex Williamson <alex@shazbot.org>, "Cédric Le Goater" <clg@redhat.com>
There is a newer version of this series
hw/vfio/pci.h                      |  1 +
include/system/host_iommu_device.h | 10 ++++
backends/iommufd.c                 |  8 ++++
hw/core/machine.c                  |  1 +
hw/vfio/pci.c                      | 74 ++++++++++++++++++++++++++++--
5 files changed, 91 insertions(+), 3 deletions(-)
[PATCH 0/3] vfio/pci: add vfio-pci ATS control property
Posted by Nathan Chen 1 month, 2 weeks ago
Hi,

This series adds an ATS control property to vfio-pci and wires iommufd
support reporting so vfio-pci can decide whether to expose the ATS PCIe
extended capability to the guest. This series is a follow-up to the
previous patch included in the "hw/arm/smmuv3-accel: Resolve AUTO
properties" series [0].

The new vfio-pci property is:
  ats=on|off|auto (default: auto)

Behavior:
- off: always masks ATS from guest view
- on: requires ATS support; fails realize if kernel reports
      IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED
- auto: masks ATS only when kernel reports
        IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED

To preserve machine compatibility for older machine types, this series adds:
  { "vfio-pci", "ats", "on" } to hw_compat_11_0.

Please note that no linux-headers sync patch is included in this series
because IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED is already present in
linux-headers/linux/iommufd.h in the current base.

Testing:
Verified ATS capability visibility changes with vfio-pci ats=off/on/auto
on an NVIDIA Grace system:
- ats=on + ATS supported by kernel => propagate ATS extended cap to
  guest view
- ats=auto + ATS supported by kernel => propagate ATS extended cap to
  guest view
- ats=on + hiod_iommufd_support_ats modified to return false (mimic 
  kernel-reported unsupported ATS) => realize failure
- ats=auto + hiod_iommufd_support_ats modified to return false (mimic
  kernel-reported unsupported ATS) => ATS masked
- ats=off => ATS masked

Changes from "Resolve AUTO properties" series:
- Split into separate patches for support_ats() handler introduction and
  iommufd implementation, "ats" property addition, and compat property fix
- Rebase on vfio-next
- Remove unnecessary includes for hw/vfio/pci.c
- Rename ats_need to ats_needed for vfio_pci_ats_requested_and_supported()
- Move the vfio_pci_ats_requested_and_supported() call to
  vfio_pci_add_capabilities() so we can propagate the Error **, and then pass
  ats_needed as a new input arg to vfio_add_ext_cap
- Fix indent error in vfio_add_ext_cap()
- Break and add a pcie_add_capability() call for the PASID case in
  vfio_add_ext_cap()
- Update comment about return value for support_ats()

Thanks,
Nathan

[0] https://lore.kernel.org/qemu-devel/20260401010231.4166776-5-nathanc@nvidia.com/

Nathan Chen (3):
  iommufd: Introduce handler for device ATS support
  vfio/pci: Add ats property
  hw/core/machine: Add new compat for vfio-pci ats property

 hw/vfio/pci.h                      |  1 +
 include/system/host_iommu_device.h | 10 ++++
 backends/iommufd.c                 |  8 ++++
 hw/core/machine.c                  |  1 +
 hw/vfio/pci.c                      | 74 ++++++++++++++++++++++++++++--
 5 files changed, 91 insertions(+), 3 deletions(-)

-- 
2.43.0
Re: [PATCH 0/3] vfio/pci: add vfio-pci ATS control property
Posted by Cédric Le Goater 1 month, 2 weeks ago
Hello Nathan,

On 6/12/26 03:43, Nathan Chen wrote:
> Hi,
> 
> This series adds an ATS control property to vfio-pci and wires iommufd
> support reporting so vfio-pci can decide whether to expose the ATS PCIe
> extended capability to the guest. This series is a follow-up to the
> previous patch included in the "hw/arm/smmuv3-accel: Resolve AUTO
> properties" series [0].
> 
> The new vfio-pci property is:
>    ats=on|off|auto (default: auto)
> 
> Behavior:
> - off: always masks ATS from guest view
> - on: requires ATS support; fails realize if kernel reports
>        IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED
> - auto: masks ATS only when kernel reports
>          IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED
> 
> To preserve machine compatibility for older machine types, this series adds:
>    { "vfio-pci", "ats", "on" } to hw_compat_11_0.
> 
> Please note that no linux-headers sync patch is included in this series
> because IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED is already present in
> linux-headers/linux/iommufd.h in the current base.
> 
> Testing:
> Verified ATS capability visibility changes with vfio-pci ats=off/on/auto
> on an NVIDIA Grace system:
> - ats=on + ATS supported by kernel => propagate ATS extended cap to
>    guest view
> - ats=auto + ATS supported by kernel => propagate ATS extended cap to
>    guest view
> - ats=on + hiod_iommufd_support_ats modified to return false (mimic
>    kernel-reported unsupported ATS) => realize failure
> - ats=auto + hiod_iommufd_support_ats modified to return false (mimic
>    kernel-reported unsupported ATS) => ATS masked
> - ats=off => ATS masked

What about ats=on and no ATS support in the physical device ?

I agree it is a bit of a corner case. A warning would be nice,
it can be addressed as a follow up change.

Thanks,

C.

  
> Changes from "Resolve AUTO properties" series:
> - Split into separate patches for support_ats() handler introduction and
>    iommufd implementation, "ats" property addition, and compat property fix
> - Rebase on vfio-next
> - Remove unnecessary includes for hw/vfio/pci.c
> - Rename ats_need to ats_needed for vfio_pci_ats_requested_and_supported()
> - Move the vfio_pci_ats_requested_and_supported() call to
>    vfio_pci_add_capabilities() so we can propagate the Error **, and then pass
>    ats_needed as a new input arg to vfio_add_ext_cap
> - Fix indent error in vfio_add_ext_cap()
> - Break and add a pcie_add_capability() call for the PASID case in
>    vfio_add_ext_cap()
> - Update comment about return value for support_ats()
> 
> Thanks,
> Nathan
> 
> [0] https://lore.kernel.org/qemu-devel/20260401010231.4166776-5-nathanc@nvidia.com/
> 
> Nathan Chen (3):
>    iommufd: Introduce handler for device ATS support
>    vfio/pci: Add ats property
>    hw/core/machine: Add new compat for vfio-pci ats property
> 
>   hw/vfio/pci.h                      |  1 +
>   include/system/host_iommu_device.h | 10 ++++
>   backends/iommufd.c                 |  8 ++++
>   hw/core/machine.c                  |  1 +
>   hw/vfio/pci.c                      | 74 ++++++++++++++++++++++++++++--
>   5 files changed, 91 insertions(+), 3 deletions(-)
>
Re: [PATCH 0/3] vfio/pci: add vfio-pci ATS control property
Posted by Nathan Chen 1 month, 1 week ago
Hi Cédric,

On 6/12/2026 12:56 AM, Cédric Le Goater wrote:
> Hello Nathan,
> 
> On 6/12/26 03:43, Nathan Chen wrote:
>> Hi,
>>
>> This series adds an ATS control property to vfio-pci and wires iommufd
>> support reporting so vfio-pci can decide whether to expose the ATS PCIe
>> extended capability to the guest. This series is a follow-up to the
>> previous patch included in the "hw/arm/smmuv3-accel: Resolve AUTO
>> properties" series [0].
>>
>> The new vfio-pci property is:
>>    ats=on|off|auto (default: auto)
>>
>> Behavior:
>> - off: always masks ATS from guest view
>> - on: requires ATS support; fails realize if kernel reports
>>        IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED
>> - auto: masks ATS only when kernel reports
>>          IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED
>>
>> To preserve machine compatibility for older machine types, this series 
>> adds:
>>    { "vfio-pci", "ats", "on" } to hw_compat_11_0.
>>
>> Please note that no linux-headers sync patch is included in this series
>> because IOMMU_HW_CAP_PCI_ATS_NOT_SUPPORTED is already present in
>> linux-headers/linux/iommufd.h in the current base.
>>
>> Testing:
>> Verified ATS capability visibility changes with vfio-pci ats=off/on/auto
>> on an NVIDIA Grace system:
>> - ats=on + ATS supported by kernel => propagate ATS extended cap to
>>    guest view
>> - ats=auto + ATS supported by kernel => propagate ATS extended cap to
>>    guest view
>> - ats=on + hiod_iommufd_support_ats modified to return false (mimic
>>    kernel-reported unsupported ATS) => realize failure
>> - ats=auto + hiod_iommufd_support_ats modified to return false (mimic
>>    kernel-reported unsupported ATS) => ATS masked
>> - ats=off => ATS masked
> 
> What about ats=on and no ATS support in the physical device ?
> 
> I agree it is a bit of a corner case. A warning would be nice,
> it can be addressed as a follow up change.

Right, I had missed that case. I will look into accounting for it in the 
next refresh.

Thanks,
Nathan