From: Davide Libenzi <davidel@xmailserver.org>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Ulrich Drepper <drepper@gmail.com>, Ingo Molnar <mingo@elte.hu>
Subject: [patch 2/6] sys_indirect RFC - add call_syscall helper to the x86 archs
Date: Fri, 29 Jun 2007 14:48:52 -0700 [thread overview]
Message-ID: <send-serie.davidel@xmailserver.org.28360.1183153735.2> (raw)
This patch introduces a new call_syscall() helper for the x86 family
archs, to be used by sys_indirect().
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
- 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(+)
Index: linux-2.6.mod/include/asm-x86_64/unistd.h
===================================================================
--- linux-2.6.mod.orig/include/asm-x86_64/unistd.h 2007-06-29 12:12:42.000000000 -0700
+++ linux-2.6.mod/include/asm-x86_64/unistd.h 2007-06-29 12:57:59.000000000 -0700
@@ -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__ */
Index: linux-2.6.mod/arch/i386/kernel/entry.S
===================================================================
--- linux-2.6.mod.orig/arch/i386/kernel/entry.S 2007-06-29 12:12:42.000000000 -0700
+++ linux-2.6.mod/arch/i386/kernel/entry.S 2007-06-29 12:12:48.000000000 -0700
@@ -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"
Index: linux-2.6.mod/include/asm-i386/unistd.h
===================================================================
--- linux-2.6.mod.orig/include/asm-i386/unistd.h 2007-06-29 12:12:42.000000000 -0700
+++ linux-2.6.mod/include/asm-i386/unistd.h 2007-06-29 12:57:58.000000000 -0700
@@ -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_ */
Index: linux-2.6.mod/arch/x86_64/kernel/entry.S
===================================================================
--- linux-2.6.mod.orig/arch/x86_64/kernel/entry.S 2007-06-29 12:12:42.000000000 -0700
+++ linux-2.6.mod/arch/x86_64/kernel/entry.S 2007-06-29 12:12:48.000000000 -0700
@@ -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)
+
reply other threads:[~2007-06-29 21:50 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=send-serie.davidel@xmailserver.org.28360.1183153735.2 \
--to=davidel@xmailserver.org \
--cc=akpm@linux-foundation.org \
--cc=drepper@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®