From e59baa76381b2eca4731c9de0cdd35c46d938846 Mon Sep 17 00:00:00 2001 From: kwikner Date: Thu, 3 Aug 2023 20:19:09 +0200 Subject: [PATCH] usermode: clobber all x64 registers. This bug possibly surfaced after adding some additional code to the syscall handler. Signed-off-by: kwikner --- include/arch/x86/asm-macros.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/arch/x86/asm-macros.h b/include/arch/x86/asm-macros.h index c2268848..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()