Skip to contentSkip to conversation

powerpc/ftrace: Disable ftrace on ppc32 if using clang

PATCH Applied Naveen N Rao 3 participants 3 messages Jun 9, 2023 – Jul 3, 2023 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/ftrace: Disable ftrace on ppc32 if using clang

Ftrace on ppc32 expects a three instruction sequence at the beginning of each function when specifying -pg:

	mflr	r0
	stw	r0,4(r1)
	bl	_mcount

This is the case with all supported versions of gcc. Clang however emits a branch to _mcount after the function prologue, similar to the pre -mprofile-kernel ABI on ppc64. This is not supported.

Disable ftrace on ppc32 if using clang for now. This can be re-enabled later if clang picks up support for -fpatchable-function-entry on ppc32.

---
 arch/powerpc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -1
index bff5820b7cda14..d85e3cf4016d90 100644
@@ -236,7 +236,7 @@ config PPC
 	select HAVE_FUNCTION_DESCRIPTORS	if PPC64_ELF_ABI_V1
 	select HAVE_FUNCTION_ERROR_INJECTION
 	select HAVE_FUNCTION_GRAPH_TRACER
-	select HAVE_FUNCTION_TRACER
+	select HAVE_FUNCTION_TRACER		if PPC64 || (PPC32 && CC_IS_GCC)
 	select HAVE_GCC_PLUGINS			if GCC_VERSION >= 50200   # plugin support on gcc <= 5.1 is buggy on PPC
 	select HAVE_GENERIC_VDSO
 	select HAVE_HARDLOCKUP_DETECTOR_ARCH	if PPC_BOOK3S_64 && SMP

base-commit: bd517a8442b6c6646a136421cd4c1b95bf4ce32b

Signature · 1 line
2.40.1
Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Naveen N Rao

Ftrace on ppc32 expects a three instruction sequence at the beginning of each function when specifying -pg:

        mflr    r0
        stw     r0,4(r1)
        bl      _mcount
Quoted 8 lines

This is the case with all supported versions of gcc. Clang however emits a branch to _mcount after the function prologue, similar to the pre -mprofile-kernel ABI on ppc64. This is not supported.

Disable ftrace on ppc32 if using clang for now. This can be re-enabled later if clang picks up support for -fpatchable-function-entry on ppc32.

Thanks for the patch! I've filed the below bug, a link to whom I'd like to see retained in the commit message. In the future, please file bugs against the compiler vendors first, then include the relevant link.

Quoted 22 lines
---
 arch/powerpc/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig +1 -1
index bff5820b7cda14..d85e3cf4016d90 100644
@@ -236,7 +236,7 @@ config PPC
        select HAVE_FUNCTION_DESCRIPTORS        if PPC64_ELF_ABI_V1
        select HAVE_FUNCTION_ERROR_INJECTION
        select HAVE_FUNCTION_GRAPH_TRACER
-       select HAVE_FUNCTION_TRACER
+       select HAVE_FUNCTION_TRACER             if PPC64 || (PPC32 && CC_IS_GCC)
        select HAVE_GCC_PLUGINS                 if GCC_VERSION >= 50200   # plugin support on gcc <= 5.1 is buggy on PPC
        select HAVE_GENERIC_VDSO
        select HAVE_HARDLOCKUP_DETECTOR_ARCH    if PPC_BOOK3S_64 && SMP

base-commit: bd517a8442b6c6646a136421cd4c1b95bf4ce32b --
2.40.1

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
In reply to Naveen N Rao
Quoted 11 lines · Naveen N Rao

Ftrace on ppc32 expects a three instruction sequence at the beginning of each function when specifying -pg:

	mflr	r0
	stw	r0,4(r1)
	bl	_mcount

This is the case with all supported versions of gcc. Clang however emits a branch to _mcount after the function prologue, similar to the pre -mprofile-kernel ABI on ppc64. This is not supported.

[...]

Applied to powerpc/next.

[1/1] powerpc/ftrace: Disable ftrace on ppc32 if using clang

      https://git.kernel.org/powerpc/c/d24da1f85530a5b47590c0febd1395dd8fc73124

cheers