Skip to content

Commit 0aec21c

Browse files
author
Peter Zijlstra
committed
x86/ibt,ftrace: Add ENDBR to samples/ftrace
Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5891271 commit 0aec21c

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

samples/ftrace/ftrace-direct-modify.c

+5
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@ static unsigned long my_ip = (unsigned long)schedule;
2424

2525
#ifdef CONFIG_X86_64
2626

27+
#include <asm/ibt.h>
28+
2729
asm (
2830
" .pushsection .text, \"ax\", @progbits\n"
2931
" .type my_tramp1, @function\n"
3032
" .globl my_tramp1\n"
3133
" my_tramp1:"
34+
ASM_ENDBR
3235
" pushq %rbp\n"
3336
" movq %rsp, %rbp\n"
3437
" call my_direct_func1\n"
3538
" leave\n"
3639
" .size my_tramp1, .-my_tramp1\n"
3740
ASM_RET
41+
3842
" .type my_tramp2, @function\n"
3943
" .globl my_tramp2\n"
4044
" my_tramp2:"
45+
ASM_ENDBR
4146
" pushq %rbp\n"
4247
" movq %rsp, %rbp\n"
4348
" call my_direct_func2\n"

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

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,36 @@ extern void my_tramp2(void *);
2222

2323
#ifdef CONFIG_X86_64
2424

25+
#include <asm/ibt.h>
26+
2527
asm (
2628
" .pushsection .text, \"ax\", @progbits\n"
2729
" .type my_tramp1, @function\n"
2830
" .globl my_tramp1\n"
2931
" my_tramp1:"
32+
ASM_ENDBR
3033
" pushq %rbp\n"
3134
" movq %rsp, %rbp\n"
3235
" pushq %rdi\n"
3336
" movq 8(%rbp), %rdi\n"
3437
" call my_direct_func1\n"
3538
" popq %rdi\n"
3639
" leave\n"
37-
" ret\n"
40+
ASM_RET
3841
" .size my_tramp1, .-my_tramp1\n"
42+
3943
" .type my_tramp2, @function\n"
40-
"\n"
4144
" .globl my_tramp2\n"
4245
" my_tramp2:"
46+
ASM_ENDBR
4347
" pushq %rbp\n"
4448
" movq %rsp, %rbp\n"
4549
" pushq %rdi\n"
4650
" movq 8(%rbp), %rdi\n"
4751
" call my_direct_func2\n"
4852
" popq %rdi\n"
4953
" leave\n"
50-
" ret\n"
54+
ASM_RET
5155
" .size my_tramp2, .-my_tramp2\n"
5256
" .popsection\n"
5357
);

samples/ftrace/ftrace-direct-multi.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@ extern void my_tramp(void *);
1717

1818
#ifdef CONFIG_X86_64
1919

20+
#include <asm/ibt.h>
21+
2022
asm (
2123
" .pushsection .text, \"ax\", @progbits\n"
2224
" .type my_tramp, @function\n"
2325
" .globl my_tramp\n"
2426
" my_tramp:"
27+
ASM_ENDBR
2528
" pushq %rbp\n"
2629
" movq %rsp, %rbp\n"
2730
" pushq %rdi\n"
2831
" movq 8(%rbp), %rdi\n"
2932
" call my_direct_func\n"
3033
" popq %rdi\n"
3134
" leave\n"
32-
" ret\n"
35+
ASM_RET
3336
" .size my_tramp, .-my_tramp\n"
3437
" .popsection\n"
3538
);

samples/ftrace/ftrace-direct-too.c

+3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@ extern void my_tramp(void *);
1919

2020
#ifdef CONFIG_X86_64
2121

22+
#include <asm/ibt.h>
23+
2224
asm (
2325
" .pushsection .text, \"ax\", @progbits\n"
2426
" .type my_tramp, @function\n"
2527
" .globl my_tramp\n"
2628
" my_tramp:"
29+
ASM_ENDBR
2730
" pushq %rbp\n"
2831
" movq %rsp, %rbp\n"
2932
" pushq %rdi\n"

samples/ftrace/ftrace-direct.c

+3
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ extern void my_tramp(void *);
1616

1717
#ifdef CONFIG_X86_64
1818

19+
#include <asm/ibt.h>
20+
1921
asm (
2022
" .pushsection .text, \"ax\", @progbits\n"
2123
" .type my_tramp, @function\n"
2224
" .globl my_tramp\n"
2325
" my_tramp:"
26+
ASM_ENDBR
2427
" pushq %rbp\n"
2528
" movq %rsp, %rbp\n"
2629
" pushq %rdi\n"

0 commit comments

Comments
 (0)