Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Yeoreum Yun <yeoreum.yun@arm.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>,
	will@kernel.org, nathan@kernel.org,
	nick.desaulniers+lkml@gmail.com, morbo@google.com,
	justinstitt@google.com, broonie@kernel.org, maz@kernel.org,
	oliver.upton@linux.dev, joey.gouly@arm.com,
	shameerali.kolothum.thodi@huawei.com, james.morse@arm.com,
	hardevsinh.palaniya@siliconsignals.io, ardb@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	stable@vger.kernel.org
Subject: Re: [PATCH v2] arm64/cpufeature: annotate arm64_use_ng_mappings with ro_after_init to prevent wrong idmap generation
Date: Tue, 6 May 2025 11:38:15 +0100	[thread overview]
Message-ID: <aBnml0luNiNZYf1s@e129823.arm.com> (raw)
In-Reply-To: <aBngorZeIASsJEvY@arm.com>

On Tue, May 06, 2025 at 11:12:50AM +0100, Catalin Marinas wrote:
> On Tue, May 06, 2025 at 09:53:57AM +0100, Yeoreum Yun wrote:
> > > >>>> On Sat, May 03, 2025 at 11:16:12AM +0100, Catalin Marinas wrote:
> > > >>>>> On Fri, 02 May 2025 19:04:12 +0100, Yeoreum Yun wrote:
> > > >>>>>> create_init_idmap() could be called before .bss section initialization
> > > >>>>>> which is done in early_map_kernel().
> > > >>>>>> Therefore, data/test_prot could be set incorrectly by PTE_MAYBE_NG macro.
> > > >>>>>>
> > > >>>>>> PTE_MAYBE_NG macro set NG bit according to value of "arm64_use_ng_mappings".
> > > >>>>>> and this variable places in .bss section.
> > > >>>>>>
> > > >>>>>> [...]
> > > >>>>>
> > > >>>>> Applied to arm64 (for-next/fixes), with some slight tweaking of the
> > > >>>>> comment, thanks!
> > > >>>>>
> > > >>>>> [1/1] arm64/cpufeature: annotate arm64_use_ng_mappings with ro_after_init to prevent wrong idmap generation
> > > >>>>>       https://git.kernel.org/arm64/c/12657bcd1835
> > > >>>>
> > > >>>> I'm going to drop this for now. The kernel compiled with a clang 19.1.5
> > > >>>> version I have around (Debian sid) fails to boot, gets stuck early on:
> [...]
> > Personally, I don't believe this because the create_init_idmap()
> > maps the the .rodata section with PAGE_KERNEL pgprot
> > from __initdata_begin to _end.
> >
> > and at the mark_readonly() the pgprot is changed to PAGE_KERNEL_RO
> > But, arm64_use_ng_mappings is accessed with write before mark_readonly()
> > only via smp_cpus_done().
> >
> > JFYI here is map information:
> >
> > // mark_readlonly() changes to ro perm below ranges:
> > ffff800081b30000 g       .rodata	0000000000000000 __start_rodata
> > ffff800082560000 g       .rodata.text	0000000000000000 __init_begin
> >
> > // create_init_idmap() maps below range with PAGE_KERNEL.
> > ffff8000826d0000 g       .altinstructions	0000000000000000 __initdata_begin
> > ffff800082eb0000 g       .bss	0000000000000000 _end
> >
> > ffff8000824596d0 g     O .rodata	0000000000000001 arm64_use_ng_mappings
>
> So arm64_use_ng_mappings is mapped as read-only since .rodata is before
> __initdata_begin.

Right. I've misread teh address at first time.
Sorry to make noise.

> --
> Catalin

--
Sincerely,
Yeoreum Yun

  reply	other threads:[~2025-05-06 10:38 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02 18:04 [PATCH v2] arm64/cpufeature: annotate arm64_use_ng_mappings with ro_after_init to prevent wrong idmap generation Yeoreum Yun
2025-05-03 10:16 ` Catalin Marinas
2025-05-03 14:11   ` Catalin Marinas
2025-05-03 20:23     ` Yeoreum Yun
2025-05-05 19:05       ` Catalin Marinas
2025-05-06  8:09         ` Yeoreum Yun
2025-05-06  8:15           ` Ryan Roberts
2025-05-06  8:53             ` Yeoreum Yun
2025-05-06 10:12               ` Catalin Marinas
2025-05-06 10:38                 ` Yeoreum Yun [this message]
2025-05-06 10:13               ` Ryan Roberts
2025-05-06  9:41             ` Ard Biesheuvel
2025-05-06 10:08               ` Ryan Roberts
2025-05-06 10:47                 ` Yeoreum Yun
2025-05-06 10:49                   ` Catalin Marinas
2025-05-06 10:57                     ` Yeoreum Yun
2025-05-06 10:17               ` Catalin Marinas
2025-05-06 10:22                 ` Ryan Roberts
2025-05-06 10:29                   ` Catalin Marinas
2025-05-06 10:36                   ` Yeoreum Yun
2025-05-06  9:09           ` Catalin Marinas
2025-05-06 10:49     ` 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=aBnml0luNiNZYf1s@e129823.arm.com \
    --to=yeoreum.yun@arm.com \
    --cc=ardb@kernel.org \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=hardevsinh.palaniya@siliconsignals.io \
    --cc=james.morse@arm.com \
    --cc=joey.gouly@arm.com \
    --cc=justinstitt@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=maz@kernel.org \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=oliver.upton@linux.dev \
    --cc=ryan.roberts@arm.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=stable@vger.kernel.org \
    --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