[PATCH 2/7] powerpc: move __end_rodata to cover arch read-only sections
Michael Ellerman
mpe at ellerman.id.au
Thu Sep 15 22:47:50 AEST 2022
Nicholas Piggin <npiggin at 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
More information about the Linuxppc-dev
mailing list