diff --git a/common/usermode.c b/common/usermode.c index ecc254f1..c510688b 100644 --- a/common/usermode.c +++ b/common/usermode.c @@ -49,12 +49,7 @@ static inline void syscall_restore(void) { } static inline long syscall_return(long return_code) { - /* clang-format off */ - asm volatile( - "mov %[ret], %%" STR(_ASM_AX) "\n" - ::[ret] "r"(return_code) - ); - /* clang-format on */ + asm volatile("" ::"a"(return_code)); return return_code; } diff --git a/include/arch/x86/asm-macros.h b/include/arch/x86/asm-macros.h index e04d0007..e1f7f2ef 100644 --- a/include/arch/x86/asm-macros.h +++ b/include/arch/x86/asm-macros.h @@ -266,15 +266,23 @@ name ## _end: "push %%r9\n" \ "push %%r10\n" \ "push %%r11\n" \ + "push %%r12\n" \ + "push %%r13\n" \ + "push %%r14\n" \ + "push %%r15\n" \ ::: "memory") #define RESTORE_CLOBBERED_REGS64() \ asm volatile ( \ + "pop %%" STR(r15) "\n" \ + "pop %%" STR(r14) "\n" \ + "pop %%" STR(r13) "\n" \ + "pop %%" STR(r12) "\n" \ "pop %%" STR(r11) "\n" \ "pop %%" STR(r10) "\n" \ "pop %%" STR(r9) "\n" \ "pop %%" STR(r8) "\n" \ - ::: "r8", "r9", "r10", "r11") + ::: "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15") #else #define SAVE_CLOBBERED_REGS64() #define RESTORE_CLOBBERED_REGS64() @@ -286,18 +294,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__)