linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/kprobes: Remove kretprobe_trampoline_holder.
@ 2016-03-31 20:10 Thiago Jung Bauermann
  2016-04-14  0:43 ` Thiago Jung Bauermann
  2016-06-21 12:27 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Thiago Jung Bauermann @ 2016-03-31 20:10 UTC (permalink / raw)
  To: linuxppc-dev
  Cc: Naveen N. Rao, Thiago Jung Bauermann, Ananth N Mavinakayanahalli,
	Michael Ellerman

Fixes the following testsuite failure:

  $ sudo ./perf test -v kallsyms
   1: vmlinux symtab matches kallsyms                          :
  --- start ---
  test child forked, pid 12489
  Using /proc/kcore for kernel object code
  Looking at the vmlinux_path (8 entries long)
  Using /boot/vmlinux for symbols
  0xc00000000003d300: diff name v: .kretprobe_trampoline_holder k: kretprobe_trampoline
  Maps only in vmlinux:
   c00000000086ca38-c000000000879b6c 87ca38 [kernel].text.unlikely
   c000000000879b6c-c000000000bf0000 889b6c [kernel].meminit.text
   c000000000bf0000-c000000000c53264 c00000 [kernel].init.text
   c000000000c53264-d000000004250000 c63264 [kernel].exit.text
   d000000004250000-d000000004450000 0 [libcrc32c]
   d000000004450000-d000000004620000 0 [xfs]
   d000000004620000-d000000004680000 0 [autofs4]
   d000000004680000-d0000000046e0000 0 [x_tables]
   d0000000046e0000-d000000004780000 0 [ip_tables]
   d000000004780000-d0000000047e0000 0 [rng_core]
   d0000000047e0000-ffffffffffffffff 0 [pseries_rng]
  Maps in vmlinux with a different name in kallsyms:
  Maps only in kallsyms:
   d000000000000000-f000000000000000 1000000000010000 [kernel.kallsyms]
   f000000000000000-ffffffffffffffff 3000000000010000 [kernel.kallsyms]
  test child finished with -1
  ---- end ----
  vmlinux symtab matches kallsyms: FAILED!

The problem is that the kretprobe_trampoline symbol looks like this:

  $ eu-readelf -s /boot/vmlinux G kretprobe_trampoline
   2431: c000000001302368     24 NOTYPE  LOCAL  DEFAULT       37 kretprobe_trampoline_holder
   2432: c00000000003d300      8 FUNC    LOCAL  DEFAULT        1 .kretprobe_trampoline_holder
  97543: c00000000003d300      0 NOTYPE  GLOBAL DEFAULT        1 kretprobe_trampoline

Its type is NOTYPE, and its size is 0, and this is a problem because
symbol-elf.c:dso__load_sym skips function symbols that are not STT_FUNC
or STT_GNU_IFUNC (this is determined by elf_sym__is_function). Even
if the type is changed to STT_FUNC, when dso__load_sym calls
symbols__fixup_duplicate, the kretprobe_trampoline symbol is dropped in
favour of .kretprobe_trampoline_holder because the latter has non-zero
size (as determined by choose_best_symbol).

With this patch, all vmlinux symbols match /proc/kallsyms and the
testcase passes.

Commit c1c355ce14c0 ("x86/kprobes: Get rid of
kretprobe_trampoline_holder()") gets rid of kretprobe_trampoline_holder
altogether on x86. This commit does the same on powerpc. This change
introduces no regressions on the perf and ftracetest testsuite results.

Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/kprobes.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 7c053f281406..417c0eadd094 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -278,12 +278,11 @@ no_kprobe:
  * 	- When the probed function returns, this probe
  * 		causes the handlers to fire
  */
-static void __used kretprobe_trampoline_holder(void)
-{
-	asm volatile(".global kretprobe_trampoline\n"
-			"kretprobe_trampoline:\n"
-			"nop\n");
-}
+asm(".global kretprobe_trampoline\n"
+	".type kretprobe_trampoline, @function\n"
+	"kretprobe_trampoline:\n"
+	"nop\n"
+	".size kretprobe_trampoline, .-kretprobe_trampoline\n");
 
 /*
  * Called when the probe at kretprobe trampoline is hit
-- 
1.9.1

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

* Re: [PATCH] powerpc/kprobes: Remove kretprobe_trampoline_holder.
  2016-03-31 20:10 [PATCH] powerpc/kprobes: Remove kretprobe_trampoline_holder Thiago Jung Bauermann
@ 2016-04-14  0:43 ` Thiago Jung Bauermann
  2016-06-21 12:27 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Thiago Jung Bauermann @ 2016-04-14  0:43 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Naveen N. Rao

Hello,

People seem to be considering patches for next, so this looks like a go=
od=20
moment to ping about this one.

--=20
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center



Am Donnerstag, 31 M=E4rz 2016, 17:10:40 schrieb Thiago Jung Bauermann:
> Fixes the following testsuite failure:
>=20
>   $ sudo ./perf test -v kallsyms
>    1: vmlinux symtab matches kallsyms                          :
>   --- start ---
>   test child forked, pid 12489
>   Using /proc/kcore for kernel object code
>   Looking at the vmlinux_path (8 entries long)
>   Using /boot/vmlinux for symbols
>   0xc00000000003d300: diff name v: .kretprobe_trampoline_holder k:
> kretprobe_trampoline Maps only in vmlinux:
>    c00000000086ca38-c000000000879b6c 87ca38 [kernel].text.unlikely
>    c000000000879b6c-c000000000bf0000 889b6c [kernel].meminit.text
>    c000000000bf0000-c000000000c53264 c00000 [kernel].init.text
>    c000000000c53264-d000000004250000 c63264 [kernel].exit.text
>    d000000004250000-d000000004450000 0 [libcrc32c]
>    d000000004450000-d000000004620000 0 [xfs]
>    d000000004620000-d000000004680000 0 [autofs4]
>    d000000004680000-d0000000046e0000 0 [x_tables]
>    d0000000046e0000-d000000004780000 0 [ip_tables]
>    d000000004780000-d0000000047e0000 0 [rng_core]
>    d0000000047e0000-ffffffffffffffff 0 [pseries_rng]
>   Maps in vmlinux with a different name in kallsyms:
>   Maps only in kallsyms:
>    d000000000000000-f000000000000000 1000000000010000 [kernel.kallsym=
s]
>    f000000000000000-ffffffffffffffff 3000000000010000 [kernel.kallsym=
s]
>   test child finished with -1
>   ---- end ----
>   vmlinux symtab matches kallsyms: FAILED!
>=20
> The problem is that the kretprobe_trampoline symbol looks like this:
>=20
>   $ eu-readelf -s /boot/vmlinux G kretprobe_trampoline
>    2431: c000000001302368     24 NOTYPE  LOCAL  DEFAULT       37
> kretprobe_trampoline_holder 2432: c00000000003d300      8 FUNC    LOC=
AL=20
> DEFAULT        1 .kretprobe_trampoline_holder 97543: c00000000003d300=
   =20
>  0 NOTYPE  GLOBAL DEFAULT        1 kretprobe_trampoline
>=20
> Its type is NOTYPE, and its size is 0, and this is a problem because
> symbol-elf.c:dso__load_sym skips function symbols that are not STT_FU=
NC
> or STT_GNU_IFUNC (this is determined by elf_sym__is_function). Even
> if the type is changed to STT_FUNC, when dso__load_sym calls
> symbols__fixup_duplicate, the kretprobe_trampoline symbol is dropped =
in
> favour of .kretprobe_trampoline_holder because the latter has non-zer=
o
> size (as determined by choose_best_symbol).
>=20
> With this patch, all vmlinux symbols match /proc/kallsyms and the
> testcase passes.
>=20
> Commit c1c355ce14c0 ("x86/kprobes: Get rid of
> kretprobe_trampoline_holder()") gets rid of kretprobe_trampoline_hold=
er
> altogether on x86. This commit does the same on powerpc. This change
> introduces no regressions on the perf and ftracetest testsuite result=
s.
>=20
> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
> ---
>  arch/powerpc/kernel/kprobes.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>=20
> diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kpro=
bes.c
> index 7c053f281406..417c0eadd094 100644
> --- a/arch/powerpc/kernel/kprobes.c
> +++ b/arch/powerpc/kernel/kprobes.c
> @@ -278,12 +278,11 @@ no_kprobe:
>   * =09- When the probed function returns, this probe
>   * =09=09causes the handlers to fire
>   */
> -static void __used kretprobe_trampoline_holder(void)
> -{
> -=09asm volatile(".global kretprobe_trampoline\n"
> -=09=09=09"kretprobe_trampoline:\n"
> -=09=09=09"nop\n");
> -}
> +asm(".global kretprobe_trampoline\n"
> +=09".type kretprobe_trampoline, @function\n"
> +=09"kretprobe_trampoline:\n"
> +=09"nop\n"
> +=09".size kretprobe_trampoline, .-kretprobe_trampoline\n");
>=20
>  /*
>   * Called when the probe at kretprobe trampoline is hit

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

* Re: powerpc/kprobes: Remove kretprobe_trampoline_holder.
  2016-03-31 20:10 [PATCH] powerpc/kprobes: Remove kretprobe_trampoline_holder Thiago Jung Bauermann
  2016-04-14  0:43 ` Thiago Jung Bauermann
@ 2016-06-21 12:27 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2016-06-21 12:27 UTC (permalink / raw)
  To: Thiago Jung Bauermann, linuxppc-dev; +Cc: Thiago Jung Bauermann, Naveen N. Rao

On Thu, 2016-31-03 at 20:10:40 UTC, Thiago Jung Bauermann wrote:
> Fixes the following testsuite failure:
> 
>   $ sudo ./perf test -v kallsyms
>    1: vmlinux symtab matches kallsyms                          :
>   --- start ---
>   test child forked, pid 12489
>   Using /proc/kcore for kernel object code
>   Looking at the vmlinux_path (8 entries long)
>   Using /boot/vmlinux for symbols
>   0xc00000000003d300: diff name v: .kretprobe_trampoline_holder k: kretprobe_trampoline
>   Maps only in vmlinux:
>    c00000000086ca38-c000000000879b6c 87ca38 [kernel].text.unlikely
>    c000000000879b6c-c000000000bf0000 889b6c [kernel].meminit.text
>    c000000000bf0000-c000000000c53264 c00000 [kernel].init.text
>    c000000000c53264-d000000004250000 c63264 [kernel].exit.text
>    d000000004250000-d000000004450000 0 [libcrc32c]
>    d000000004450000-d000000004620000 0 [xfs]
>    d000000004620000-d000000004680000 0 [autofs4]
>    d000000004680000-d0000000046e0000 0 [x_tables]
>    d0000000046e0000-d000000004780000 0 [ip_tables]
>    d000000004780000-d0000000047e0000 0 [rng_core]
>    d0000000047e0000-ffffffffffffffff 0 [pseries_rng]
>   Maps in vmlinux with a different name in kallsyms:
>   Maps only in kallsyms:
>    d000000000000000-f000000000000000 1000000000010000 [kernel.kallsyms]
>    f000000000000000-ffffffffffffffff 3000000000010000 [kernel.kallsyms]
>   test child finished with -1
>   ---- end ----
>   vmlinux symtab matches kallsyms: FAILED!
> 
> The problem is that the kretprobe_trampoline symbol looks like this:
> 
>   $ eu-readelf -s /boot/vmlinux G kretprobe_trampoline
>    2431: c000000001302368     24 NOTYPE  LOCAL  DEFAULT       37 kretprobe_trampoline_holder
>    2432: c00000000003d300      8 FUNC    LOCAL  DEFAULT        1 .kretprobe_trampoline_holder
>   97543: c00000000003d300      0 NOTYPE  GLOBAL DEFAULT        1 kretprobe_trampoline
> 
> Its type is NOTYPE, and its size is 0, and this is a problem because
> symbol-elf.c:dso__load_sym skips function symbols that are not STT_FUNC
> or STT_GNU_IFUNC (this is determined by elf_sym__is_function). Even
> if the type is changed to STT_FUNC, when dso__load_sym calls
> symbols__fixup_duplicate, the kretprobe_trampoline symbol is dropped in
> favour of .kretprobe_trampoline_holder because the latter has non-zero
> size (as determined by choose_best_symbol).
> 
> With this patch, all vmlinux symbols match /proc/kallsyms and the
> testcase passes.
> 
> Commit c1c355ce14c0 ("x86/kprobes: Get rid of
> kretprobe_trampoline_holder()") gets rid of kretprobe_trampoline_holder
> altogether on x86. This commit does the same on powerpc. This change
> introduces no regressions on the perf and ftracetest testsuite results.
> 
> Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> Signed-off-by: Thiago Jung Bauermann <bauerman@linux.vnet.ibm.com>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/61ed9cfb1b0951a3b4b98dd8bf

cheers

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

end of thread, other threads:[~2016-06-21 12:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-31 20:10 [PATCH] powerpc/kprobes: Remove kretprobe_trampoline_holder Thiago Jung Bauermann
2016-04-14  0:43 ` Thiago Jung Bauermann
2016-06-21 12:27 ` Michael Ellerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).