Re: [PATCHv8 00/11] Linear Address Masking enabling

From: Jacob Pan
Date: Wed Sep 14 2022 - 19:48:17 EST


Hi Kirill,

On Wed, 14 Sep 2022 18:45:32 +0300, "Kirill A. Shutemov"
<kirill.shutemov@xxxxxxxxxxxxxxx> wrote:

> On Wed, Sep 14, 2022 at 08:31:56AM -0700, Ashok Raj wrote:
> > On Wed, Sep 14, 2022 at 06:18:18PM +0300, Kirill A. Shutemov wrote:
> > > > > > >
> > > > > > > The patch below implements something like this. It is PoC,
> > > > > > > build-tested only.
> > > > > > >
> > > > > > > To be honest, I hate it. It is clearly a layering violation.
> > > > > > > It feels dirty. But I don't see any better way as we tie
> > > > > > > orthogonal features together.
> > > > > > >
> > > > > > > Also I have no idea how to make forced PASID allocation if
> > > > > > > LAM enabled. What the API has to look like?
> > > > > >
> > > > > > Jacob, Ashok, any comment on this part?
> > > > > >
> > > > > > I expect in many cases LAM will be enabled very early (like
> > > > > > before malloc is functinal) in process start and it makes PASID
> > > > > > allocation always fail.
> > > > > >
> > > > > > Any way out?
> > > > >
> > > > > We need closure on this to proceed. Any clue?
> > > >
> > > > Failing PASID allocation seems like the right thing to do here. If
> > > > the application is explicitly allocating PASID's it can opt-out
> > > > using the similar mechanism you have for LAM enabling. So user takes
> > > > responsibility for sanitizing pointers.
> > > >
> > > > If some library is using an accelerator without application
> > > > knowledge, that would use the failure as a mechanism to use an
> > > > alternate path if one exists.
> > > >
> > > > I don't know if both LAM and SVM need a separate forced opt-in (or i
> > > > don't have an opinion rather). Is this what you were asking?
> > > >
> > > > + Joerg, JasonG in case they have an opinion.
> > >
> > > My point is that the patch provides a way to override LAM vs. PASID
> > > mutual exclusion, but only if PASID allocated first. If we enabled
> > > LAM before PASID is allcoated there's no way to forcefully allocate
> > > PASID, bypassing LAM check. I think there should be one, no?
> >
> > Yes, we should have one for force enabling SVM too if the application
> > asks for forgiveness.
>
> What is the right API here?
>
It seems very difficult to implement a UAPI for the applications to
override at a runtime. Currently, SVM bind is under the control of
individual drivers. It could be at the time of open or some ioctl.

Perhaps, this can be a platform policy via some commandline option. e.g.
intel_iommu=sva_lam_coexist.

Thanks,

Jacob