summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2013-05-23 23:02:25 -0400
committerChris Zankel <chris@zankel.net>2013-07-08 04:18:57 -0400
commit478ba61afccd3a4d7ca662cadff1d35d183fe67d (patch)
tree9458a98aa39dba5e195241a48a4c31435a4c92e3 /arch
parent220f5354089b27e8eeaa8658806dabc59ce55729 (diff)
xtensa: add static function tracer support
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com> Signed-off-by: Chris Zankel <chris@zankel.net>
Diffstat (limited to 'arch')
-rw-r--r--arch/xtensa/Kconfig1
-rw-r--r--arch/xtensa/boot/lib/Makefile7
-rw-r--r--arch/xtensa/include/asm/ftrace.h17
-rw-r--r--arch/xtensa/kernel/Makefile1
-rw-r--r--arch/xtensa/kernel/mcount.S50
-rw-r--r--arch/xtensa/kernel/xtensa_ksyms.c4
6 files changed, 78 insertions, 2 deletions
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 8852c0d35834..7ea6451a3a33 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -19,6 +19,7 @@ config XTENSA
19 select CLONE_BACKWARDS 19 select CLONE_BACKWARDS
20 select IRQ_DOMAIN 20 select IRQ_DOMAIN
21 select HAVE_OPROFILE 21 select HAVE_OPROFILE
22 select HAVE_FUNCTION_TRACER
22 help 23 help
23 Xtensa processors are 32-bit RISC machines designed by Tensilica 24 Xtensa processors are 32-bit RISC machines designed by Tensilica
24 primarily for embedded systems. These processors are both 25 primarily for embedded systems. These processors are both
diff --git a/arch/xtensa/boot/lib/Makefile b/arch/xtensa/boot/lib/Makefile
index ad8952e8a07f..6868f2ca6af8 100644
--- a/arch/xtensa/boot/lib/Makefile
+++ b/arch/xtensa/boot/lib/Makefile
@@ -7,6 +7,13 @@ zlib := inffast.c inflate.c inftrees.c
7lib-y += $(zlib:.c=.o) zmem.o 7lib-y += $(zlib:.c=.o) zmem.o
8 8
9ccflags-y := -Ilib/zlib_inflate 9ccflags-y := -Ilib/zlib_inflate
10ifdef CONFIG_FUNCTION_TRACER
11CFLAGS_REMOVE_inflate.o = -pg
12CFLAGS_REMOVE_zmem.o = -pg
13CFLAGS_REMOVE_inftrees.o = -pg
14CFLAGS_REMOVE_inffast.o = -pg
15endif
16
10 17
11quiet_cmd_copy_zlib = COPY $@ 18quiet_cmd_copy_zlib = COPY $@
12 cmd_copy_zlib = cat $< > $@ 19 cmd_copy_zlib = cat $< > $@
diff --git a/arch/xtensa/include/asm/ftrace.h b/arch/xtensa/include/asm/ftrace.h
index 36dc7a684397..73cc3f482304 100644
--- a/arch/xtensa/include/asm/ftrace.h
+++ b/arch/xtensa/include/asm/ftrace.h
@@ -13,6 +13,7 @@
13#include <asm/processor.h> 13#include <asm/processor.h>
14 14
15#define HAVE_ARCH_CALLER_ADDR 15#define HAVE_ARCH_CALLER_ADDR
16#ifndef __ASSEMBLY__
16#define CALLER_ADDR0 ({ unsigned long a0, a1; \ 17#define CALLER_ADDR0 ({ unsigned long a0, a1; \
17 __asm__ __volatile__ ( \ 18 __asm__ __volatile__ ( \
18 "mov %0, a0\n" \ 19 "mov %0, a0\n" \
@@ -24,10 +25,22 @@ extern unsigned long return_address(unsigned level);
24#define CALLER_ADDR1 return_address(1) 25#define CALLER_ADDR1 return_address(1)
25#define CALLER_ADDR2 return_address(2) 26#define CALLER_ADDR2 return_address(2)
26#define CALLER_ADDR3 return_address(3) 27#define CALLER_ADDR3 return_address(3)
27#else 28#else /* CONFIG_FRAME_POINTER */
28#define CALLER_ADDR1 (0) 29#define CALLER_ADDR1 (0)
29#define CALLER_ADDR2 (0) 30#define CALLER_ADDR2 (0)
30#define CALLER_ADDR3 (0) 31#define CALLER_ADDR3 (0)
31#endif 32#endif /* CONFIG_FRAME_POINTER */
33#endif /* __ASSEMBLY__ */
34
35#ifdef CONFIG_FUNCTION_TRACER
36
37#define MCOUNT_ADDR ((unsigned long)(_mcount))
38#define MCOUNT_INSN_SIZE 3
39
40#ifndef __ASSEMBLY__
41extern void _mcount(void);
42#define mcount _mcount
43#endif /* __ASSEMBLY__ */
44#endif /* CONFIG_FUNCTION_TRACER */
32 45
33#endif /* _XTENSA_FTRACE_H */ 46#endif /* _XTENSA_FTRACE_H */
diff --git a/arch/xtensa/kernel/Makefile b/arch/xtensa/kernel/Makefile
index 1e7fc87a94bb..f90265ec1ccc 100644
--- a/arch/xtensa/kernel/Makefile
+++ b/arch/xtensa/kernel/Makefile
@@ -11,6 +11,7 @@ obj-y := align.o coprocessor.o entry.o irq.o pci-dma.o platform.o process.o \
11obj-$(CONFIG_KGDB) += xtensa-stub.o 11obj-$(CONFIG_KGDB) += xtensa-stub.o
12obj-$(CONFIG_PCI) += pci.o 12obj-$(CONFIG_PCI) += pci.o
13obj-$(CONFIG_MODULES) += xtensa_ksyms.o module.o 13obj-$(CONFIG_MODULES) += xtensa_ksyms.o module.o
14obj-$(CONFIG_FUNCTION_TRACER) += mcount.o
14 15
15AFLAGS_head.o += -mtext-section-literals 16AFLAGS_head.o += -mtext-section-literals
16 17
diff --git a/arch/xtensa/kernel/mcount.S b/arch/xtensa/kernel/mcount.S
new file mode 100644
index 000000000000..0eeda2e4a25e
--- /dev/null
+++ b/arch/xtensa/kernel/mcount.S
@@ -0,0 +1,50 @@
1/*
2 * arch/xtensa/kernel/mcount.S
3 *
4 * Xtensa specific mcount support
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 *
10 * Copyright (C) 2013 Tensilica Inc.
11 */
12
13#include <linux/linkage.h>
14#include <asm/ftrace.h>
15
16/*
17 * Entry condition:
18 *
19 * a2: a0 of the caller
20 */
21
22ENTRY(_mcount)
23
24 entry a1, 16
25
26 movi a4, ftrace_trace_function
27 l32i a4, a4, 0
28 movi a3, ftrace_stub
29 bne a3, a4, 1f
30 retw
31
321: xor a7, a2, a1
33 movi a3, 0x3fffffff
34 and a7, a7, a3
35 xor a7, a7, a1
36
37 xor a6, a0, a1
38 and a6, a6, a3
39 xor a6, a6, a1
40 addi a6, a6, -MCOUNT_INSN_SIZE
41 callx4 a4
42
43 retw
44
45ENDPROC(_mcount)
46
47ENTRY(ftrace_stub)
48 entry a1, 16
49 retw
50ENDPROC(ftrace_stub)
diff --git a/arch/xtensa/kernel/xtensa_ksyms.c b/arch/xtensa/kernel/xtensa_ksyms.c
index 42c53c87c204..d8507f812f46 100644
--- a/arch/xtensa/kernel/xtensa_ksyms.c
+++ b/arch/xtensa/kernel/xtensa_ksyms.c
@@ -124,3 +124,7 @@ extern long common_exception_return;
124extern long _spill_registers; 124extern long _spill_registers;
125EXPORT_SYMBOL(common_exception_return); 125EXPORT_SYMBOL(common_exception_return);
126EXPORT_SYMBOL(_spill_registers); 126EXPORT_SYMBOL(_spill_registers);
127
128#ifdef CONFIG_FUNCTION_TRACER
129EXPORT_SYMBOL(_mcount);
130#endif