sys_indirect RFC - add call_syscall helper to the x86 archs
PATCH 2/6 sys_indirect RFC - add call_syscall helper to the x86 archs
This patch introduces a new call_syscall() helper for the x86 family archs, to be used by sys_indirect().
Signed-off-by Davide Libenzi <[email protected]>
- Davide
--- arch/i386/kernel/entry.S | 18 ++++++++++++++++++ arch/x86_64/kernel/entry.S | 18 ++++++++++++++++++ include/asm-i386/unistd.h | 16 ++++++++++++++++ include/asm-x86_64/unistd.h | 15 +++++++++++++++ 4 files changed, 67 insertions(+)
include/asm-x86_64/unistd.h +15 -0
@@ -669,6 +669,21 @@const struct sigaction __user *act, struct sigaction __user *oact, size_t sigsetsize); +extern long call_syscall (unsigned int nr,const unsigned long *params); + +static inline int indirect_call_ok (unsigned int nr) +{ +switch (nr) { +case __NR_clone: +case __NR_fork: +case __NR_vfork: +case __NR_rt_sigsuspend: +case __NR_sigaltstack: +case __NR_iopl: +return 0 ; + } +return 1 ; +}#endif /* __ASSEMBLY__ */ #endif /* __KERNEL__ */
arch/i386/kernel/entry.S +18 -0
@@ -1023,6 +1023,24 @@ CFI_ENDPROC ENDPROC(kernel_thread_helper) +ENTRY(call_syscall) + movl $-ENOSYS, %eax + movl 4(%esp), %edx + cmpl $(nr_syscalls), %edx + jae bad_sysc + movl 8(%esp), %eax + pushl 20(%eax) + pushl 16(%eax) + pushl 12(%eax) + pushl 8(%eax) + pushl 4(%eax) + pushl (%eax) + call *sys_call_table(,%edx,4) + addl $24, %esp +bad_sysc: + ret +ENDPROC(call_syscall) + .section .rodata,"a" #include "syscall_table.S"
include/asm-i386/unistd.h +16 -0
@@ -368,5 +368,21 @@#define cond_syscall (x) asm(".weak\t" #x "\n\t.set\t" #x ",sys_ni_syscall")#endif +extern long call_syscall (unsigned int nr,const unsigned long *params); + +static inline int indirect_call_ok (unsigned int nr) +{ +switch (nr) { +case __NR_clone: +case __NR_fork: +case __NR_vfork: +case __NR_rt_sigsuspend: +case __NR_sigaltstack: +case __NR_iopl: +return 0 ; + } +return 1 ; +} +#endif /* __KERNEL__ */ #endif /* _ASM_I386_UNISTD_H_ */
arch/x86_64/kernel/entry.S +18 -0
@@ -1170,3 +1170,21 @@ sysret CFI_ENDPROC ENDPROC(ignore_sysret) + +ENTRY(call_syscall) + movq $-ENOSYS, %rax + cmpl $__NR_syscall_max, %edi + ja bad_sysc + mov %edi, %eax + movq %rsi, %r11 + movq (%r11), %rdi + movq 8(%r11), %rsi + movq 16(%r11), %rdx + movq 24(%r11), %rcx + movq 32(%r11), %r8 + movq 40(%r11), %r9 + call *sys_call_table(,%rax,8) +bad_sysc: + ret +ENDPROC(call_syscall) +