[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220704134346.ua37tgg2c5eff4jm@black.fi.intel.com>
Date: Mon, 4 Jul 2022 16:43:46 +0300
From: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
To: Andy Lutomirski <luto@...nel.org>
Cc: Dave Hansen <dave.hansen@...ux.intel.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
the arch/x86 maintainers <x86@...nel.org>,
"kcc@...gle.com" <kcc@...gle.com>,
"ryabinin.a.a@...il.com" <ryabinin.a.a@...il.com>,
"andreyknvl@...il.com" <andreyknvl@...il.com>,
"glider@...gle.com" <glider@...gle.com>,
"dvyukov@...gle.com" <dvyukov@...gle.com>,
"H.J. Lu" <hjl.tools@...il.com>, Andi Kleen <ak@...ux.intel.com>,
Rick P Edgecombe <rick.p.edgecombe@...el.com>,
linux-mm@...ck.org,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCHv3 6/8] x86/mm: Provide ARCH_GET_UNTAG_MASK and
ARCH_ENABLE_TAGGED_ADDR
On Sat, Jul 02, 2022 at 04:55:40PM -0700, Andy Lutomirski wrote:
> > diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
> > index 427ebef3f64b..cd2b03fe94c4 100644
> > --- a/arch/x86/kernel/process_64.c
> > +++ b/arch/x86/kernel/process_64.c
> > @@ -745,15 +745,16 @@ static long prctl_map_vdso(const struct
> > vdso_image *image, unsigned long addr)
> > static void enable_lam_func(void *mm)
> > {
> > struct mm_struct *loaded_mm = this_cpu_read(cpu_tlbstate.loaded_mm);
> > + unsigned long lam_mask;
> >
> > if (loaded_mm != mm)
> > return;
> >
> > - /* Counterpart of smp_wmb() in prctl_enable_tagged_addr() */
> > - smp_rmb();
> > + lam_mask = READ_ONCE(loaded_mm->context.lam_cr3_mask);
> >
> > /* Update CR3 to get LAM active on the CPU */
> > - switch_mm(loaded_mm, loaded_mm, current);
> > + write_cr3(__read_cr3() | lam_mask);
>
> Perhaps this should also mask off the old LAM mask?
So far LAM enabling is one-way operation, so it should be fine.
But I think masking off is good idea to avoid problems in the future.
--
Kirill A. Shutemov
Powered by blists - more mailing lists