RE: [PATCH v4 04/12] iommu/vt-d: Add helper to setup pasid nested translation

From: Tian, Kevin
Date: Wed Aug 02 2023 - 04:14:28 EST


> From: Baolu Lu <baolu.lu@xxxxxxxxxxxxxxx>
> Sent: Wednesday, August 2, 2023 4:12 PM
>
> On 2023/8/2 16:09, Baolu Lu wrote:
> > On 2023/8/2 15:10, Tian, Kevin wrote:
> >>> +
> >>> +    pasid_set_slptr(pte, virt_to_phys(pgd));
> >>> +    pasid_set_fault_enable(pte);
> >>> +    pasid_set_domain_id(pte, did);
> >>> +    pasid_set_address_width(pte, s2_domain->agaw);
> >>> +    pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap));
> >>> +    pasid_set_translation_type(pte, PASID_ENTRY_PGTT_NESTED);
> >>> +    pasid_set_present(pte);
> >>> +    spin_unlock(&iommu->lock);
> >>> +
> >> this lacks of handling of force_snooping
> >
> > If stage-2 domain has force_snooping attribute set, then we should set
> > the bit field in the pasid entry, right?
> >
> > How about below additional change?

yes

> >
> > diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
> > index 19ac4084913b..86db81ec91f1 100644
> > --- a/drivers/iommu/intel/pasid.c
> > +++ b/drivers/iommu/intel/pasid.c
> > @@ -827,6 +827,9 @@ int intel_pasid_setup_nested(struct intel_iommu
> > *iommu, struct device *dev,
> >         if (s1_cfg->flags & IOMMU_VTD_S1_EAFE)
> >                 pasid_set_eafe(pte);
> >
> > +       if (s2_domain>force_snooping)
>
> + if (s2_domain->force_snooping)
>
> Sorry for typo.
>
> > +               pasid_set_pgsnp(pte);
> > +
> >         pasid_set_slptr(pte, virt_to_phys(pgd));
> >         pasid_set_fault_enable(pte);
> >         pasid_set_domain_id(pte, did);
> >
> > Best regards,
> > baolu