From 834789d006d5fa6a7448cfd49ac03bba7da0c527 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Mon, 20 May 2013 20:16:34 +0200 Subject: [PATCH] Chain kernel frame pointer list with user-space. --- sortix/x64/syscall.s | 6 ++++-- sortix/x86/syscall.s | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sortix/x64/syscall.s b/sortix/x64/syscall.s index 392683e5..0e574543 100644 --- a/sortix/x64/syscall.s +++ b/sortix/x64/syscall.s @@ -33,7 +33,9 @@ syscall_handler: sti movl $0, global_errno # Reset errno + pushq %rbp + movq %rsp, %rbp # Make sure the requested system call is valid, if not, then fix it. cmp SYSCALL_MAX, %rax @@ -41,8 +43,8 @@ syscall_handler: valid_syscall: # Read a system call function pointer. - xorq %rbp, %rbp - movq syscall_list(%rbp,%rax,8), %rax + xorq %r11, %r11 + movq syscall_list(%r11,%rax,8), %rax # Oh how nice, user-space put the parameters in: rdi, rsi, rdx, rcx, r8, r9 diff --git a/sortix/x86/syscall.s b/sortix/x86/syscall.s index db6b9344..346a5cb7 100644 --- a/sortix/x86/syscall.s +++ b/sortix/x86/syscall.s @@ -33,6 +33,7 @@ syscall_handler: sti movl $0, global_errno # Reset errno + pushl %ebp # Grant ourselves kernel permissions to the data segment. @@ -53,6 +54,10 @@ valid_syscall: xorl %ebp, %ebp movl syscall_list(%ebp,%eax,4), %eax + # Point the %ebp register to the pushed user-space %ebp above. + movl %esp, %ebp + addl $4, %ebp + # Call the system call. pushl %esi pushl %edi