Skip to content

Commit 01678fb

Browse files
Song Shuairostedt
authored andcommitted
samples: ftrace: Include the nospec-branch.h only for x86
When other architectures without the nospec functionality write their direct-call functions of samples/ftrace/*.c, the including of asm/nospec-branch.h must be taken care to fix the no header file found error in building process. This commit (ee3e246 "x86/ftrace: Make it call depth tracking aware") file-globally includes asm/nospec-branch.h providing CALL_DEPTH_ACCOUNT for only x86 direct-call functions. It seems better to move the including to `#ifdef CONFIG_X86_64`. Link: https://lore.kernel.org/linux-trace-kernel/[email protected] Signed-off-by: Song Shuai <[email protected]> Reviewed-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent a9c4bdd commit 01678fb

File tree

5 files changed

+5
-5
lines changed

5 files changed

+5
-5
lines changed

samples/ftrace/ftrace-direct-modify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <linux/kthread.h>
44
#include <linux/ftrace.h>
55
#include <asm/asm-offsets.h>
6-
#include <asm/nospec-branch.h>
76

87
extern void my_direct_func1(void);
98
extern void my_direct_func2(void);
@@ -26,6 +25,7 @@ static unsigned long my_ip = (unsigned long)schedule;
2625
#ifdef CONFIG_X86_64
2726

2827
#include <asm/ibt.h>
28+
#include <asm/nospec-branch.h>
2929

3030
asm (
3131
" .pushsection .text, \"ax\", @progbits\n"

samples/ftrace/ftrace-direct-multi-modify.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include <linux/kthread.h>
44
#include <linux/ftrace.h>
55
#include <asm/asm-offsets.h>
6-
#include <asm/nospec-branch.h>
76

87
extern void my_direct_func1(unsigned long ip);
98
extern void my_direct_func2(unsigned long ip);
@@ -24,6 +23,7 @@ extern void my_tramp2(void *);
2423
#ifdef CONFIG_X86_64
2524

2625
#include <asm/ibt.h>
26+
#include <asm/nospec-branch.h>
2727

2828
asm (
2929
" .pushsection .text, \"ax\", @progbits\n"

samples/ftrace/ftrace-direct-multi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include <linux/ftrace.h>
66
#include <linux/sched/stat.h>
77
#include <asm/asm-offsets.h>
8-
#include <asm/nospec-branch.h>
98

109
extern void my_direct_func(unsigned long ip);
1110

@@ -19,6 +18,7 @@ extern void my_tramp(void *);
1918
#ifdef CONFIG_X86_64
2019

2120
#include <asm/ibt.h>
21+
#include <asm/nospec-branch.h>
2222

2323
asm (
2424
" .pushsection .text, \"ax\", @progbits\n"

samples/ftrace/ftrace-direct-too.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <linux/mm.h> /* for handle_mm_fault() */
55
#include <linux/ftrace.h>
66
#include <asm/asm-offsets.h>
7-
#include <asm/nospec-branch.h>
87

98
extern void my_direct_func(struct vm_area_struct *vma,
109
unsigned long address, unsigned int flags);
@@ -21,6 +20,7 @@ extern void my_tramp(void *);
2120
#ifdef CONFIG_X86_64
2221

2322
#include <asm/ibt.h>
23+
#include <asm/nospec-branch.h>
2424

2525
asm (
2626
" .pushsection .text, \"ax\", @progbits\n"

samples/ftrace/ftrace-direct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include <linux/sched.h> /* for wake_up_process() */
55
#include <linux/ftrace.h>
66
#include <asm/asm-offsets.h>
7-
#include <asm/nospec-branch.h>
87

98
extern void my_direct_func(struct task_struct *p);
109

@@ -18,6 +17,7 @@ extern void my_tramp(void *);
1817
#ifdef CONFIG_X86_64
1918

2019
#include <asm/ibt.h>
20+
#include <asm/nospec-branch.h>
2121

2222
asm (
2323
" .pushsection .text, \"ax\", @progbits\n"

0 commit comments

Comments
 (0)