From: David Hildenbrand <david@redhat.com>
To: Jianyong Wu <Jianyong.Wu@arm.com>,
Ard Biesheuvel <ardb@kernel.org>,
Catalin Marinas <Catalin.Marinas@arm.com>
Cc: Justin He <Justin.He@arm.com>,
"will@kernel.org" <will@kernel.org>,
Anshuman Khandual <Anshuman.Khandual@arm.com>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"quic_qiancai@quicinc.com" <quic_qiancai@quicinc.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"gshan@redhat.com" <gshan@redhat.com>, nd <nd@arm.com>
Subject: Re: [PATCH v3] arm64/mm: avoid fixmap race condition when create pud mapping
Date: Thu, 27 Jan 2022 13:22:47 +0100 [thread overview]
Message-ID: <ca62449b-7ab0-0e18-ee5a-b46b3f527385@redhat.com> (raw)
In-Reply-To: <AM9PR08MB7276062BC7B474174FFFA11BF4219@AM9PR08MB7276.eurprd08.prod.outlook.com>
>
> 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)
...
>
> 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 / dhildenb
next prev parent reply other threads:[~2022-01-27 12:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-16 8:28 [PATCH v3] arm64/mm: avoid fixmap race condition when create pud mapping Jianyong Wu
2021-12-16 15:19 ` David Hildenbrand
2021-12-17 9:30 ` Mark Rutland
2021-12-17 10:09 ` Jianyong Wu
2022-01-05 18:03 ` Catalin Marinas
2022-01-06 10:13 ` Jianyong Wu
2022-01-06 15:56 ` Catalin Marinas
2022-01-07 9:10 ` Jianyong Wu
2022-01-07 10:42 ` Catalin Marinas
2022-01-26 4:20 ` Justin He
2022-01-26 8:36 ` Ard Biesheuvel
2022-01-26 10:09 ` Jianyong Wu
2022-01-26 10:12 ` Ard Biesheuvel
2022-01-26 10:17 ` David Hildenbrand
2022-01-26 10:28 ` Jianyong Wu
2022-01-26 10:30 ` David Hildenbrand
2022-01-26 10:31 ` David Hildenbrand
2022-01-27 6:24 ` Jianyong Wu
2022-01-27 12:22 ` David Hildenbrand [this message]
2022-01-27 12:34 ` Catalin Marinas
2022-01-31 8:13 ` Jianyong Wu
2022-01-31 8:10 ` Jianyong Wu
2022-01-27 1:31 ` Justin He
2022-01-07 10:53 ` Catalin Marinas
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=ca62449b-7ab0-0e18-ee5a-b46b3f527385@redhat.com \
--to=david@redhat.com \
--cc=Anshuman.Khandual@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=Jianyong.Wu@arm.com \
--cc=Justin.He@arm.com \
--cc=akpm@linux-foundation.org \
--cc=ardb@kernel.org \
--cc=gshan@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nd@arm.com \
--cc=quic_qiancai@quicinc.com \
--cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).