All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/modules: If mprofile-kernel is enabled add it to vermagic
@ 2017-05-10  6:57 Michael Ellerman
  2017-05-10  7:58 ` Balbir Singh
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-05-10  6:57 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: jeyu, rusty, linux-kernel

On powerpc we can build the kernel with two different ABIs for mcount(), which
is used by ftrace. Kernels built with one ABI do not know how to load modules
built with the other ABI. The new style ABI is called "mprofile-kernel", for
want of a better name.

Currently if we build a module using the old style ABI, and the kernel with
mprofile-kernel, when we load the module we'll oops something like:

  # insmod autofs4-no-mprofile-kernel.ko
  ftrace-powerpc: Unexpected instruction f8810028 around bl _mcount
  ------------[ cut here ]------------
  WARNING: CPU: 6 PID: 3759 at ../kernel/trace/ftrace.c:2024 ftrace_bug+0x2b8/0x3c0
  CPU: 6 PID: 3759 Comm: insmod Not tainted 4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 #11
  ...
  NIP [c0000000001eaa48] ftrace_bug+0x2b8/0x3c0
  LR [c0000000001eaff8] ftrace_process_locs+0x4a8/0x590
  Call Trace:
    alloc_pages_current+0xc4/0x1d0 (unreliable)
    ftrace_process_locs+0x4a8/0x590
    load_module+0x1c8c/0x28f0
    SyS_finit_module+0x110/0x140
    system_call+0x38/0xfc
  ...
  ftrace failed to modify
  [<d000000002a31024>] 0xd000000002a31024
   actual:   35:65:00:48

We can avoid this by including in the vermagic whether the kernel/module was
built with mprofile-kernel. Which results in:

  # insmod autofs4-pg.ko
  autofs4: version magic
  '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 SMP mod_unload modversions '
  should be
  '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269-dirty SMP mod_unload modversions mprofile-kernel'
  insmod: ERROR: could not insert module autofs4-pg.ko: Invalid module format

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/module.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h
index 53885512b8d3..6c0132c7212f 100644
--- a/arch/powerpc/include/asm/module.h
+++ b/arch/powerpc/include/asm/module.h
@@ -14,6 +14,10 @@
 #include <asm-generic/module.h>
 
 
+#ifdef CC_USING_MPROFILE_KERNEL
+#define MODULE_ARCH_VERMAGIC	"mprofile-kernel"
+#endif
+
 #ifndef __powerpc64__
 /*
  * Thanks to Paul M for explaining this.
-- 
2.7.4

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

* Re: [PATCH] powerpc/modules: If mprofile-kernel is enabled add it to vermagic
  2017-05-10  6:57 [PATCH] powerpc/modules: If mprofile-kernel is enabled add it to vermagic Michael Ellerman
@ 2017-05-10  7:58 ` Balbir Singh
  2017-05-12  7:20 ` Jessica Yu
  2017-05-17  9:34 ` Michael Ellerman
  2 siblings, 0 replies; 5+ messages in thread
From: Balbir Singh @ 2017-05-10  7:58 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Rusty Russell, Jessica Yu, linux-kernel

On Wed, May 10, 2017 at 4:57 PM, Michael Ellerman <mpe@ellerman.id.au> wrote:
> On powerpc we can build the kernel with two different ABIs for mcount(), which
> is used by ftrace. Kernels built with one ABI do not know how to load modules
> built with the other ABI. The new style ABI is called "mprofile-kernel", for
> want of a better name.
>
> Currently if we build a module using the old style ABI, and the kernel with
> mprofile-kernel, when we load the module we'll oops something like:
>
>   # insmod autofs4-no-mprofile-kernel.ko
>   ftrace-powerpc: Unexpected instruction f8810028 around bl _mcount
>   ------------[ cut here ]------------
>   WARNING: CPU: 6 PID: 3759 at ../kernel/trace/ftrace.c:2024 ftrace_bug+0x2b8/0x3c0
>   CPU: 6 PID: 3759 Comm: insmod Not tainted 4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 #11
>   ...
>   NIP [c0000000001eaa48] ftrace_bug+0x2b8/0x3c0
>   LR [c0000000001eaff8] ftrace_process_locs+0x4a8/0x590
>   Call Trace:
>     alloc_pages_current+0xc4/0x1d0 (unreliable)
>     ftrace_process_locs+0x4a8/0x590
>     load_module+0x1c8c/0x28f0
>     SyS_finit_module+0x110/0x140
>     system_call+0x38/0xfc
>   ...
>   ftrace failed to modify
>   [<d000000002a31024>] 0xd000000002a31024
>    actual:   35:65:00:48
>
> We can avoid this by including in the vermagic whether the kernel/module was
> built with mprofile-kernel. Which results in:
>
>   # insmod autofs4-pg.ko
>   autofs4: version magic
>   '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 SMP mod_unload modversions '
>   should be
>   '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269-dirty SMP mod_unload modversions mprofile-kernel'
>   insmod: ERROR: could not insert module autofs4-pg.ko: Invalid module format
>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> ---
>  arch/powerpc/include/asm/module.h | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h
> index 53885512b8d3..6c0132c7212f 100644
> --- a/arch/powerpc/include/asm/module.h
> +++ b/arch/powerpc/include/asm/module.h
> @@ -14,6 +14,10 @@
>  #include <asm-generic/module.h>
>
>
> +#ifdef CC_USING_MPROFILE_KERNEL
> +#define MODULE_ARCH_VERMAGIC   "mprofile-kernel"
> +#endif
> +
>  #ifndef __powerpc64__
>  /*
>   * Thanks to Paul M for explaining this.
> --

Makes sense

Acked-by: Balbir Singh <bsingharora@gmail.com>

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

* Re: [PATCH] powerpc/modules: If mprofile-kernel is enabled add it to vermagic
  2017-05-10  6:57 [PATCH] powerpc/modules: If mprofile-kernel is enabled add it to vermagic Michael Ellerman
  2017-05-10  7:58 ` Balbir Singh
@ 2017-05-12  7:20 ` Jessica Yu
  2017-05-15  9:24   ` Michael Ellerman
  2017-05-17  9:34 ` Michael Ellerman
  2 siblings, 1 reply; 5+ messages in thread
From: Jessica Yu @ 2017-05-12  7:20 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, rusty, linux-kernel

+++ Michael Ellerman [10/05/17 16:57 +1000]:
>On powerpc we can build the kernel with two different ABIs for mcount(), which
>is used by ftrace. Kernels built with one ABI do not know how to load modules
>built with the other ABI. The new style ABI is called "mprofile-kernel", for
>want of a better name.
>
>Currently if we build a module using the old style ABI, and the kernel with
>mprofile-kernel, when we load the module we'll oops something like:
>
>  # insmod autofs4-no-mprofile-kernel.ko
>  ftrace-powerpc: Unexpected instruction f8810028 around bl _mcount
>  ------------[ cut here ]------------
>  WARNING: CPU: 6 PID: 3759 at ../kernel/trace/ftrace.c:2024 ftrace_bug+0x2b8/0x3c0
>  CPU: 6 PID: 3759 Comm: insmod Not tainted 4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 #11
>  ...
>  NIP [c0000000001eaa48] ftrace_bug+0x2b8/0x3c0
>  LR [c0000000001eaff8] ftrace_process_locs+0x4a8/0x590
>  Call Trace:
>    alloc_pages_current+0xc4/0x1d0 (unreliable)
>    ftrace_process_locs+0x4a8/0x590
>    load_module+0x1c8c/0x28f0
>    SyS_finit_module+0x110/0x140
>    system_call+0x38/0xfc
>  ...
>  ftrace failed to modify
>  [<d000000002a31024>] 0xd000000002a31024
>   actual:   35:65:00:48
>
>We can avoid this by including in the vermagic whether the kernel/module was
>built with mprofile-kernel. Which results in:
>
>  # insmod autofs4-pg.ko
>  autofs4: version magic
>  '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 SMP mod_unload modversions '
>  should be
>  '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269-dirty SMP mod_unload modversions mprofile-kernel'
>  insmod: ERROR: could not insert module autofs4-pg.ko: Invalid module format
>
>Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

Looks good to me:

Acked-by: Jessica Yu <jeyu@redhat.com>

>---
> arch/powerpc/include/asm/module.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
>diff --git a/arch/powerpc/include/asm/module.h b/arch/powerpc/include/asm/module.h
>index 53885512b8d3..6c0132c7212f 100644
>--- a/arch/powerpc/include/asm/module.h
>+++ b/arch/powerpc/include/asm/module.h
>@@ -14,6 +14,10 @@
> #include <asm-generic/module.h>
>
>
>+#ifdef CC_USING_MPROFILE_KERNEL
>+#define MODULE_ARCH_VERMAGIC	"mprofile-kernel"
>+#endif
>+
> #ifndef __powerpc64__
> /*
>  * Thanks to Paul M for explaining this.
>-- 
>2.7.4
>

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

* Re: [PATCH] powerpc/modules: If mprofile-kernel is enabled add it to vermagic
  2017-05-12  7:20 ` Jessica Yu
@ 2017-05-15  9:24   ` Michael Ellerman
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-05-15  9:24 UTC (permalink / raw)
  To: Jessica Yu; +Cc: linuxppc-dev, rusty, linux-kernel

Jessica Yu <jeyu@redhat.com> writes:

> +++ Michael Ellerman [10/05/17 16:57 +1000]:
>>On powerpc we can build the kernel with two different ABIs for mcount(), which
>>is used by ftrace. Kernels built with one ABI do not know how to load modules
>>built with the other ABI. The new style ABI is called "mprofile-kernel", for
>>want of a better name.
>>
>>Currently if we build a module using the old style ABI, and the kernel with
>>mprofile-kernel, when we load the module we'll oops something like:
>>
>>  # insmod autofs4-no-mprofile-kernel.ko
>>  ftrace-powerpc: Unexpected instruction f8810028 around bl _mcount
>>  ------------[ cut here ]------------
>>  WARNING: CPU: 6 PID: 3759 at ../kernel/trace/ftrace.c:2024 ftrace_bug+0x2b8/0x3c0
>>  CPU: 6 PID: 3759 Comm: insmod Not tainted 4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 #11
>>  ...
>>  NIP [c0000000001eaa48] ftrace_bug+0x2b8/0x3c0
>>  LR [c0000000001eaff8] ftrace_process_locs+0x4a8/0x590
>>  Call Trace:
>>    alloc_pages_current+0xc4/0x1d0 (unreliable)
>>    ftrace_process_locs+0x4a8/0x590
>>    load_module+0x1c8c/0x28f0
>>    SyS_finit_module+0x110/0x140
>>    system_call+0x38/0xfc
>>  ...
>>  ftrace failed to modify
>>  [<d000000002a31024>] 0xd000000002a31024
>>   actual:   35:65:00:48
>>
>>We can avoid this by including in the vermagic whether the kernel/module was
>>built with mprofile-kernel. Which results in:
>>
>>  # insmod autofs4-pg.ko
>>  autofs4: version magic
>>  '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 SMP mod_unload modversions '
>>  should be
>>  '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269-dirty SMP mod_unload modversions mprofile-kernel'
>>  insmod: ERROR: could not insert module autofs4-pg.ko: Invalid module format
>>
>>Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
>
> Looks good to me:
>
> Acked-by: Jessica Yu <jeyu@redhat.com>

Thanks.

cheers

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

* Re: powerpc/modules: If mprofile-kernel is enabled add it to vermagic
  2017-05-10  6:57 [PATCH] powerpc/modules: If mprofile-kernel is enabled add it to vermagic Michael Ellerman
  2017-05-10  7:58 ` Balbir Singh
  2017-05-12  7:20 ` Jessica Yu
@ 2017-05-17  9:34 ` Michael Ellerman
  2 siblings, 0 replies; 5+ messages in thread
From: Michael Ellerman @ 2017-05-17  9:34 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: rusty, jeyu, linux-kernel

On Wed, 2017-05-10 at 06:57:49 UTC, Michael Ellerman wrote:
> On powerpc we can build the kernel with two different ABIs for mcount(), which
> is used by ftrace. Kernels built with one ABI do not know how to load modules
> built with the other ABI. The new style ABI is called "mprofile-kernel", for
> want of a better name.
> 
> Currently if we build a module using the old style ABI, and the kernel with
> mprofile-kernel, when we load the module we'll oops something like:
> 
>   # insmod autofs4-no-mprofile-kernel.ko
>   ftrace-powerpc: Unexpected instruction f8810028 around bl _mcount
>   ------------[ cut here ]------------
>   WARNING: CPU: 6 PID: 3759 at ../kernel/trace/ftrace.c:2024 ftrace_bug+0x2b8/0x3c0
>   CPU: 6 PID: 3759 Comm: insmod Not tainted 4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 #11
>   ...
>   NIP [c0000000001eaa48] ftrace_bug+0x2b8/0x3c0
>   LR [c0000000001eaff8] ftrace_process_locs+0x4a8/0x590
>   Call Trace:
>     alloc_pages_current+0xc4/0x1d0 (unreliable)
>     ftrace_process_locs+0x4a8/0x590
>     load_module+0x1c8c/0x28f0
>     SyS_finit_module+0x110/0x140
>     system_call+0x38/0xfc
>   ...
>   ftrace failed to modify
>   [<d000000002a31024>] 0xd000000002a31024
>    actual:   35:65:00:48
> 
> We can avoid this by including in the vermagic whether the kernel/module was
> built with mprofile-kernel. Which results in:
> 
>   # insmod autofs4-pg.ko
>   autofs4: version magic
>   '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269 SMP mod_unload modversions '
>   should be
>   '4.11.0-rc3-gcc-5.4.1-00017-g5a61ef74f269-dirty SMP mod_unload modversions mprofile-kernel'
>   insmod: ERROR: could not insert module autofs4-pg.ko: Invalid module format
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Acked-by: Balbir Singh <bsingharora@gmail.com>
> Acked-by: Jessica Yu <jeyu@redhat.com>

Applied to powerpc fixes.

https://git.kernel.org/powerpc/c/43e24e82f35291d4c1ca78877ce1b2

cheers

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

end of thread, other threads:[~2017-05-17  9:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-10  6:57 [PATCH] powerpc/modules: If mprofile-kernel is enabled add it to vermagic Michael Ellerman
2017-05-10  7:58 ` Balbir Singh
2017-05-12  7:20 ` Jessica Yu
2017-05-15  9:24   ` Michael Ellerman
2017-05-17  9:34 ` 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.