[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AM9PR08MB72760F336E9D198FB4A1E6D5F4259@AM9PR08MB7276.eurprd08.prod.outlook.com>
Date: Mon, 31 Jan 2022 08:10:44 +0000
From: Jianyong Wu <Jianyong.Wu@....com>
To: David Hildenbrand <david@...hat.com>,
Ard Biesheuvel <ardb@...nel.org>,
Catalin Marinas <Catalin.Marinas@....com>
CC: Justin He <Justin.He@....com>, "will@...nel.org" <will@...nel.org>,
Anshuman Khandual <Anshuman.Khandual@....com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"quic_qiancai@...cinc.com" <quic_qiancai@...cinc.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"gshan@...hat.com" <gshan@...hat.com>, nd <nd@....com>
Subject: RE: [PATCH v3] arm64/mm: avoid fixmap race condition when create pud
mapping
Hi David,
> -----Original Message-----
> From: David Hildenbrand <david@...hat.com>
> Sent: Thursday, January 27, 2022 8:23 PM
> To: Jianyong Wu <Jianyong.Wu@....com>; Ard Biesheuvel
> <ardb@...nel.org>; Catalin Marinas <Catalin.Marinas@....com>
> Cc: Justin He <Justin.He@....com>; will@...nel.org; Anshuman Khandual
> <Anshuman.Khandual@....com>; akpm@...ux-foundation.org;
> quic_qiancai@...cinc.com; linux-kernel@...r.kernel.org; linux-arm-
> kernel@...ts.infradead.org; gshan@...hat.com; nd <nd@....com>
> Subject: Re: [PATCH v3] arm64/mm: avoid fixmap race condition when create
> pud mapping
>
> >
> > Yes, system_state can roughly separate these callers of
> __create_pgd_mapping. When system_state > SYSTEM_BOOTING we can
> add the lock.
> > Thus, I have the following change:
> >
> > static DEFINE_SPINLOCK(swapper_pgdir_lock);
> > +static DEFINE_MUTEX(fixmap_lock);
> >
> > void set_swapper_pgd(pgd_t *pgdp, pgd_t pgd) { @@ -329,6 +330,8 @@
> > static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long
> end,
> > }
> > BUG_ON(p4d_bad(p4d));
> >
> > + if (system_state > SYSTEM_BOOTING)
>
> As there is nothing smaller than SYSTEM_BOOTING, you can use
> if (system_state != SYSTEM_BOOTING)
>
> ...
OK,
>
> >
> > It seems work and somehow simper. But I don't know if it is reasonable
> > to do this. So, any idea? @Ard Biesheuvel @Catalin Marinas
>
> It's worth looking at kernel/notifier.c, e.g.,
> blocking_notifier_chain_register()
>
> if (unlikely(system_state == SYSTEM_BOOTING))
> return notifier_chain_register(&nh->head, n);
>
> down_write(&nh->rwsem);
> ret = notifier_chain_register(&nh->head, n); up_write(&nh->rwsem);
>
>
>
> If we decide to go down that path, we should make sure to add a comment
> like
>
> /*
> * No need for locking during early boot. And it doesn't work as
> * expected with KASLR enabled where we might clear BSS twice.
> */
>
Thanks David, it's very helpful.
Thanks
Jianyong
> --
> Thanks,
>
> David / dhildenb
Powered by blists - more mailing lists