On Thu, Mar 07, 2024 at 01:39:14PM +0000, Yosry Ahmed wrote: > In switch_mm_irqs_off(), we read the 'mm->context.lam_cr3_mask' into > 'new_lam', which is later passed to load_new_mm_cr3(). However, there is > a call to set_tlbstate_lam_mode() in between which will read > 'mm->context.lam_cr3_mask' again and set 'cpu_tlbstate.lam' accordingly. > If we race with another thread updating 'mm->context.lam_cr3_mask', the > value in 'cpu_tlbstate.lam' could end up being different from CR3. What other thread? LAM can only be enabled when the process has single thread. And cannot be disabled. See MM_CONTEXT_LOCK_LAM. > While we are at it, remove the misguiding comment that states that > 'new_lam' may not match tlbstate_lam_cr3_mask() if a race occurs. The comment is indeed misguiding, but for different reason. It is leftover from the earlier version of LAM patchset. -- Kiryl Shutsemau / Kirill A. Shutemov