All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc64/ftrace: Fix ftrace for clang builds
@ 2022-08-09  9:59 ` Naveen N. Rao
  0 siblings, 0 replies; 8+ messages in thread
From: Naveen N. Rao @ 2022-08-09  9:59 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: linuxppc-dev, Christophe Leroy, Nick Desaulniers, Ondrej Mosnacek, llvm

Clang doesn't support -mprofile-kernel ABI, so guard the checks against
CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version.

Fixes: 23b44fc248f420 ("powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64")
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Ondrej Mosnacek <omosnacek@gmail.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/trace/ftrace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
index cb158c32b50b99..7b85c3b460a3c0 100644
--- a/arch/powerpc/kernel/trace/ftrace.c
+++ b/arch/powerpc/kernel/trace/ftrace.c
@@ -393,11 +393,11 @@ int ftrace_make_nop(struct module *mod,
  */
 static bool expected_nop_sequence(void *ip, ppc_inst_t op0, ppc_inst_t op1)
 {
-	if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1))
+	if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS))
+		return ppc_inst_equal(op0, ppc_inst(PPC_RAW_NOP()));
+	else
 		return ppc_inst_equal(op0, ppc_inst(PPC_RAW_BRANCH(8))) &&
 		       ppc_inst_equal(op1, ppc_inst(PPC_INST_LD_TOC));
-	else
-		return ppc_inst_equal(op0, ppc_inst(PPC_RAW_NOP()));
 }
 
 static int
@@ -412,7 +412,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
 	if (copy_inst_from_kernel_nofault(op, ip))
 		return -EFAULT;
 
-	if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1) &&
+	if (!IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS) &&
 	    copy_inst_from_kernel_nofault(op + 1, ip + 4))
 		return -EFAULT;
 

base-commit: ff1ed171e05c971652a0ede3d716997de8ee41c9
-- 
2.37.1


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

* [PATCH] powerpc64/ftrace: Fix ftrace for clang builds
@ 2022-08-09  9:59 ` Naveen N. Rao
  0 siblings, 0 replies; 8+ messages in thread
From: Naveen N. Rao @ 2022-08-09  9:59 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: Nick Desaulniers, llvm, linuxppc-dev, Ondrej Mosnacek

Clang doesn't support -mprofile-kernel ABI, so guard the checks against
CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version.

Fixes: 23b44fc248f420 ("powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64")
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Reported-by: Ondrej Mosnacek <omosnacek@gmail.com>
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
---
 arch/powerpc/kernel/trace/ftrace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c
index cb158c32b50b99..7b85c3b460a3c0 100644
--- a/arch/powerpc/kernel/trace/ftrace.c
+++ b/arch/powerpc/kernel/trace/ftrace.c
@@ -393,11 +393,11 @@ int ftrace_make_nop(struct module *mod,
  */
 static bool expected_nop_sequence(void *ip, ppc_inst_t op0, ppc_inst_t op1)
 {
-	if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1))
+	if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS))
+		return ppc_inst_equal(op0, ppc_inst(PPC_RAW_NOP()));
+	else
 		return ppc_inst_equal(op0, ppc_inst(PPC_RAW_BRANCH(8))) &&
 		       ppc_inst_equal(op1, ppc_inst(PPC_INST_LD_TOC));
-	else
-		return ppc_inst_equal(op0, ppc_inst(PPC_RAW_NOP()));
 }
 
 static int
@@ -412,7 +412,7 @@ __ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
 	if (copy_inst_from_kernel_nofault(op, ip))
 		return -EFAULT;
 
-	if (IS_ENABLED(CONFIG_PPC64_ELF_ABI_V1) &&
+	if (!IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS) &&
 	    copy_inst_from_kernel_nofault(op + 1, ip + 4))
 		return -EFAULT;
 

base-commit: ff1ed171e05c971652a0ede3d716997de8ee41c9
-- 
2.37.1


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

* Re: [PATCH] powerpc64/ftrace: Fix ftrace for clang builds
  2022-08-09  9:59 ` Naveen N. Rao
@ 2022-08-09 16:59   ` Ondrej Mosnáček
  -1 siblings, 0 replies; 8+ messages in thread
From: Ondrej Mosnáček @ 2022-08-09 16:59 UTC (permalink / raw)
  To: Naveen N. Rao
  Cc: Michael Ellerman, linuxppc-dev, Christophe Leroy, Nick Desaulniers, llvm

On Tue, Aug 9, 2022 at 11:59 AM Naveen N. Rao
<naveen.n.rao@linux.vnet.ibm.com> wrote:
> Clang doesn't support -mprofile-kernel ABI, so guard the checks against
> CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version.
>
> Fixes: 23b44fc248f420 ("powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64")
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Reported-by: Ondrej Mosnacek <omosnacek@gmail.com>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
>  arch/powerpc/kernel/trace/ftrace.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

With this patch my reproducer [1] is passing, thanks!

Tested-by: Ondrej Mosnacek <omosnacek@gmail.com>

[1] https://github.com/ClangBuiltLinux/linux/issues/1682#issue-1330483247

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

* Re: [PATCH] powerpc64/ftrace: Fix ftrace for clang builds
@ 2022-08-09 16:59   ` Ondrej Mosnáček
  0 siblings, 0 replies; 8+ messages in thread
From: Ondrej Mosnáček @ 2022-08-09 16:59 UTC (permalink / raw)
  To: Naveen N. Rao; +Cc: llvm, Nick Desaulniers, linuxppc-dev

On Tue, Aug 9, 2022 at 11:59 AM Naveen N. Rao
<naveen.n.rao@linux.vnet.ibm.com> wrote:
> Clang doesn't support -mprofile-kernel ABI, so guard the checks against
> CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version.
>
> Fixes: 23b44fc248f420 ("powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64")
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Reported-by: Ondrej Mosnacek <omosnacek@gmail.com>
> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> ---
>  arch/powerpc/kernel/trace/ftrace.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

With this patch my reproducer [1] is passing, thanks!

Tested-by: Ondrej Mosnacek <omosnacek@gmail.com>

[1] https://github.com/ClangBuiltLinux/linux/issues/1682#issue-1330483247

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

* Re: [PATCH] powerpc64/ftrace: Fix ftrace for clang builds
  2022-08-09 16:59   ` Ondrej Mosnáček
@ 2022-08-09 17:10     ` Nick Desaulniers
  -1 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2022-08-09 17:10 UTC (permalink / raw)
  To: Ondrej Mosnáček, Naveen N. Rao, Michael Ellerman
  Cc: linuxppc-dev, Christophe Leroy, llvm

On Tue, Aug 9, 2022 at 9:59 AM Ondrej Mosnáček <omosnacek@gmail.com> wrote:
>
> On Tue, Aug 9, 2022 at 11:59 AM Naveen N. Rao
> <naveen.n.rao@linux.vnet.ibm.com> wrote:
> > Clang doesn't support -mprofile-kernel ABI, so guard the checks against
> > CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version.
> >
> > Fixes: 23b44fc248f420 ("powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64")
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Reported-by: Ondrej Mosnacek <omosnacek@gmail.com>
> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> > ---
> >  arch/powerpc/kernel/trace/ftrace.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
>
> With this patch my reproducer [1] is passing, thanks!
>
> Tested-by: Ondrej Mosnacek <omosnacek@gmail.com>
>
> [1] https://github.com/ClangBuiltLinux/linux/issues/1682#issue-1330483247

Thanks for the report and fixup. I filed
https://github.com/llvm/llvm-project/issues/57031
as a feature request for -mprofile-kernel in clang.  If there are
other missing features for this target, let's get bugs filed for them.

Acked-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://github.com/llvm/llvm-project/issues/57031
Link: https://github.com/ClangBuiltLinux/linux/issues/1682

MPE: can you please ensure the above two links get added if/when applying?
-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] powerpc64/ftrace: Fix ftrace for clang builds
@ 2022-08-09 17:10     ` Nick Desaulniers
  0 siblings, 0 replies; 8+ messages in thread
From: Nick Desaulniers @ 2022-08-09 17:10 UTC (permalink / raw)
  To: Ondrej Mosnáček, Naveen N. Rao, Michael Ellerman
  Cc: llvm, linuxppc-dev

On Tue, Aug 9, 2022 at 9:59 AM Ondrej Mosnáček <omosnacek@gmail.com> wrote:
>
> On Tue, Aug 9, 2022 at 11:59 AM Naveen N. Rao
> <naveen.n.rao@linux.vnet.ibm.com> wrote:
> > Clang doesn't support -mprofile-kernel ABI, so guard the checks against
> > CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version.
> >
> > Fixes: 23b44fc248f420 ("powerpc/ftrace: Make __ftrace_make_{nop/call}() common to PPC32 and PPC64")
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Reported-by: Ondrej Mosnacek <omosnacek@gmail.com>
> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
> > ---
> >  arch/powerpc/kernel/trace/ftrace.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
>
> With this patch my reproducer [1] is passing, thanks!
>
> Tested-by: Ondrej Mosnacek <omosnacek@gmail.com>
>
> [1] https://github.com/ClangBuiltLinux/linux/issues/1682#issue-1330483247

Thanks for the report and fixup. I filed
https://github.com/llvm/llvm-project/issues/57031
as a feature request for -mprofile-kernel in clang.  If there are
other missing features for this target, let's get bugs filed for them.

Acked-by: Nick Desaulniers <ndesaulniers@google.com>
Link: https://github.com/llvm/llvm-project/issues/57031
Link: https://github.com/ClangBuiltLinux/linux/issues/1682

MPE: can you please ensure the above two links get added if/when applying?
-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] powerpc64/ftrace: Fix ftrace for clang builds
  2022-08-09  9:59 ` Naveen N. Rao
@ 2022-08-13 22:38   ` Michael Ellerman
  -1 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2022-08-13 22:38 UTC (permalink / raw)
  To: Michael Ellerman, Naveen N. Rao
  Cc: Nick Desaulniers, llvm, Ondrej Mosnacek, linuxppc-dev

On Tue, 9 Aug 2022 15:29:07 +0530, Naveen N. Rao wrote:
> Clang doesn't support -mprofile-kernel ABI, so guard the checks against
> CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version.
> 
> 

Applied to powerpc/fixes.

[1/1] powerpc64/ftrace: Fix ftrace for clang builds
      https://git.kernel.org/powerpc/c/cb928ac192128c842f4c1cfc8b6780b95719d65f

cheers

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

* Re: [PATCH] powerpc64/ftrace: Fix ftrace for clang builds
@ 2022-08-13 22:38   ` Michael Ellerman
  0 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2022-08-13 22:38 UTC (permalink / raw)
  To: Michael Ellerman, Naveen N. Rao
  Cc: Ondrej Mosnacek, Nick Desaulniers, linuxppc-dev, llvm, Christophe Leroy

On Tue, 9 Aug 2022 15:29:07 +0530, Naveen N. Rao wrote:
> Clang doesn't support -mprofile-kernel ABI, so guard the checks against
> CONFIG_DYNAMIC_FTRACE_WITH_REGS, rather than the elf ABI version.
> 
> 

Applied to powerpc/fixes.

[1/1] powerpc64/ftrace: Fix ftrace for clang builds
      https://git.kernel.org/powerpc/c/cb928ac192128c842f4c1cfc8b6780b95719d65f

cheers

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

end of thread, other threads:[~2022-08-13 22:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-09  9:59 [PATCH] powerpc64/ftrace: Fix ftrace for clang builds Naveen N. Rao
2022-08-09  9:59 ` Naveen N. Rao
2022-08-09 16:59 ` Ondrej Mosnáček
2022-08-09 16:59   ` Ondrej Mosnáček
2022-08-09 17:10   ` Nick Desaulniers
2022-08-09 17:10     ` Nick Desaulniers
2022-08-13 22:38 ` Michael Ellerman
2022-08-13 22:38   ` 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.