diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-09 22:40:35 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-09 22:42:19 +0100 |
commit | b285a1944e7c3a5256c08eb3b484227574c35b80 (patch) | |
tree | 3446587e5469fc61739313181483f24b2bf21abd /Kernel | |
parent | fbeb1ab15b8e1730a42eb43b4b211d17fe2bbb01 (diff) | |
download | serenity-b285a1944e7c3a5256c08eb3b484227574c35b80.zip |
Kernel: Clear the x86 DF flag when entering the kernel
The SysV ABI says that the DF flag should be clear on function entry.
That means we have to clear it when jumping into the kernel from some
random userspace context.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Arch/i386/CPU.cpp | 59 | ||||
-rw-r--r-- | Kernel/Arch/i386/PIT.cpp | 1 | ||||
-rw-r--r-- | Kernel/Syscall.cpp | 1 |
3 files changed, 33 insertions, 28 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp index 738dcf35b3..1bbdb0bd50 100644 --- a/Kernel/Arch/i386/CPU.cpp +++ b/Kernel/Arch/i386/CPU.cpp @@ -55,6 +55,7 @@ asm( " pushw %ss\n" " popw %ds\n" " popw %es\n" + " cld\n" " call handle_irq\n" " popw %es\n" " popw %ds\n" @@ -82,6 +83,7 @@ asm( " popw %es\n" \ " popw %fs\n" \ " popw %gs\n" \ + " cld\n" \ " call exception_" #ec "_handler\n" \ " popw %gs\n" \ " popw %gs\n" \ @@ -92,35 +94,36 @@ asm( " add $0x4, %esp\n" \ " iret\n"); -#define EH_ENTRY_NO_CODE(ec) \ +#define EH_ENTRY_NO_CODE(ec) \ extern "C" void exception_##ec##_handler(RegisterDump); \ - extern "C" void exception_##ec##_entry(); \ - asm( \ - ".globl exception_" #ec "_entry\n" \ - "exception_" #ec "_entry: \n" \ - " pushl $0x0\n" \ - " pusha\n" \ - " pushw %ds\n" \ - " pushw %es\n" \ - " pushw %fs\n" \ - " pushw %gs\n" \ - " pushw %ss\n" \ - " pushw %ss\n" \ - " pushw %ss\n" \ - " pushw %ss\n" \ - " pushw %ss\n" \ - " popw %ds\n" \ - " popw %es\n" \ - " popw %fs\n" \ - " popw %gs\n" \ - " call exception_" #ec "_handler\n" \ - " popw %gs\n" \ - " popw %gs\n" \ - " popw %fs\n" \ - " popw %es\n" \ - " popw %ds\n" \ - " popa\n" \ - " add $0x4, %esp\n" \ + extern "C" void exception_##ec##_entry(); \ + asm( \ + ".globl exception_" #ec "_entry\n" \ + "exception_" #ec "_entry: \n" \ + " pushl $0x0\n" \ + " pusha\n" \ + " pushw %ds\n" \ + " pushw %es\n" \ + " pushw %fs\n" \ + " pushw %gs\n" \ + " pushw %ss\n" \ + " pushw %ss\n" \ + " pushw %ss\n" \ + " pushw %ss\n" \ + " pushw %ss\n" \ + " popw %ds\n" \ + " popw %es\n" \ + " popw %fs\n" \ + " popw %gs\n" \ + " cld\n" \ + " call exception_" #ec "_handler\n" \ + " popw %gs\n" \ + " popw %gs\n" \ + " popw %fs\n" \ + " popw %es\n" \ + " popw %ds\n" \ + " popa\n" \ + " add $0x4, %esp\n" \ " iret\n"); static void dump(const RegisterDump& regs) diff --git a/Kernel/Arch/i386/PIT.cpp b/Kernel/Arch/i386/PIT.cpp index b4861c3066..0a64e6d34f 100644 --- a/Kernel/Arch/i386/PIT.cpp +++ b/Kernel/Arch/i386/PIT.cpp @@ -27,6 +27,7 @@ asm( " popw %es\n" " popw %fs\n" " popw %gs\n" + " cld\n" " call timer_interrupt_handler\n" " popw %gs\n" " popw %gs\n" diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 378a3e3e0b..9cc6cd365d 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -24,6 +24,7 @@ asm( " popw %es\n" " popw %fs\n" " popw %gs\n" + " cld\n" " call syscall_trap_entry\n" " popw %gs\n" " popw %gs\n" |