When both device and vIOMMU have PASID enabled, then guest may setup pasid usages such as SVM. VFIO needs to be aware of potential pasid usage and should attach the non-pasid part of pasid-capable device to hwpt flagged with IOMMU_HWPT_ALLOC_PASID. ARM SMMU doesn't support IOMMU_HWPT_ALLOC_PASID, only VTD need it. So we can't check the existing vIOMMU flag VIOMMU_FLAG_PASID_SUPPORTED to determine if set flag IOMMU_HWPT_ALLOC_PASID. Instead, introduce a new flag VIOMMU_FLAG_WANT_PASID_ATTACH which will only be exposed by VTD. Opportunistically add documentation for VIOMMU_FLAG_PASID_SUPPORTED and explain the difference with VIOMMU_FLAG_WANT_PASID_ATTACH. Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Reviewed-by: Yi Liu <yi.l.liu@intel.com> Tested-by: Xudong Hao <xudong.hao@intel.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Message-Id: <20260527054658.1021096-4-zhenzhong.duan@intel.com> Reviewed-by: Shameer Kolothum <skolothumtho@nvidia.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
48 lines
1.5 KiB
C
48 lines
1.5 KiB
C
/*
|
|
* General vIOMMU flags
|
|
*
|
|
* Copyright (C) 2026 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#ifndef HW_IOMMU_H
|
|
#define HW_IOMMU_H
|
|
|
|
#include "qemu/bitops.h"
|
|
|
|
/*
|
|
* Theoretical vIOMMU flags. Only determined by the vIOMMU device properties and
|
|
* independent on the actual host IOMMU capabilities they may depend on. Each
|
|
* flag can be an expectation or request to other sub-system or just a pure
|
|
* vIOMMU capability. vIOMMU can choose which flags to expose.
|
|
*/
|
|
enum viommu_flags {
|
|
/* vIOMMU needs nesting parent HWPT to create nested HWPT */
|
|
VIOMMU_FLAG_WANT_NESTING_PARENT = BIT_ULL(0),
|
|
/*
|
|
* vIOMMU supports PASID capability, VFIO checks this flag and synthesize
|
|
* a PASID capability.
|
|
*/
|
|
VIOMMU_FLAG_PASID_SUPPORTED = BIT_ULL(1),
|
|
/* vIOMMU needs dirty tracking on the nesting parent HWPT for nested use */
|
|
VIOMMU_FLAG_WANT_NESTING_DIRTY_TRACKING = BIT_ULL(2),
|
|
/*
|
|
* vIOMMU requests other sub-system like VFIO to create a HWPT that can be
|
|
* used with PASID attachment. VIOMMU_FLAG_PASID_SUPPORTED can't be used
|
|
* for this purpose as PASID attachment is needed by VTD IOMMU but not ARM
|
|
* SMMU.
|
|
*/
|
|
VIOMMU_FLAG_WANT_PASID_ATTACH = BIT_ULL(3),
|
|
};
|
|
|
|
/* Host IOMMU quirks. Extracted from host IOMMU capabilities */
|
|
enum host_iommu_quirks {
|
|
HOST_IOMMU_QUIRK_NESTING_PARENT_BYPASS_RO = BIT_ULL(0),
|
|
};
|
|
|
|
/* ABI constant: IOMMU_NO_PASID must always be 0 (keep in sync with kernel) */
|
|
#define IOMMU_NO_PASID 0
|
|
|
|
#endif /* HW_IOMMU_H */
|