[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3a56vovcqy7ju5og76nqlekfruq42i56wmp4oek3jgkffvzjby@q5guufebkpzr>
Date: Tue, 12 Mar 2024 14:35:46 +0200
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Yosry Ahmed <yosryahmed@...gle.com>
Cc: x86@...nel.org, Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com>,
Andy Lutomirski <luto@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
Rick Edgecombe <rick.p.edgecombe@...el.com>, Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] x86/mm: Fix LAM inconsistency during context switch
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().
> 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
Powered by blists - more mailing lists