All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yosry Ahmed <yosryahmed@google.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: x86@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,  Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	 "H. Peter Anvin" <hpa@zytor.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	 Rick Edgecombe <rick.p.edgecombe@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] x86/mm: Fix LAM inconsistency during context switch
Date: Tue, 12 Mar 2024 15:34:55 +0000	[thread overview]
Message-ID: <ZfB2HyzkWzaAQHYo@google.com> (raw)
In-Reply-To: <3a56vovcqy7ju5og76nqlekfruq42i56wmp4oek3jgkffvzjby@q5guufebkpzr>

On Tue, Mar 12, 2024 at 02:35:46PM +0200, Kirill A. Shutemov wrote:
> On Tue, Mar 12, 2024 at 03:59:50AM +0000, Yosry Ahmed wrote:
> > diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> > index 76e91fc68c5f3..748d2b3bdb985 100644
> > --- a/arch/x86/kernel/process_64.c
> > +++ b/arch/x86/kernel/process_64.c
> > @@ -753,10 +753,12 @@ static long prctl_map_vdso(const struct vdso_image *image, unsigned long addr)
> >  static void enable_lam_func(void *__mm)
> >  {
> >  	struct mm_struct *mm = __mm;
> > +	unsigned long lam = mm_lam_cr3_mask(mm);
> > +	u64 untag_mask = mm_untag_mask(mm);
> >  
> 
> Maybe push these mm dereferences inside the if block below?
> I am not sure if compiler can re-order operations past this_cpu_read().

I am not sure either, so I will push them inside. Better safe than
sorry. Will send a v2 shortly, thanks for the reviews!

> 
> >  	if (this_cpu_read(cpu_tlbstate.loaded_mm) == mm) {
> > -		write_cr3(__read_cr3() | mm->context.lam_cr3_mask);
> > -		set_tlbstate_lam_mode(mm);
> > +		write_cr3(__read_cr3() | lam);
> > +		cpu_tlbstate_update_lam(lam, untag_mask);
> >  	}
> >  }
> >  
> 
> -- 
>   Kiryl Shutsemau / Kirill A. Shutemov


  reply	other threads:[~2024-03-12 15:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  3:59 [PATCH 1/3] x86/mm: Use IPIs to synchronize LAM enablement Yosry Ahmed
2024-03-12  3:59 ` [PATCH 2/3] x86/mm: Fix LAM inconsistency during context switch Yosry Ahmed
2024-03-12 12:35   ` Kirill A. Shutemov
2024-03-12 15:34     ` Yosry Ahmed [this message]
2024-03-12  3:59 ` [PATCH 3/3] x86/mm: Cleanup prctl_enable_tagged_addr() nr_bits error checking Yosry Ahmed
2024-03-12 12:36   ` Kirill A. Shutemov
2024-03-12 12:24 ` [PATCH 1/3] x86/mm: Use IPIs to synchronize LAM enablement Kirill A. Shutemov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZfB2HyzkWzaAQHYo@google.com \
    --to=yosryahmed@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.