<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 18, 2020 at 5:39 PM Christophe Leroy <<a href="mailto:christophe.leroy@csgroup.eu">christophe.leroy@csgroup.eu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">It can cause, or it causes ? Did you encounter the issue ?<br></blockquote><div>Yes, in configs that result in the section layout I described, the crush is consistent.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> <br>
> The init sections are ordered like this:<br>
> .init.text<br>
> .exit.text<br>
> .init.data<br>
> <br>
> Currently, these sections aren't page aligned.<br>
> <br>
> Because the init code is mapped read-only at runtime and because the<br>
> .init.text section can potentially reside on the same physical page as<br>
> .init.data, the beginning of .init.data might be mapped read-only along<br>
> with .init.text.<br>
<br>
init code is mapped PAGE_KERNEL_TEXT.<br>
<br>
Whether PAGE_KERNEL_TEXT is read-only or not depends on the selected options.<br></blockquote><div>You are right, of course. Should I change the commit message to 'might be mapped' or something?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> <br>
> Then when the kernel tries to modify a variable in .init.data (like<br>
> kthreadd_done, used in kernel_init()) the kernel panics.<br>
> <br>
> To avoid this, I made these sections page aligned.<br>
<br>
Should write this unpersonal, something like "To avoid this, make these sections page aligned"<br></blockquote><div>Noted, thanks.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> <br>
> Fixes: 060ef9d89d18 ("powerpc32: PAGE_EXEC required for inittext")<br>
> Signed-off-by: Ariel Marcovitch <<a href="mailto:ariel.marcovitch@gmail.com" target="_blank">ariel.marcovitch@gmail.com</a>><br>
> ---<br>
> arch/powerpc/kernel/vmlinux.lds.S | 7 +++++++<br>
> 1 file changed, 7 insertions(+)<br>
> <br>
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S<br>
> index 326e113d2e45..e3a7c90c03f4 100644<br>
> --- a/arch/powerpc/kernel/vmlinux.lds.S<br>
> +++ b/arch/powerpc/kernel/vmlinux.lds.S<br>
> @@ -179,6 +179,11 @@ SECTIONS<br>
> #endif<br>
> } :text<br>
> <br>
> + /* .init.text is made RO and .exit.text is not, so we must<br>
> + * ensure these sections reside in separate physical pages.<br>
> + */<br>
> + . = ALIGN(PAGE_SIZE);<br>
> +<br>
<br>
In principle, as it is text, it should be made RO as well. But what happens at the begining doesn't <br>
really matter, anyway .exit.text should never be executed and is discarded together with init text.<br>
So, I think it is OK the live with it as is for the time being.</blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Making it page aligned makes sense anyway.<br>
<br>
Should we make _einittext page aligned instead, just like _etext ?</blockquote><div>Yes, this will probably be better (because when _einittext is not aligned,</div><div>the part of the page after _einittext is mapped RO implicitly, and it's</div><div>hard to notice from the code). I suppose you mean something like this:</div><div> _sinittext = .;<br> INIT_TEXT<br>+<br>+ . = ALIGN(.);<br> _einittext = .;</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> /* .exit.text is discarded at runtime, not link time,<br>
> * to deal with references from __bug_table<br>
> */<br>
> @@ -186,6 +191,8 @@ SECTIONS<br>
> EXIT_TEXT<br>
> }<br>
> <br>
> + . = ALIGN(PAGE_SIZE);<br>
> +<br>
<br>
Here for sure, as you explain in the coming log, this needs to be separated from init text. So <br>
making it aligned is a must. </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {<br>
> INIT_DATA<br>
> }<br>
> <br>
> base-commit: 1398820fee515873379809a6415930ad0764b2f6<br>
> <br>
<br>
Christophe<br></blockquote><div>Thanks for your time,</div><div> Ariel Marcovitch</div></div></div>