Re: [RFC PATCH v2 07/10] iommu/riscv: Add domain_alloc_paging_flags for second-stage domain
| Newsgroups | org.infradead.lists.kvm-riscv,dev.linux.lists.iommu,org.infradead.lists.linux-riscv,org.kernel.vger.kvm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
>On Thu, May 07, 2026 at 07:37:03PM +0800, [email protected] wrote: >... >> + case IOMMU_HWPT_ALLOC_NEST_PARENT: >> + case IOMMU_HWPT_ALLOC_DIRTY_TRACKING: >> + case IOMMU_HWPT_ALLOC_DIRTY_TRACKING | IOMMU_HWPT_ALLOC_NEST_PARENT: >> + /* >> + * Second-stage (iohgatp) page table for KVM VFIO device >> + * pass-through and dirty tracking. The GPA space is 2 bits >> + * wider than the corresponding first-stage VA space (x4 root >> + * page table), so hw_max_vasz_lg2 values are 41/50/59. >> + */ >> + if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV57X4) { >> + cfg.common.hw_max_vasz_lg2 = 59; >> + } else if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV48X4) { >> + cfg.common.hw_max_vasz_lg2 = 50; >> + } else if (iommu->caps & RISCV_IOMMU_CAPABILITIES_SV39X4) { >> + cfg.common.hw_max_vasz_lg2 = 41; >> + } else { >> + ret = -ENODEV; >> + goto err_free; >> + } >> + domain->gscid = ida_alloc_range(&riscv_iommu_gscids, 1, >> + RISCV_IOMMU_MAX_GSCID, GFP_KERNEL); >> + if (domain->gscid < 0) { >> + ret = -ENOMEM; >> + goto err_free; >> + } >> + cfg.common.features |= BIT(PT_FEAT_RISCV_S2); > >cfg.common.features currently has PT_FEAT_SIGN_EXTEND which isn't correct >for the second stage. So it needs to removed and then added back in for >the first stage. riscv_64_kunit_fmt_cfgs[] in the kunit test will then >need to also be updated. Thanks, agreed. PT_FEAT_SIGN_EXTEND is only valid for first-stage VA translation and should not be inherited by iohgatp domains. I'll move PT_FEAT_SIGN_EXTEND into the first-stage allocation path, leave second-stage domains with PT_FEAT_RISCV_S2 only, and update the RISC-V KUnit configs accordingly in next version. > >Thanks, >drew -- kvm-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kvm-riscv