diff --git a/kernel/arch/i686/Signal.S b/kernel/arch/i686/Signal.S index eec11ad8..07ce9143 100644 --- a/kernel/arch/i686/Signal.S +++ b/kernel/arch/i686/Signal.S @@ -1,7 +1,7 @@ .section .userspace, "ax" // stack contains -// (4 bytes) return address +// (4 bytes) return address (on return stack) // (4 bytes) return stack // (4 bytes) return rflags // (8 bytes) restore sigmask @@ -19,6 +19,10 @@ signal_trampoline: pushl %eax pushl %ebp + movl 80(%esp), %eax + pushl %eax; addl $4, (%esp) + pushl (%eax) + // FIXME: populate these xorl %eax, %eax pushl %eax // stack @@ -29,9 +33,9 @@ signal_trampoline: pushl %eax // link movl %esp, %edx // ucontext - leal 60(%esp), %esi // siginfo - movl 56(%esp), %edi // signal number - movl 52(%esp), %eax // handlers + leal 68(%esp), %esi // siginfo + movl 64(%esp), %edi // signal number + movl 60(%esp), %eax // handlers // align stack to 16 bytes movl %esp, %ebp @@ -62,6 +66,7 @@ signal_trampoline: int $0xF0 // restore registers + addl $8, %esp popl %ebp popl %eax popl %ebx diff --git a/kernel/arch/x86_64/Signal.S b/kernel/arch/x86_64/Signal.S index 1bb4db99..ca9e979a 100644 --- a/kernel/arch/x86_64/Signal.S +++ b/kernel/arch/x86_64/Signal.S @@ -1,7 +1,7 @@ .section .userspace, "ax" // stack contains -// (8 bytes) return address +// (8 bytes) return address (on return stack) // (8 bytes) return stack // (8 bytes) return rflags // (8 bytes) restore sigmask @@ -27,6 +27,10 @@ signal_trampoline: pushq %rax pushq %rbp + movq 208(%rsp), %rax + pushq %rax; addq $(128 + 8), (%rsp) + pushq (%rax) + // FIXME: populate these xorq %rax, %rax pushq %rax // stack @@ -36,9 +40,9 @@ signal_trampoline: pushq %rax // link movq %rsp, %rdx // ucontext - leaq 176(%rsp), %rsi // siginfo - movq 168(%rsp), %rdi // signal number - movq 160(%rsp), %rax // handler + leaq 192(%rsp), %rsi // siginfo + movq 184(%rsp), %rdi // signal number + movq 176(%rsp), %rax // handler // align stack to 16 bytes movq %rsp, %rbp @@ -64,6 +68,7 @@ signal_trampoline: syscall // restore registers + addq $16, %rsp popq %rbp popq %rax popq %rbx