Skip to content

Commit

Permalink
powerpc/64: Use -mprofile-kernel for big endian ELFv2 kernels
Browse files Browse the repository at this point in the history
-mprofile-kernel is an optimised calling convention for mcount that
Linux  has only implemented with the ELFv2 ABI, so it was disabled for
big endian kernels. However it does work with ELFv2 big endian, so let's
allow that if the compiler supports it.

Acked-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Suggested-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20230606093832.199712-4-npiggin@gmail.com
  • Loading branch information
npiggin authored and mpe committed Jun 14, 2023
1 parent 8c5fa3b commit aec0ba7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions arch/powerpc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,9 @@ config LD_HEAD_STUB_CATCH
If unsure, say "N".

config MPROFILE_KERNEL
depends on PPC64 && CPU_LITTLE_ENDIAN && FUNCTION_TRACER
def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)
depends on PPC64_ELF_ABI_V2 && FUNCTION_TRACER
def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -mlittle-endian) if CPU_LITTLE_ENDIAN
def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -mbig-endian) if CPU_BIG_ENDIAN

config HOTPLUG_CPU
bool "Support for enabling/disabling CPUs"
Expand Down
11 changes: 6 additions & 5 deletions arch/powerpc/tools/gcc-check-mprofile-kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,21 @@ set -o pipefail
# To debug, uncomment the following line
# set -x

# -mprofile-kernel is only supported on 64le, so this should not be invoked
# for other targets. Therefore we can pass in -m64 and -mlittle-endian
# explicitly, to take care of toolchains defaulting to other targets.
# -mprofile-kernel is only supported on 64-bit, so this should not be invoked
# for 32-bit. We pass in -m64 explicitly, and -mbig-endian and -mlittle-endian
# are passed in from Kconfig, which takes care of toolchains defaulting to
# other targets.

# Test whether the compile option -mprofile-kernel exists and generates
# profiling code (ie. a call to _mcount()).
echo "int func() { return 0; }" | \
$* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
$* -m64 -S -x c -O2 -p -mprofile-kernel - -o - \
2> /dev/null | grep -q "_mcount"

# Test whether the notrace attribute correctly suppresses calls to _mcount().

echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
$* -m64 -mlittle-endian -S -x c -O2 -p -mprofile-kernel - -o - \
$* -m64 -S -x c -O2 -p -mprofile-kernel - -o - \
2> /dev/null | grep -q "_mcount" && \
exit 1

Expand Down

0 comments on commit aec0ba7

Please sign in to comment.