Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions common/usermode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
16 changes: 13 additions & 3 deletions include/arch/x86/asm-macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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__)
Expand Down