From: Wu Fei A VMM needs the physical IOMMU capabilities to decide which features it can expose to a guest. Define IOMMU_HW_INFO_TYPE_RISCV and struct iommu_hw_info_riscv so IOMMU_GET_HW_INFO can return the RISC-V capabilities register. Signed-off-by: Wu Fei Signed-off-by: Gong Shuai --- include/uapi/linux/iommufd.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h index fee63e6cbb7a..adc7f30b2b18 100644 --- a/include/uapi/linux/iommufd.h +++ b/include/uapi/linux/iommufd.h @@ -733,6 +733,28 @@ struct iommu_hw_info_amd { __aligned_u64 efr2; }; +/** + * struct iommu_hw_info_riscv - RISC-V IOMMU device info + * (IOMMU_HW_INFO_TYPE_RISCV) + * + * @capabilities: Value of the RISC-V IOMMU capabilities register, defined + * in "IOMMU capabilities (capabilities)" of the RISC-V + * IOMMU Architecture Specification. The value is reported + * raw by the hardware. + * + * The VMM is responsible to determine the appropriate fields to be + * exposed to the VM since certain features are not currently supported + * by the kernel for nested domains. Current list of supported fields: + * - capabilities[Sv39, Sv48, Sv57, END, AMO_HWAD] + * + * This list may expand in the future. It is important that VMMs do not + * expose bits outside the list to the VM, to allow for compatibility + * with future kernels. + */ +struct iommu_hw_info_riscv { + __aligned_u64 capabilities; +}; + /** * enum iommu_hw_info_type - IOMMU Hardware Info Types * @IOMMU_HW_INFO_TYPE_NONE: Output by the drivers that do not report hardware @@ -743,6 +765,7 @@ struct iommu_hw_info_amd { * @IOMMU_HW_INFO_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV (extension for ARM * SMMUv3) info type * @IOMMU_HW_INFO_TYPE_AMD: AMD IOMMU info type + * @IOMMU_HW_INFO_TYPE_RISCV: RISC-V IOMMU info type */ enum iommu_hw_info_type { IOMMU_HW_INFO_TYPE_NONE = 0, @@ -751,6 +774,7 @@ enum iommu_hw_info_type { IOMMU_HW_INFO_TYPE_ARM_SMMUV3 = 2, IOMMU_HW_INFO_TYPE_TEGRA241_CMDQV = 3, IOMMU_HW_INFO_TYPE_AMD = 4, + IOMMU_HW_INFO_TYPE_RISCV = 5, }; /** -- 2.53.0