On Fri, Jan 30, 2026 at 10:37:06AM -0800, Nathan Chen via Devel wrote:
> From: Nathan Chen <[email protected]>
> 
> Add support for enabling HW-accelerated nested SMMUv3
> via <accel> attribute and its additional attributes for
> ATS, SSID, RIL, and OAS configuration. Support element
> for specifying PCI hostdev PASID capability offset.
> 
> Signed-off-by: Nathan Chen <[email protected]>
> ---
>  docs/formatdomain.rst             |  36 +++++++++++
>  src/conf/domain_conf.c            | 101 +++++++++++++++++++++++++++++-
>  src/conf/domain_conf.h            |   6 ++
>  src/conf/domain_validate.c        |  36 ++++++++++-
>  src/conf/schemas/domaincommon.rng |  32 ++++++++++
>  src/qemu/qemu_command.c           |  23 +++++++
>  src/util/virpci.h                 |   4 ++
>  7 files changed, 233 insertions(+), 5 deletions(-)
> 
> diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst
> index 04ef319a73..998d289ebf 100644
> --- a/docs/formatdomain.rst
> +++ b/docs/formatdomain.rst
> @@ -4880,6 +4880,13 @@ or:
>     device; if PCI ROM loading is disabled through this attribute, attempts to
>     tweak the loading process further using the ``bar`` or ``file`` attributes
>     will be rejected. :since:`Since 4.3.0 (QEMU and KVM only)`.
> +``vpasidCapOffset``
> +   The ``vpasidCapOffset`` element is used to change the offset at which a
> +   PASID PCIe extended capability is placed in a vfio-pci device's PCIe
> +   extended configuration space. If not specified or set to 0, the capability
> +   is placed at the end of the extended configuration space when PASID is
> +   supported. The offset must be 4-byte aligned and within the PCIe extended
> +   configuration space.

The QEMU options starts with `x-` which usually means experimental and
unsupported and we do not use unsupported options in libvirt.

>  ``address``
>     The ``address`` element for USB devices has a ``bus`` and ``device``
>     attribute to specify the USB bus and device number the device appears at 
> on
> @@ -9264,6 +9271,35 @@ Example:
>        The ``pciBus`` attribute notes the index of the controller that an
>        IOMMU device is attached to. (QEMU/KVM and ``smmuv3`` model only)
>  
> +   ``accel``
> +      The ``accel`` attribute with possible values ``on`` and ``off`` can be 
> used
> +      to enable hardware acceleration support for smmuv3Dev IOMMU devices.
> +      (QEMU/KVM and ``smmuv3`` model only)
> +
> +   ``ats``
> +      The ``ats`` attribute with possible values ``on`` and ``off`` can be 
> used
> +      to enable reporting Address Translation Services capability to the 
> guest
> +      for smmuv3Dev IOMMU devices with ``accel`` set to ``on``, if the host
> +      SMMUv3 supports ATS and the associated passthrough device supports ATS.
> +      (QEMU/KVM and ``smmuv3`` model only)

This is the only one that QEMU doesn't validate if it's supported by
host so cannot be currently enabled based on host and user needs to
somehow figure out if this should be enabled or not.

> +   ``ril``
> +      The ``ril`` attribute with possible values ``on`` and ``off`` can be 
> used
> +      to report whether Range Invalidation for smmuv3Dev IOMMU devices with
> +      ``accel`` set to ``on`` is compatible with host SMMUv3 support.
> +      (QEMU/KVM and ``smmuv3`` model only)

Current default in QEMU is `on` but if `accel` is enabled it has to match
what is supported by host SMMUv3 and QEMU errors out if incorrect value
is used.

I wonder why QEMU cannot figure out the default value if nothing is
specified? This way when acceleration is enabled and host SMMUv3 doesn't
support RIL user needs to manually set this option as well.

> +
> +   ``ssidSize``
> +      The ``ssidSize`` attribute sets the number of bits used to represent
> +      SubstreamIDs. A value of N allows SSIDs in the range [0 .. 2^N - 1].
> +      The valid range is 0-20, and a value greater than 0 is required for
> +      enabling PASID support, as doing so advertises PASID capability to
> +      the vIOMMU. (QEMU/KVM and ``smmuv3`` model only)

By default this is disabled in QEMU and can be used only with accel
enabled. If user picks 20 it can be still rejected by QEMU if the host
doesn't support that size.

Is this necessary to be enabled and what is reasonable default user
should use?

> +   ``oas``
> +      The ``oas`` attribute sets the output address size in units of bits.
> +      (QEMU/KVM and ``smmuv3`` model only)

Currently supported values in QEMU are 44 and 48
bits. QEMU defaults to 44, if accel is off it has to be 44, if accel
is on it can be 48. In addition QEMU also errors out if user sets OAS
greater than what is supported by host.

How is user supposed to figure this out and why QEMU cannot pick
reasonable default?

>  The ``virtio`` IOMMU devices can further have ``address`` element as 
> described
>  in `Device addresses`_ (address has to by type of ``pci``).

For all these options we should store the default value in XML if user
doesn't provide it to make sure that existing VMs will not change if
QEMU changes its defaults.

Pavel

Attachment: signature.asc
Description: PGP signature

Reply via email to