Kernel: Make sure stack is aligned on interrupts for i686 target
I just realized that only x86_64 aligns stack pointer when interrupt is triggered.
This commit is contained in:
parent
8fe798de6d
commit
1ee37cb671
|
@ -15,8 +15,14 @@ asm_syscall_handler:
|
||||||
pushl %esi
|
pushl %esi
|
||||||
pushl %ebp
|
pushl %ebp
|
||||||
|
|
||||||
# align stack and push arguments
|
# align stack
|
||||||
pushl %esp
|
movl %esp, %ebp
|
||||||
|
subl $15, %esp
|
||||||
|
andl $0xFFFFFFF0, %esp
|
||||||
|
|
||||||
|
# push arguments
|
||||||
|
subl $4, %esp
|
||||||
|
pushl %ebp
|
||||||
addl $32, (%esp)
|
addl $32, (%esp)
|
||||||
pushl %edi
|
pushl %edi
|
||||||
pushl %esi
|
pushl %esi
|
||||||
|
@ -34,7 +40,8 @@ asm_syscall_handler:
|
||||||
movw %ax, %gs
|
movw %ax, %gs
|
||||||
|
|
||||||
call cpp_syscall_handler
|
call cpp_syscall_handler
|
||||||
addl $28, %esp
|
|
||||||
|
movl %ebp, %esp
|
||||||
|
|
||||||
# restore general purpose registers
|
# restore general purpose registers
|
||||||
popl %ebp
|
popl %ebp
|
||||||
|
|
|
@ -38,13 +38,18 @@ isr_stub:
|
||||||
movl 60(%esp), %ecx // error code
|
movl 60(%esp), %ecx // error code
|
||||||
movl 56(%esp), %edx // isr number
|
movl 56(%esp), %edx // isr number
|
||||||
|
|
||||||
subl $12, %esp
|
movl %esp, %ebp
|
||||||
|
subl $15, %esp
|
||||||
|
andl $0xFFFFFFF0, %esp
|
||||||
|
|
||||||
pushl %eax
|
pushl %eax
|
||||||
pushl %ebx
|
pushl %ebx
|
||||||
pushl %ecx
|
pushl %ecx
|
||||||
pushl %edx
|
pushl %edx
|
||||||
call cpp_isr_handler
|
call cpp_isr_handler
|
||||||
addl $44, %esp
|
|
||||||
|
movl %ebp, %esp
|
||||||
|
addl $16, %esp
|
||||||
|
|
||||||
pop_userspace
|
pop_userspace
|
||||||
addl $8, %esp
|
addl $8, %esp
|
||||||
|
@ -56,10 +61,15 @@ irq_stub:
|
||||||
|
|
||||||
movl 40(%esp), %eax # interrupt number
|
movl 40(%esp), %eax # interrupt number
|
||||||
|
|
||||||
|
movl %esp, %ebp
|
||||||
|
subl $15, %esp
|
||||||
|
andl $0xFFFFFFF0, %esp
|
||||||
|
|
||||||
subl $12, %esp
|
subl $12, %esp
|
||||||
pushl %eax
|
pushl %eax
|
||||||
call cpp_irq_handler
|
call cpp_irq_handler
|
||||||
addl $16, %esp
|
|
||||||
|
movl %ebp, %esp
|
||||||
|
|
||||||
pop_userspace
|
pop_userspace
|
||||||
addl $8, %esp
|
addl $8, %esp
|
||||||
|
@ -73,11 +83,16 @@ asm_yield_handler:
|
||||||
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
|
||||||
|
|
||||||
subl $4, %esp
|
movl %esp, %ebp
|
||||||
|
subl $15, %esp
|
||||||
|
andl $0xFFFFFFF0, %esp
|
||||||
|
|
||||||
|
subl $8, %esp
|
||||||
pushl %eax
|
pushl %eax
|
||||||
pushl %ebx
|
pushl %ebx
|
||||||
call cpp_yield_handler
|
call cpp_yield_handler
|
||||||
addl $12, %esp
|
|
||||||
|
movl %ebp, %esp
|
||||||
|
|
||||||
popal
|
popal
|
||||||
iret
|
iret
|
||||||
|
|
Loading…
Reference in New Issue