Re: [PATCHv10 10/15] x86/mm, iommu/sva: Make LAM and SVM mutually exclusive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 18, 2022 at 02:00:38PM -0700, Dave Hansen wrote:
> > diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
> > index b0e9ea23758b..6b9ac2c60cec 100644
> > --- a/arch/x86/include/asm/mmu_context.h
> > +++ b/arch/x86/include/asm/mmu_context.h
> > @@ -113,6 +113,8 @@ static inline void mm_reset_untag_mask(struct mm_struct *mm)
> >  	mm->context.untag_mask = -1UL;
> >  }
> >  
> > +#define arch_pgtable_dma_compat(mm)	\
> > +	(!mm_lam_cr3_mask(mm) || (mm->context.flags & MM_CONTEXT_FORCE_TAGGED_SVM))
> >  #else
> 
> This needs to be a 'static inline' unless there's a compelling and
> documented reason that it can't be.

Seems work fine.

> >  static inline unsigned long mm_lam_cr3_mask(struct mm_struct *mm)
> > diff --git a/arch/x86/include/uapi/asm/prctl.h b/arch/x86/include/uapi/asm/prctl.h
> > index a31e27b95b19..7bd22defb558 100644
> > --- a/arch/x86/include/uapi/asm/prctl.h
> > +++ b/arch/x86/include/uapi/asm/prctl.h
> > @@ -23,5 +23,6 @@
> >  #define ARCH_GET_UNTAG_MASK		0x4001
> >  #define ARCH_ENABLE_TAGGED_ADDR		0x4002
> >  #define ARCH_GET_MAX_TAG_BITS		0x4003
> > +#define ARCH_FORCE_TAGGED_SVM		0x4004
> >  
> >  #endif /* _ASM_X86_PRCTL_H */
> > diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> > index 9952e9f517ec..8faa8774bb93 100644
> > --- a/arch/x86/kernel/process_64.c
> > +++ b/arch/x86/kernel/process_64.c
> > @@ -783,6 +783,13 @@ static int prctl_enable_tagged_addr(struct mm_struct *mm, unsigned long nr_bits)
> >  		goto out;
> >  	}
> >  
> > +#ifdef CONFIG_IOMMU_SVA
> > +	if (pasid_valid(mm->pasid) &&
> > +	    !(mm->context.flags & MM_CONTEXT_FORCE_TAGGED_SVM)) {
> > +		ret = -EBUSY;
> > +		goto out;
> > +	}
> > +#endif
> 
> Is this #ifdef really necessary?  CONFIG_IOMMU_SVA selects IOASID,
> without which pasid_valid() is just stubbed out to 0.

mm->pasid is only defined for CONFIG_IOMMU_SVA=y.

Do you want me to add mm_has_valid_pasid()?

-- 
  Kiryl Shutsemau / Kirill A. Shutemov




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux