From 35e949ef5ee8a8604b0e89b7ffd1dffff85987d6 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 21 Apr 2023 11:08:02 +0300 Subject: [PATCH] Kernel: Fix syscall return value in 32 bit --- kernel/arch/i386/IDT.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/arch/i386/IDT.cpp b/kernel/arch/i386/IDT.cpp index f75e1ace..e4f2bcc2 100644 --- a/kernel/arch/i386/IDT.cpp +++ b/kernel/arch/i386/IDT.cpp @@ -174,7 +174,18 @@ found: "addl $16, %esp;" "popw %es;" "popw %ds;" - "popa;" + + // NOTE: following instructions are same as in 'popa', except we skip eax + // since it holds the return value of the syscall. + "popl %edi;" + "popl %esi;" + "popl %ebp;" + "addl $4, %esp;" + "popl %ebx;" + "popl %edx;" + "popl %ecx;" + "addl $4, %esp;" + "iret;" );