On Tue, Oct 15, 2024 at 10:52:19AM +0800, Baolu Lu wrote:
On 2024/10/15 3:24, Jason Gunthorpe wrote:That sounds good too
On Mon, Oct 14, 2024 at 09:25:03AM +0800, Baolu Lu wrote:Yea, you are right. I overlooked that part. I'll remove the 'if'
It only calls it on the s2_parent which is always a paging domain?A nested domain is not a paging domain. It represents a user-space page+ if (domain->type & __IOMMU_DOMAIN_PAGING) {It looks like this entire function is already never called for
anything but paging?
The only three callers are:
.default_domain_ops = &(const struct iommu_domain_ops) {
.attach_dev = intel_iommu_attach_device,
.set_dev_pasid = intel_iommu_set_dev_pasid,
and
static const struct iommu_domain_ops intel_nested_domain_ops = {
.attach_dev = intel_nested_attach_dev,
And none of those cases can be anything except a paging domain by
definition.
table that nested on a parent paging domain. Perhaps I overlooked
anything?
ret = prepare_domain_attach_device(&dmar_domain->s2_domain->domain, dev);
statement and utilize a WARN_ON() function instead.
And also, I will rename this function with a meaningful name,some like
paging_domain_is_compatible()?
Ultimately you want to try to structure the driver so that there is a
struct paging_domain that is always the paging domain type and
everything is easy to understand. Don't re-use the same struct for
identity/blocked/nested domains.