Re: [PATCHv14 04/17] x86/mm: Handle LAM on context switch

From: Kirill A. Shutemov
Date: Wed Jan 11 2023 - 09:15:22 EST


On Wed, Jan 11, 2023 at 07:49:30AM -0600, Linus Torvalds wrote:
> Sorry, I'm traveling, and right now only on mobile. So I'm reading patches
> on my phone, and answering on it too, so html garbage..
>
> On Wed, Jan 11, 2023, 07:24 Kirill A. Shutemov <
> kirill.shutemov@xxxxxxxxxxxxxxx> wrote:
>
> >
> > +static inline unsigned long mm_lam_cr3_mask(struct mm_struct *mm)
> > +{
> > + return READ_ONCE(mm->context.lam_cr3_mask);
> > +}
> >
>
> I mentioned this before - in the original version this needed (but didn't
> have, iirc) that READ_ONCE, but in the new non-thread situation I don't
> think that's true. There should be no concurrent changes that can interfere
> with the read, no?

It should be safe, yes.

It is reachable from iommu_sva_bind_device(), but it only called with mm
== current->mm.

I will drop the READ_ONCE().

--
Kiryl Shutsemau / Kirill A. Shutemov