Re: [RFC PATCH v2 07/10] iommu/riscv: Add domain_alloc_paging_flags for second-stage domain
Andrew Jones <[email protected]>
| 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 | <rzvdgmjkk5rzn4qehsoajmbak7jpssqancyn3mfvpnzf6wyvsc@alyg5a4c2scx> |
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, drew -- kvm-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kvm-riscv