From f032e67ae32a30e79fa2bd5ae5f5c915a2967cef Mon Sep 17 00:00:00 2001 From: Alexander Kartashov Date: Wed, 9 Jan 2013 17:26:46 +0400 Subject: [PATCH] parasite-syscall.c: moved the routine syscall_seized() into the file arch/x86/crtools.c. Signed-off-by: Alexander Kartashov Signed-off-by: Pavel Emelyanov --- arch/x86/crtools.c | 28 ++++++++++++++++++++++++++++ include/parasite-syscall.h | 2 ++ parasite-syscall.c | 30 +----------------------------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/arch/x86/crtools.c b/arch/x86/crtools.c index 20c55197b..59ea002c2 100644 --- a/arch/x86/crtools.c +++ b/arch/x86/crtools.c @@ -43,3 +43,31 @@ void parasite_setup_regs(unsigned long new_ip, user_regs_struct_t *regs) /* Make sure flags are in known state */ regs->flags &= ~(X86_EFLAGS_TF | X86_EFLAGS_DF | X86_EFLAGS_IF); } + +int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret, + unsigned long arg1, + unsigned long arg2, + unsigned long arg3, + unsigned long arg4, + unsigned long arg5, + unsigned long arg6) +{ + user_regs_struct_t regs = ctl->regs_orig; + int err; + + regs.ax = (unsigned long)nr; + regs.di = arg1; + regs.si = arg2; + regs.dx = arg3; + regs.r10 = arg4; + regs.r8 = arg5; + regs.r9 = arg6; + + parasite_setup_regs(ctl->syscall_ip, ®s); + err = __parasite_execute(ctl, ctl->pid, ®s); + if (err) + return err; + + *ret = regs.ax; + return 0; +} diff --git a/include/parasite-syscall.h b/include/parasite-syscall.h index 6b0d65914..cccd6786d 100644 --- a/include/parasite-syscall.h +++ b/include/parasite-syscall.h @@ -69,4 +69,6 @@ int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret, unsigned long arg5, unsigned long arg6); +extern int __parasite_execute(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs); + #endif /* __CR_PARASITE_SYSCALL_H__ */ diff --git a/parasite-syscall.c b/parasite-syscall.c index e792ad0a5..e77579265 100644 --- a/parasite-syscall.c +++ b/parasite-syscall.c @@ -56,7 +56,7 @@ static struct vma_area *get_vma_by_ip(struct list_head *vma_area_list, unsigned } /* we run at @regs->ip */ -static int __parasite_execute(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs) +int __parasite_execute(struct parasite_ctl *ctl, pid_t pid, user_regs_struct_t *regs) { siginfo_t siginfo; int status; @@ -230,34 +230,6 @@ static int parasite_execute(unsigned int cmd, struct parasite_ctl *ctl) return parasite_execute_by_pid(cmd, ctl, ctl->pid); } -int syscall_seized(struct parasite_ctl *ctl, int nr, unsigned long *ret, - unsigned long arg1, - unsigned long arg2, - unsigned long arg3, - unsigned long arg4, - unsigned long arg5, - unsigned long arg6) -{ - user_regs_struct_t regs = ctl->regs_orig; - int err; - - regs.ax = (unsigned long)nr; - regs.di = arg1; - regs.si = arg2; - regs.dx = arg3; - regs.r10 = arg4; - regs.r8 = arg5; - regs.r9 = arg6; - - parasite_setup_regs(ctl->syscall_ip, ®s); - err = __parasite_execute(ctl, ctl->pid, ®s); - if (err) - return err; - - *ret = regs.ax; - return 0; -} - static void *mmap_seized(struct parasite_ctl *ctl, void *addr, size_t length, int prot, int flags, int fd, off_t offset)