Module: xenomai-forge Branch: next Commit: 53b3ee3592f0e2016c62be3c5c09f39aeced0e1d URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=53b3ee3592f0e2016c62be3c5c09f39aeced0e1d
Author: Philippe Gerum <r...@xenomai.org> Date: Mon Sep 1 15:00:12 2014 +0200 cobalt/syscall: use task_pt_regs() when applicable --- include/cobalt/kernel/thread.h | 1 - kernel/cobalt/posix/process.c | 2 -- kernel/cobalt/posix/syscall.c | 47 ++++++++++++++++++---------------------- 3 files changed, 21 insertions(+), 29 deletions(-) diff --git a/include/cobalt/kernel/thread.h b/include/cobalt/kernel/thread.h index 056fe51..204c525 100644 --- a/include/cobalt/kernel/thread.h +++ b/include/cobalt/kernel/thread.h @@ -186,7 +186,6 @@ struct xnthread { void (*entry)(void *cookie); /* Thread entry routine */ void *cookie; /* Cookie to pass to the entry routine */ - struct pt_regs *regs; /* Current register frame */ struct xnthread_user_window *u_window; /* Data visible from userland. */ struct xnthread_personality *personality; diff --git a/kernel/cobalt/posix/process.c b/kernel/cobalt/posix/process.c index c71d1ce..1714523 100644 --- a/kernel/cobalt/posix/process.c +++ b/kernel/cobalt/posix/process.c @@ -743,8 +743,6 @@ static inline int handle_exception(struct ipipe_trap_data *d) * running in primary mode, move it to the Linux domain, * leaving the kernel process the exception. */ - thread->regs = xnarch_fault_regs(d); - #if XENO_DEBUG(COBALT) || XENO_DEBUG(USER) if (!user_mode(d->regs)) { xntrace_panic_freeze(); diff --git a/kernel/cobalt/posix/syscall.c b/kernel/cobalt/posix/syscall.c index 0f09e5d..becb773 100644 --- a/kernel/cobalt/posix/syscall.c +++ b/kernel/cobalt/posix/syscall.c @@ -113,13 +113,10 @@ static int handle_head_syscall(struct ipipe_domain *ipd, struct pt_regs *regs) unsigned long sysflags; struct task_struct *p; - thread = xnthread_current(); - if (thread) - thread->regs = regs; - if (!__xn_syscall_p(regs)) goto linux_syscall; + thread = xnthread_current(); nr = __xn_syscall(regs); trace_cobalt_head_sysentry(thread, nr); @@ -301,14 +298,11 @@ static int handle_root_syscall(struct ipipe_domain *ipd, struct pt_regs *regs) */ xnthread_test_cancel(); - thread = xnthread_current(); - if (thread) - thread->regs = regs; - if (!__xn_syscall_p(regs)) /* Fall back to Linux syscall handling. */ return KEVENT_PROPAGATE; + thread = xnthread_current(); /* nr has already been checked in the head domain handler. */ nr = __xn_syscall(regs); @@ -555,30 +549,31 @@ static int cobalt_serialdbg(const char __user *u_msg, int len) static int cobalt_mayday(void) { + struct pt_regs *regs = task_pt_regs(current); struct xnthread *cur; cur = xnthread_current(); - if (likely(cur)) { - /* - * If the thread was kicked by the watchdog, this - * syscall we have just forced on it via the mayday - * escape will cause it to relax. See - * handle_head_syscall(). - */ - xnarch_fixup_mayday(xnthread_archtcb(cur), cur->regs); - - /* - * Return whatever value xnarch_fixup_mayday set for - * this register, in order not to undo what - * xnarch_fixup_mayday did. - */ - return __xn_reg_rval(cur->regs); + if (cur == NULL) { + printk(XENO_WARN + "MAYDAY received from invalid context %s[%d]\n", + current->comm, current->pid); + return -EPERM; } - printk(XENO_WARN "MAYDAY received from invalid context %s[%d]\n", - current->comm, current->pid); + /* + * If the thread was kicked by the watchdog, this syscall we + * have just forced on it via the mayday escape will cause it + * to relax. See handle_head_syscall(). + */ + xnarch_fixup_mayday(xnthread_archtcb(cur), regs); + + /* + * Return whatever value xnarch_fixup_mayday set for this + * register, in order not to undo what xnarch_fixup_mayday + * did. + */ + return __xn_reg_rval(regs); - return -EPERM; } static void stringify_feature_set(unsigned long fset, char *buf, int size) _______________________________________________ Xenomai-git mailing list Xenomai-git@xenomai.org http://www.xenomai.org/mailman/listinfo/xenomai-git