From 568c5a047c9c3b9df89b14d3b940d4a038083ab7 Mon Sep 17 00:00:00 2001 From: Johannes Wikner Date: Thu, 3 Aug 2023 15:29:46 +0200 Subject: [PATCH] usermode: syscall_handler clobbers rbp syscall handlers like mmap are use rbp without saving it. Save original rbp before handling syscall. Signed-off-by: kwikner --- include/arch/x86/asm-macros.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/arch/x86/asm-macros.h b/include/arch/x86/asm-macros.h index e04d0007..c2268848 100644 --- a/include/arch/x86/asm-macros.h +++ b/include/arch/x86/asm-macros.h @@ -286,18 +286,20 @@ name ## _end: "push %%" STR(_ASM_DX) "\n" \ "push %%" STR(_ASM_SI) "\n" \ "push %%" STR(_ASM_DI) "\n" \ + "push %%" STR(_ASM_BP) "\n" \ ::: "memory"); \ SAVE_CLOBBERED_REGS64() #define RESTORE_CLOBBERED_REGS() \ RESTORE_CLOBBERED_REGS64(); \ asm volatile ( \ + "pop %%" STR(_ASM_BP) "\n" \ "pop %%" STR(_ASM_DI) "\n" \ "pop %%" STR(_ASM_SI) "\n" \ "pop %%" STR(_ASM_DX) "\n" \ "pop %%" STR(_ASM_CX) "\n" \ - ::: STR(_ASM_DI), STR(_ASM_SI), \ - STR(_ASM_DX), STR(_ASM_CX)) + ::: STR(_ASM_BP), STR(_ASM_DI), \ + STR(_ASM_SI), STR(_ASM_DX), STR(_ASM_CX)) /* clang-format on */ #if defined(__x86_64__)