Re: [PATCH v3 07/59] x86: Sanitize linker script
From: Borislav Petkov
Date: Fri Oct 07 2022 - 12:04:15 EST
On Thu, Sep 15, 2022 at 01:10:46PM +0200, Peter Zijlstra wrote:
> From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>
> The section ordering in the text section is more than suboptimal:
>
> ALIGN_ENTRY_TEXT_BEGIN
> ENTRY_TEXT
> ALIGN_ENTRY_TEXT_END
> SOFTIRQENTRY_TEXT
> STATIC_CALL_TEXT
> INDIRECT_THUNK_TEXT
>
> ENTRY_TEXT is in a seperate PMD so it can be mapped into the cpu entry area
s/seperate/separate/g
That's tglx's favourite spelling of "separate" :-)
> when KPTI is enabled. That means the sections after it are also in a
> seperate PMD. That's wasteful especially as the indirect thunk text is a
^^^^^^^^
ditto.
> --- a/arch/x86/kernel/vmlinux.lds.S
> +++ b/arch/x86/kernel/vmlinux.lds.S
> @@ -132,18 +132,19 @@ SECTIONS
> CPUIDLE_TEXT
> LOCK_TEXT
> KPROBES_TEXT
> - ALIGN_ENTRY_TEXT_BEGIN
> - ENTRY_TEXT
> - ALIGN_ENTRY_TEXT_END
> SOFTIRQENTRY_TEXT
> - STATIC_CALL_TEXT
> - *(.gnu.warning)
> -
> #ifdef CONFIG_RETPOLINE
> __indirect_thunk_start = .;
> *(.text.__x86.*)
> __indirect_thunk_end = .;
> #endif
<--- might wanna put a comment here so that people don't slap some new
sections underneath it.
> + STATIC_CALL_TEXT
> +
> + ALIGN_ENTRY_TEXT_BEGIN
> + ENTRY_TEXT
> + ALIGN_ENTRY_TEXT_END
> + *(.gnu.warning)
> +
> } :text =0xcccc
>
> /* End of text section, which should occupy whole number of pages */
>
>
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette