aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/powerpc/Kconfig19
-rw-r--r--arch/powerpc/Makefile15
-rwxr-xr-xarch/powerpc/scripts/gcc-check-mprofile-kernel.sh23
3 files changed, 57 insertions, 0 deletions
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index e4824fd04bb7..91da283cd658 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -94,6 +94,7 @@ config PPC
94 select OF_RESERVED_MEM 94 select OF_RESERVED_MEM
95 select HAVE_FTRACE_MCOUNT_RECORD 95 select HAVE_FTRACE_MCOUNT_RECORD
96 select HAVE_DYNAMIC_FTRACE 96 select HAVE_DYNAMIC_FTRACE
97 select HAVE_DYNAMIC_FTRACE_WITH_REGS if MPROFILE_KERNEL
97 select HAVE_FUNCTION_TRACER 98 select HAVE_FUNCTION_TRACER
98 select HAVE_FUNCTION_GRAPH_TRACER 99 select HAVE_FUNCTION_GRAPH_TRACER
99 select SYSCTL_EXCEPTION_TRACE 100 select SYSCTL_EXCEPTION_TRACE
@@ -373,6 +374,24 @@ config PPC_TRANSACTIONAL_MEM
373 ---help--- 374 ---help---
374 Support user-mode Transactional Memory on POWERPC. 375 Support user-mode Transactional Memory on POWERPC.
375 376
377config DISABLE_MPROFILE_KERNEL
378 bool "Disable use of mprofile-kernel for kernel tracing"
379 depends on PPC64 && CPU_LITTLE_ENDIAN
380 default y
381 help
382 Selecting this options disables use of the mprofile-kernel ABI for
383 kernel tracing. That will cause options such as live patching
384 (CONFIG_LIVEPATCH) which depend on CONFIG_DYNAMIC_FTRACE_WITH_REGS to
385 be disabled also.
386
387 If you have a toolchain which supports mprofile-kernel, then you can
388 enable this. Otherwise leave it disabled. If you're not sure, say
389 "N".
390
391config MPROFILE_KERNEL
392 depends on PPC64 && CPU_LITTLE_ENDIAN
393 def_bool !DISABLE_MPROFILE_KERNEL
394
376config IOMMU_HELPER 395config IOMMU_HELPER
377 def_bool PPC64 396 def_bool PPC64
378 397
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 96efd8213c1c..f4e49a4153cb 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -133,6 +133,21 @@ else
133CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64 133CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
134endif 134endif
135 135
136ifdef CONFIG_MPROFILE_KERNEL
137 ifeq ($(shell $(srctree)/arch/powerpc/scripts/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__),OK)
138 CC_FLAGS_FTRACE := -pg -mprofile-kernel
139 KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL
140 else
141 # If the user asked for mprofile-kernel but the toolchain doesn't
142 # support it, emit a warning and deliberately break the build later
143 # with mprofile-kernel-not-supported. We would prefer to make this an
144 # error right here, but then the user would never be able to run
145 # oldconfig to change their configuration.
146 $(warning Compiler does not support mprofile-kernel, set CONFIG_DISABLE_MPROFILE_KERNEL)
147 CC_FLAGS_FTRACE := -mprofile-kernel-not-supported
148 endif
149endif
150
136CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell) 151CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell)
137CFLAGS-$(CONFIG_POWER4_CPU) += $(call cc-option,-mcpu=power4) 152CFLAGS-$(CONFIG_POWER4_CPU) += $(call cc-option,-mcpu=power4)
138CFLAGS-$(CONFIG_POWER5_CPU) += $(call cc-option,-mcpu=power5) 153CFLAGS-$(CONFIG_POWER5_CPU) += $(call cc-option,-mcpu=power5)
diff --git a/arch/powerpc/scripts/gcc-check-mprofile-kernel.sh b/arch/powerpc/scripts/gcc-check-mprofile-kernel.sh
new file mode 100755
index 000000000000..c658d8cf760b
--- /dev/null
+++ b/arch/powerpc/scripts/gcc-check-mprofile-kernel.sh
@@ -0,0 +1,23 @@
1#!/bin/bash
2
3set -e
4set -o pipefail
5
6# To debug, uncomment the following line
7# set -x
8
9# Test whether the compile option -mprofile-kernel exists and generates
10# profiling code (ie. a call to _mcount()).
11echo "int func() { return 0; }" | \
12 $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
13 grep -q "_mcount"
14
15# Test whether the notrace attribute correctly suppresses calls to _mcount().
16
17echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
18 $* -S -x c -O2 -p -mprofile-kernel - -o - 2> /dev/null | \
19 grep -q "_mcount" && \
20 exit 1
21
22echo "OK"
23exit 0