Kernel: Clear DF on every interrupt handler

I was missing this and it lead to UB with my new mem* functions that
were implemented with `rep`
This commit is contained in:
Bananymous 2025-01-17 16:11:13 +02:00
parent 03b5c8e76e
commit 34775633b2
4 changed files with 12 additions and 1 deletions

View File

@ -14,6 +14,7 @@ asm_syscall_handler:
pushl %edi pushl %edi
pushl %esi pushl %esi
pushl %ebp pushl %ebp
cld
# align stack # align stack
movl %esp, %ebp movl %esp, %ebp

View File

@ -27,6 +27,7 @@
isr_stub: isr_stub:
push_userspace push_userspace
load_kernel_segments load_kernel_segments
cld
movl %cr0, %eax; pushl %eax movl %cr0, %eax; pushl %eax
movl %cr2, %eax; pushl %eax movl %cr2, %eax; pushl %eax
@ -58,6 +59,7 @@ isr_stub:
irq_stub: irq_stub:
push_userspace push_userspace
load_kernel_segments load_kernel_segments
cld
movl 40(%esp), %eax # interrupt number movl 40(%esp), %eax # interrupt number
@ -79,6 +81,7 @@ irq_stub:
asm_yield_handler: asm_yield_handler:
# This can only be called from kernel, so no segment saving is needed # This can only be called from kernel, so no segment saving is needed
pushal pushal
cld
movl %esp, %eax # interrupt registers ptr movl %esp, %eax # interrupt registers ptr
leal 32(%esp), %ebx # interrupt stack ptr leal 32(%esp), %ebx # interrupt stack ptr
@ -101,6 +104,7 @@ asm_yield_handler:
asm_ipi_handler: asm_ipi_handler:
push_userspace push_userspace
load_kernel_segments load_kernel_segments
cld
movl %esp, %ebp movl %esp, %ebp
subl $15, %esp subl $15, %esp
@ -118,6 +122,7 @@ asm_ipi_handler:
asm_timer_handler: asm_timer_handler:
push_userspace push_userspace
load_kernel_segments load_kernel_segments
cld
movl %esp, %ebp movl %esp, %ebp
subl $15, %esp subl $15, %esp

View File

@ -16,6 +16,7 @@ asm_syscall_handler:
pushq %r13 pushq %r13
pushq %r14 pushq %r14
pushq %r15 pushq %r15
cld
movq %rsi, %r8 movq %rsi, %r8
movq %rdi, %r9 movq %rdi, %r9

View File

@ -36,7 +36,7 @@
isr_stub: isr_stub:
pushaq pushaq
cld
movq %cr0, %rax; pushq %rax movq %cr0, %rax; pushq %rax
movq %cr2, %rax; pushq %rax movq %cr2, %rax; pushq %rax
movq %cr3, %rax; pushq %rax movq %cr3, %rax; pushq %rax
@ -55,6 +55,7 @@ isr_stub:
irq_stub: irq_stub:
pushaq pushaq
cld
movq 120(%rsp), %rdi # irq number movq 120(%rsp), %rdi # irq number
call cpp_irq_handler call cpp_irq_handler
popaq popaq
@ -64,6 +65,7 @@ irq_stub:
.global asm_yield_handler .global asm_yield_handler
asm_yield_handler: asm_yield_handler:
pushaq pushaq
cld
leaq 120(%rsp), %rdi # interrupt stack ptr leaq 120(%rsp), %rdi # interrupt stack ptr
movq %rsp, %rsi # interrupt register ptr movq %rsp, %rsi # interrupt register ptr
call cpp_yield_handler call cpp_yield_handler
@ -73,6 +75,7 @@ asm_yield_handler:
.global asm_ipi_handler .global asm_ipi_handler
asm_ipi_handler: asm_ipi_handler:
pushaq pushaq
cld
call cpp_ipi_handler call cpp_ipi_handler
popaq popaq
iretq iretq
@ -80,6 +83,7 @@ asm_ipi_handler:
.global asm_timer_handler .global asm_timer_handler
asm_timer_handler: asm_timer_handler:
pushaq pushaq
cld
call cpp_timer_handler call cpp_timer_handler
popaq popaq
iretq iretq