Skip to content

Commit

Permalink
x86/ibt,ftrace: Add ENDBR to samples/ftrace
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154318.523421433@infradead.org
  • Loading branch information
Peter Zijlstra committed Mar 15, 2022
1 parent 5891271 commit 0aec21c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions samples/ftrace/ftrace-direct-modify.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,25 @@ static unsigned long my_ip = (unsigned long)schedule;

#ifdef CONFIG_X86_64

#include <asm/ibt.h>

asm (
" .pushsection .text, \"ax\", @progbits\n"
" .type my_tramp1, @function\n"
" .globl my_tramp1\n"
" my_tramp1:"
ASM_ENDBR
" pushq %rbp\n"
" movq %rsp, %rbp\n"
" call my_direct_func1\n"
" leave\n"
" .size my_tramp1, .-my_tramp1\n"
ASM_RET

" .type my_tramp2, @function\n"
" .globl my_tramp2\n"
" my_tramp2:"
ASM_ENDBR
" pushq %rbp\n"
" movq %rsp, %rbp\n"
" call my_direct_func2\n"
Expand Down
10 changes: 7 additions & 3 deletions samples/ftrace/ftrace-direct-multi-modify.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,36 @@ extern void my_tramp2(void *);

#ifdef CONFIG_X86_64

#include <asm/ibt.h>

asm (
" .pushsection .text, \"ax\", @progbits\n"
" .type my_tramp1, @function\n"
" .globl my_tramp1\n"
" my_tramp1:"
ASM_ENDBR
" pushq %rbp\n"
" movq %rsp, %rbp\n"
" pushq %rdi\n"
" movq 8(%rbp), %rdi\n"
" call my_direct_func1\n"
" popq %rdi\n"
" leave\n"
" ret\n"
ASM_RET
" .size my_tramp1, .-my_tramp1\n"

" .type my_tramp2, @function\n"
"\n"
" .globl my_tramp2\n"
" my_tramp2:"
ASM_ENDBR
" pushq %rbp\n"
" movq %rsp, %rbp\n"
" pushq %rdi\n"
" movq 8(%rbp), %rdi\n"
" call my_direct_func2\n"
" popq %rdi\n"
" leave\n"
" ret\n"
ASM_RET
" .size my_tramp2, .-my_tramp2\n"
" .popsection\n"
);
Expand Down
5 changes: 4 additions & 1 deletion samples/ftrace/ftrace-direct-multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,22 @@ extern void my_tramp(void *);

#ifdef CONFIG_X86_64

#include <asm/ibt.h>

asm (
" .pushsection .text, \"ax\", @progbits\n"
" .type my_tramp, @function\n"
" .globl my_tramp\n"
" my_tramp:"
ASM_ENDBR
" pushq %rbp\n"
" movq %rsp, %rbp\n"
" pushq %rdi\n"
" movq 8(%rbp), %rdi\n"
" call my_direct_func\n"
" popq %rdi\n"
" leave\n"
" ret\n"
ASM_RET
" .size my_tramp, .-my_tramp\n"
" .popsection\n"
);
Expand Down
3 changes: 3 additions & 0 deletions samples/ftrace/ftrace-direct-too.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ extern void my_tramp(void *);

#ifdef CONFIG_X86_64

#include <asm/ibt.h>

asm (
" .pushsection .text, \"ax\", @progbits\n"
" .type my_tramp, @function\n"
" .globl my_tramp\n"
" my_tramp:"
ASM_ENDBR
" pushq %rbp\n"
" movq %rsp, %rbp\n"
" pushq %rdi\n"
Expand Down
3 changes: 3 additions & 0 deletions samples/ftrace/ftrace-direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ extern void my_tramp(void *);

#ifdef CONFIG_X86_64

#include <asm/ibt.h>

asm (
" .pushsection .text, \"ax\", @progbits\n"
" .type my_tramp, @function\n"
" .globl my_tramp\n"
" my_tramp:"
ASM_ENDBR
" pushq %rbp\n"
" movq %rsp, %rbp\n"
" pushq %rdi\n"
Expand Down

0 comments on commit 0aec21c

Please sign in to comment.