Re: [PATCH v2] iommu/virtio: Add debugfs state dump

Jean-Philippe Brucker <[email protected]>
Newsgroups dev.linux.lists.iommu,dev.linux.lists.virtualization
Message-ID <20260818133339.GA319267@myrica>
Hi,

On Tue, Aug 18, 2026 at 08:36:18PM +0800, LiMing Wu wrote:
> From: Liming Wu <[email protected]>
> 
> Expose basic virtio-iommu runtime state through debugfs so that the
> relationship between endpoints, IOMMU groups, domains and active mappings
> can be inspected from a running guest.

Thank you for the patch. Do you have a use for this feature, a platform
with virtio-iommu?  I'd rather not add new features to the driver unless
someone needs them.

> Create per-device files under /sys/kernel/debug/iommu/virtio/:
> 
>   status    - negotiated virtio-iommu features and geometry
>   endpoints - endpoint, group and attached domain information
>   domains   - domain type, endpoint count and mapping count
>   mappings  - active IOVA mappings tracked by the driver

endpoints, groups and domains are described in /sys/kernel/iommu_groups.
Mappings are not, but a VMM like QEMU can provide a trace of ATTACH,
MAP, UNMAP requests which is quite useful when debugging.

> +	seq_puts(s, "features:\n");
> +	viommu_debugfs_feature(s, viommu, VIRTIO_IOMMU_F_MAP_UNMAP,
> +			       "map_unmap");
> +	viommu_debugfs_feature(s, viommu, VIRTIO_IOMMU_F_INPUT_RANGE,
> +			       "input_range");
> +	viommu_debugfs_feature(s, viommu, VIRTIO_IOMMU_F_DOMAIN_RANGE,
> +			       "domain_range");
> +	viommu_debugfs_feature(s, viommu, VIRTIO_IOMMU_F_PROBE, "probe");
> +	viommu_debugfs_feature(s, viommu, VIRTIO_IOMMU_F_MMIO, "mmio");
> +	viommu_debugfs_feature(s, viommu, VIRTIO_IOMMU_F_BYPASS_CONFIG,
> +			       "bypass_config");

Virtio provides the feature bits in /sys/bus/virtio/devices/. Not as
convenient as text description but a simple script could help decode it,
for example https://jpbrucker.net/git/iommutools/tree/lsiommu.c#n743

Thanks,
Jean
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.