[PATCH] iommu: Allow device driver to use its own PASID space for SVA

Jason Gunthorpe jgg at ziepe.ca
Mon May 18 10:52:49 PDT 2026


On Mon, May 18, 2026 at 09:06:54AM +0000, Joonwon Kang wrote:
> > On Fri, May 15, 2026 at 09:46:05AM +0000, Joonwon Kang wrote:
> > > diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
> > > index 0ca3912ecb7f..61e2e52105e5 100644
> > > --- a/arch/x86/kernel/traps.c
> > > +++ b/arch/x86/kernel/traps.c
> > > @@ -864,6 +864,8 @@ static bool try_fixup_enqcmd_gp(void)
> > >  		return false;
> > >  
> > >  	pasid = mm_get_enqcmd_pasid(current->mm);
> > > +	if (pasid == IOMMU_PASID_INVALID)
> > > +		return false;
> > 
> > If you do this then probably you should get rid of mm_valid_pasid(),
> > mm_get_enqcmd_pasid() already has the NULL check so the two functions
> > are kind of pointless.
> > 
> > You also missed the other place calling mm_valid_pasid() that should
> > really be sensitive to this as well:
> > 
> > static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)
> > {
> > [..]
> >         if (mm_valid_pasid(mm) &&
> >             !test_bit(MM_CONTEXT_FORCE_TAGGED_SVA, &mm->context.flags))
> >                 return -EINVAL;
> > 
> > Make that removal a prep patch
> > 
> 
> Thanks for pointing this out. I think mm_valid_pasid() is to check if SVA
> is currently in action while mm_get_enqcmd_pasid() is to get the PASID for
> "ENQCMD instruction execution".

> Since it is now possible with this patch to activate SVA without involving
> EL0(for ENQCMD-like instructions),

I see, this thing about which is about LAM should remain, yes

But all the "EL0" machinery about trapping and enabling ENQCMD should
be moved over to mm_get_enqcmd_pasid() and never call mm_valid_pasid()

Jason



More information about the linux-arm-kernel mailing list