All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: Ensure .mem(init|exit).text are within _stext/_etext
@ 2016-09-15  5:11 Michael Ellerman
  2016-09-15  5:28 ` Anton Blanchard
  2016-09-20 13:07 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-09-15  5:11 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: anton

In our linker script we open code the list of text sections, because we
need to include the __ftr_alt sections, which are arch-specific.

This means we can't use TEXT_TEXT as defined in vmlinux.lds.h, and so we
don't have the MEM_KEEP() logic for memory hotplug sections.

If we build the kernel with the gold linker, and with CONFIG_MEMORY_HOTPLUG=y,
we see that functions marked __meminit can end up outside of the
_stext/_etext range, and also outside of _sinittext/_einittext, eg:

    c000000000000000 T _stext
    c0000000009e0000 A _etext
    c0000000009e3f18 T hash__vmemmap_create_mapping
    c000000000ca0000 T _sinittext
    c000000000d00844 T _einittext

This causes them to not be recognised as text by is_kernel_text(), and
prevents them being patched by jump_label (and presumably ftrace/kprobes
etc.).

Fix it by adding MEM_KEEP() directives, mirroring what TEXT_TEXT does.

This isn't a problem when CONFIG_MEMORY_HOTPLUG=n, because we use the
standard INIT_TEXT_SECTION() and EXIT_TEXT macros from vmlinux.lds.h.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kernel/vmlinux.lds.S | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index b5fba689fca6..b59d75e194a5 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -56,6 +56,8 @@ SECTIONS
 		KPROBES_TEXT
 		IRQENTRY_TEXT
 		SOFTIRQENTRY_TEXT
+		MEM_KEEP(init.text)
+		MEM_KEEP(exit.text)
 
 #ifdef CONFIG_PPC32
 		*(.got1)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc: Ensure .mem(init|exit).text are within _stext/_etext
  2016-09-15  5:11 [PATCH] powerpc: Ensure .mem(init|exit).text are within _stext/_etext Michael Ellerman
@ 2016-09-15  5:28 ` Anton Blanchard
  2016-09-20 13:07 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Anton Blanchard @ 2016-09-15  5:28 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

Hi,

> In our linker script we open code the list of text sections, because
> we need to include the __ftr_alt sections, which are arch-specific.
> 
> This means we can't use TEXT_TEXT as defined in vmlinux.lds.h, and so
> we don't have the MEM_KEEP() logic for memory hotplug sections.
> 
> If we build the kernel with the gold linker, and with
> CONFIG_MEMORY_HOTPLUG=y, we see that functions marked __meminit can
> end up outside of the _stext/_etext range, and also outside of
> _sinittext/_einittext, eg:
> 
>     c000000000000000 T _stext
>     c0000000009e0000 A _etext
>     c0000000009e3f18 T hash__vmemmap_create_mapping
>     c000000000ca0000 T _sinittext
>     c000000000d00844 T _einittext
> 
> This causes them to not be recognised as text by is_kernel_text(), and
> prevents them being patched by jump_label (and presumably
> ftrace/kprobes etc.).
> 
> Fix it by adding MEM_KEEP() directives, mirroring what TEXT_TEXT does.
> 
> This isn't a problem when CONFIG_MEMORY_HOTPLUG=n, because we use the
> standard INIT_TEXT_SECTION() and EXIT_TEXT macros from vmlinux.lds.h.

Thanks Michael, looks good:

Tested-by: Anton Blanchard <anton@samba.org>

Anton
--
 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/kernel/vmlinux.lds.S | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/vmlinux.lds.S
> b/arch/powerpc/kernel/vmlinux.lds.S index b5fba689fca6..b59d75e194a5
> 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S
> +++ b/arch/powerpc/kernel/vmlinux.lds.S
> @@ -56,6 +56,8 @@ SECTIONS
>  		KPROBES_TEXT
>  		IRQENTRY_TEXT
>  		SOFTIRQENTRY_TEXT
> +		MEM_KEEP(init.text)
> +		MEM_KEEP(exit.text)
>  
>  #ifdef CONFIG_PPC32
>  		*(.got1)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: powerpc: Ensure .mem(init|exit).text are within _stext/_etext
  2016-09-15  5:11 [PATCH] powerpc: Ensure .mem(init|exit).text are within _stext/_etext Michael Ellerman
  2016-09-15  5:28 ` Anton Blanchard
@ 2016-09-20 13:07 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-09-20 13:07 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: anton

On Thu, 2016-15-09 at 05:11:59 UTC, Michael Ellerman wrote:
> In our linker script we open code the list of text sections, because we
> need to include the __ftr_alt sections, which are arch-specific.
> 
> This means we can't use TEXT_TEXT as defined in vmlinux.lds.h, and so we
> don't have the MEM_KEEP() logic for memory hotplug sections.
> 
> If we build the kernel with the gold linker, and with CONFIG_MEMORY_HOTPLUG=y,
> we see that functions marked __meminit can end up outside of the
> _stext/_etext range, and also outside of _sinittext/_einittext, eg:
> 
>     c000000000000000 T _stext
>     c0000000009e0000 A _etext
>     c0000000009e3f18 T hash__vmemmap_create_mapping
>     c000000000ca0000 T _sinittext
>     c000000000d00844 T _einittext
> 
> This causes them to not be recognised as text by is_kernel_text(), and
> prevents them being patched by jump_label (and presumably ftrace/kprobes
> etc.).
> 
> Fix it by adding MEM_KEEP() directives, mirroring what TEXT_TEXT does.
> 
> This isn't a problem when CONFIG_MEMORY_HOTPLUG=n, because we use the
> standard INIT_TEXT_SECTION() and EXIT_TEXT macros from vmlinux.lds.h.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Tested-by: Anton Blanchard <anton@samba.org>

Applied to powerpc next.

https://git.kernel.org/powerpc/c/7de3b27bac47da9de08409df1d

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-09-20 13:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-15  5:11 [PATCH] powerpc: Ensure .mem(init|exit).text are within _stext/_etext Michael Ellerman
2016-09-15  5:28 ` Anton Blanchard
2016-09-20 13:07 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.