public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman•id.au>
To: Nicholas Piggin <npiggin@gmail•com>, linuxppc-dev@lists•ozlabs.org
Cc: Nicholas Piggin <npiggin@gmail•com>
Subject: Re: [PATCH 2/7] powerpc: move __end_rodata to cover arch read-only sections
Date: Thu, 15 Sep 2022 22:47:50 +1000	[thread overview]
Message-ID: <877d24n6rt.fsf@mpe.ellerman.id.au> (raw)
In-Reply-To: <20220914154746.1122482-3-npiggin@gmail.com>

Nicholas Piggin <npiggin@gmail•com> writes:
> powerpc has a number of read-only sections and tables that are put
> after RO_DATA(). Move the __end_rodata symbol to cover these as well.
>
> Setting memory to read-only at boot is done using __init_begin,
> change that that to use __end_rodata.

Did you just do that because it seems logical?

Because it does seem logical, but it leaves a RWX region in the gap
between __end_rodata and __init_begin, which is bad.

This is the current behaviour, on radix:

---[ Start of kernel VM ]---
0xc000000000000000-0xc000000001ffffff  0x0000000000000000        32M         r      X   pte  valid  present        dirty  accessed
0xc000000002000000-0xc00000007fffffff  0x0000000002000000      2016M         r  w       pte  valid  present        dirty  accessed

And with your change:

---[ Start of kernel VM ]---
0xc000000000000000-0xc0000000013fffff  0x0000000000000000        20M         r      X   pte  valid  present        dirty  accessed
0xc000000001400000-0xc000000001ffffff  0x0000000001400000        12M         r  w   X   pte  valid  present        dirty  accessed
0xc000000002000000-0xc00000007fffffff  0x0000000002000000      2016M         r  w       pte  valid  present        dirty  accessed


On radix the 16M alignment is larger than we need, but we need to chose
a value at build time that works for radix and hash.

We could make the code smarter on radix, to mark those pages in between
__end_rodata and __init_begin as RW_ and use them for data. But that
would be a more involved change.

I think if we just drop the changes to the C files this patch is OK to
go in.

cheers

  parent reply	other threads:[~2022-09-15 12:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 15:47 [PATCH 0/7] powerpc: build / linker improvements Nicholas Piggin
2022-09-14 15:47 ` [PATCH 1/7] powerpc/build: put sys_call_table in .data.rel.ro if RELOCATABLE Nicholas Piggin
2022-09-15  5:53   ` Christophe Leroy
2022-09-15 12:51     ` Michael Ellerman
2022-09-16  0:30       ` Nicholas Piggin
2022-09-14 15:47 ` [PATCH 2/7] powerpc: move __end_rodata to cover arch read-only sections Nicholas Piggin
2022-09-15  5:50   ` Christophe Leroy
2022-09-15 12:47   ` Michael Ellerman [this message]
2022-09-16  0:28     ` Nicholas Piggin
2022-09-16  6:35       ` Michael Ellerman
2022-09-14 15:47 ` [PATCH 3/7] powerpc/32/build: move got1/got2 sections out of text Nicholas Piggin
2022-09-14 15:47 ` [PATCH 4/7] powerpc/build: move got, toc, plt, branch_lt sections to read-only Nicholas Piggin
2022-09-14 15:47 ` [PATCH 5/7] powerpc/build: move .data.rel.ro, .sdata2 " Nicholas Piggin
2022-09-14 15:47 ` [PATCH 6/7] powerpc/64/build: only include .opd with ELFv1 Nicholas Piggin
2022-09-14 15:47 ` [PATCH 7/7] powerpc/64/build: merge .got and .toc input sections Nicholas Piggin

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=877d24n6rt.fsf@mpe.ellerman.id.au \
    --to=mpe@ellerman$(echo .)id.au \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=npiggin@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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