[RFC PATCH v2 2/9] iommufd: Add RISC-V IOMMU hwpt and vIOMMU types
Gong Shuai
gong.shuai at sanechips.com.cn
Wed Oct 28 23:11:24 PDT 2026
From: Wu Fei <wu.fei9 at sanechips.com.cn>
Add IOMMU_HWPT_DATA_RISCV_S1 and struct iommu_hwpt_riscv to carry
the guest device context in base format for nested hwpt allocation.
Add IOMMU_VIOMMU_TYPE_RISCV so user space can request a RISC-V
vIOMMU.
The RISC-V nested translation support added later needs these types.
Signed-off-by: Wu Fei <wu.fei9 at sanechips.com.cn>
Co-developed-by: Gong Shuai <gong.shuai at sanechips.com.cn>
Signed-off-by: Gong Shuai <gong.shuai at sanechips.com.cn>
---
include/uapi/linux/iommufd.h | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/include/uapi/linux/iommufd.h b/include/uapi/linux/iommufd.h
index 206fa667c782..5b5ca6e41063 100644
--- a/include/uapi/linux/iommufd.h
+++ b/include/uapi/linux/iommufd.h
@@ -506,18 +506,46 @@ struct iommu_hwpt_amd_guest {
__aligned_u64 dte[4];
};
+/**
+ * struct iommu_hwpt_riscv - RISC-V IOMMU stage-1 page table data
+ * (IOMMU_HWPT_DATA_RISCV_S1)
+ *
+ * @dc: The guest device-context (DC) in the base format defined in
+ * "Leaf DDT entry" of the RISC-V IOMMU Architecture Specification,
+ * refer to "Device-context fields" for the meaning of each
+ * doubleword. Only the guest-owned doublewords are validated:
+ * - dc[0] (tc): Allowed bits are V, EN_ATS, EN_PRI, T2GPA, DTF,
+ * PRPR, SADE and SBE. GADE is owned by the host and the value
+ * here is ignored. PDTV, DPE and SXL are not supported and must
+ * be 0.
+ * - dc[3] (fsc): Carries iosatp when tc.PDTV=0, allowed fields
+ * are MODE (Bare, Sv39, Sv48, Sv57) and PPN; Carries pdtp when
+ * tc.PDTV=1, which not supported now.
+ *
+ * The host-owned doublewords dc[1] (iohgatp) and dc[2] (ta) are
+ * ignored. iohgatp is installed by the kernel from the nesting
+ * parent at attach time and ta is managed by the host. The
+ * extended-format MSI doublewords are configured by the host for
+ * interrupt remapping and are not passed via this structure.
+ */
+struct iommu_hwpt_riscv {
+ __aligned_u64 dc[4];
+};
+
/**
* enum iommu_hwpt_data_type - IOMMU HWPT Data Type
* @IOMMU_HWPT_DATA_NONE: no data
* @IOMMU_HWPT_DATA_VTD_S1: Intel VT-d stage-1 page table
* @IOMMU_HWPT_DATA_ARM_SMMUV3: ARM SMMUv3 Context Descriptor Table
* @IOMMU_HWPT_DATA_AMD_GUEST: AMD IOMMU guest page table
+ * @IOMMU_HWPT_DATA_RISCV_S1: RISC-V IOMMU stage-1 page table
*/
enum iommu_hwpt_data_type {
IOMMU_HWPT_DATA_NONE = 0,
IOMMU_HWPT_DATA_VTD_S1 = 1,
IOMMU_HWPT_DATA_ARM_SMMUV3 = 2,
IOMMU_HWPT_DATA_AMD_GUEST = 3,
+ IOMMU_HWPT_DATA_RISCV_S1 = 4,
};
/**
@@ -1095,6 +1123,7 @@ struct iommu_fault_alloc {
* @IOMMU_VIOMMU_TYPE_ARM_SMMUV3: ARM SMMUv3 driver specific type
* @IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV: NVIDIA Tegra241 CMDQV (extension for ARM
* SMMUv3) enabled ARM SMMUv3 type
+ * @IOMMU_VIOMMU_TYPE_RISCV: RISC-V IOMMU driver specific type
*/
enum iommu_viommu_type {
IOMMU_VIOMMU_TYPE_DEFAULT = 0,
@@ -1105,6 +1134,7 @@ enum iommu_viommu_type {
* VMM must wire the HYP_OWN bit to 0 in guest VINTF_CONFIG register
*/
IOMMU_VIOMMU_TYPE_TEGRA241_CMDQV = 2,
+ IOMMU_VIOMMU_TYPE_RISCV = 3,
};
/**
--
2.53.0
More information about the kvm-riscv
mailing list