RE: [PATCH] iommu/vt-d: Set SSADE when attaching to a parent with dirty tracking

From: Tian, Kevin
Date: Sun Feb 18 2024 - 19:41:05 EST


> From: Joao Martins <joao.m.martins@xxxxxxxxxx>
> Sent: Friday, February 9, 2024 6:36 PM
>
> On 08/02/2024 10:31, Joao Martins wrote:
> > On 08/02/2024 09:14, Yi Liu wrote:
> >> Should set the SSADE (Second Stage Access/Dirty bit Enable) bit of the
> >> pasid entry when attaching a device to a nested domain if its parent
> >> has already enabled dirty tracking.
> >>
> >> Fixes: 111bf85c68f6 ("iommu/vt-d: Add helper to setup pasid nested
> translation")
> >> Signed-off-by: Yi Liu <yi.l.liu@xxxxxxxxx>
> >
> > Reviewed-by: Joao Martins <joao.m.martins@xxxxxxxxxx>
> >
> On a second thought, while the patch looks fine if this is what we wanna do,
> just a quick clarification on the why (that's also applicable to the last patch
> of your other series[0]). I am sure I am missing something :)
>
> Shouldn't the nested domain be subdued to whatever features guest idea of
> ecap/cap instead of host's view? Or is this because guest first-stage page
> table
> on Intel is supposed to be always-enabled dirty tracking (per SDM) ? If it's the
> latter, it probably should be sprinkled in the commit message(s).
>
> [0] https://lore.kernel.org/linux-iommu/20240208082307.15759-9-
> yi.l.liu@xxxxxxxxx/
>

first-stage dirty tracking is always enabled. but the real point here is
that the host has enabled dirty-tracking in second-stage so when
a device is attached to a nested domain on top of that second-stage
we should set SSADE in the pasid entry for that device.

even if there is a guest ecap/cap for first-stage dirty tracking that
shouldn't affect the host setting for second-stage which is invisible
to the guest.