From: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
To: Yosry Ahmed <yosryahmed@google.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 v2 2/3] x86/mm: Fix LAM inconsistency during context switch
Date: Wed, 13 Mar 2024 15:38:46 +0200 [thread overview]
Message-ID: <so22e3yeljtvz5axz2cgwtns3r5kimk43r65cognlazsgh4agz@zwdnsc266dw3> (raw)
In-Reply-To: <20240312155641.4003683-2-yosryahmed@google.com>
On Tue, Mar 12, 2024 at 03:56:40PM +0000, Yosry Ahmed wrote:
> LAM can only be enabled when a process is single-threaded. But _kernel_
> threads can temporarily use a single-threaded process's mm. That means
> that a context-switching kernel thread can race and observe the mm's LAM
> metadata (mm->context.lam_cr3_mask) change.
>
> The context switch code does two logical things with that metadata:
> populate CR3 and populate 'cpu_tlbstate.lam'. If it hits this race,
> 'cpu_tlbstate.lam' and CR3 can end up out of sync.
>
> This de-synchronization is currently harmless. But it is confusing and
> might lead to warnings or real bugs.
>
> Update set_tlbstate_lam_mode() to take in the LAM mask and untag mask
> instead of an mm_struct pointer, and while we are at it, rename it to
> cpu_tlbstate_update_lam(). This should also make it clearer that we are
> updating cpu_tlbstate. In switch_mm_irqs_off(), read the LAM mask once
> and use it for both the cpu_tlbstate update and the CR3 update.
>
> Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
--
Kiryl Shutsemau / Kirill A. Shutemov
next prev parent reply other threads:[~2024-03-13 13:38 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-12 15:56 [PATCH v2 1/3] x86/mm: Use IPIs to synchronize LAM enablement Yosry Ahmed
2024-03-12 15:56 ` [PATCH v2 2/3] x86/mm: Fix LAM inconsistency during context switch Yosry Ahmed
2024-03-13 13:38 ` Kirill A. Shutemov [this message]
2024-03-12 15:56 ` [PATCH v2 3/3] x86/mm: Cleanup prctl_enable_tagged_addr() nr_bits error checking Yosry Ahmed
2024-03-12 16:04 ` [PATCH v2 1/3] x86/mm: Use IPIs to synchronize LAM enablement Dave Hansen
2024-03-12 16:09 ` Yosry Ahmed
2024-03-12 16:13 ` Borislav Petkov
2024-03-12 16:23 ` Yosry Ahmed
2024-03-12 16:35 ` Borislav Petkov
2024-03-12 16:46 ` Yosry Ahmed
2024-03-12 17:01 ` Borislav Petkov
2024-03-12 17:05 ` Yosry Ahmed
2024-04-04 21:27 ` Yosry Ahmed
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=so22e3yeljtvz5axz2cgwtns3r5kimk43r65cognlazsgh4agz@zwdnsc266dw3 \
--to=kirill.shutemov@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.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 \
--cc=yosryahmed@google.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox