summaryrefslogtreecommitdiffstats
path: root/arch/score
diff options
context:
space:
mode:
Diffstat (limited to 'arch/score')
-rw-r--r--arch/score/Kconfig2
-rw-r--r--arch/score/include/asm/processor.h1
-rw-r--r--arch/score/include/asm/syscalls.h1
-rw-r--r--arch/score/include/asm/unistd.h1
-rw-r--r--arch/score/kernel/entry.S12
-rw-r--r--arch/score/kernel/process.c55
-rw-r--r--arch/score/kernel/signal.c7
-rw-r--r--arch/score/kernel/sys_score.c54
8 files changed, 26 insertions, 107 deletions
diff --git a/arch/score/Kconfig b/arch/score/Kconfig
index 4f93a431a45a..a285e78fb9c5 100644
--- a/arch/score/Kconfig
+++ b/arch/score/Kconfig
@@ -13,6 +13,8 @@ config SCORE
select GENERIC_CLOCKEVENTS
select HAVE_MOD_ARCH_SPECIFIC
select MODULES_USE_ELF_REL
+ select GENERIC_KERNEL_THREAD
+ select GENERIC_KERNEL_EXECVE
choice
prompt "System type"
diff --git a/arch/score/include/asm/processor.h b/arch/score/include/asm/processor.h
index ab3aceb54209..d9a922d8711b 100644
--- a/arch/score/include/asm/processor.h
+++ b/arch/score/include/asm/processor.h
@@ -13,7 +13,6 @@ struct task_struct;
*/
extern void (*cpu_wait)(void);
-extern long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
extern unsigned long thread_saved_pc(struct task_struct *tsk);
extern void start_thread(struct pt_regs *regs,
unsigned long pc, unsigned long sp);
diff --git a/arch/score/include/asm/syscalls.h b/arch/score/include/asm/syscalls.h
index 1dd5e0d6b0c3..8d332534342f 100644
--- a/arch/score/include/asm/syscalls.h
+++ b/arch/score/include/asm/syscalls.h
@@ -2,7 +2,6 @@
#define _ASM_SCORE_SYSCALLS_H
asmlinkage long score_clone(struct pt_regs *regs);
-asmlinkage long score_execve(struct pt_regs *regs);
asmlinkage long score_sigaltstack(struct pt_regs *regs);
asmlinkage long score_rt_sigreturn(struct pt_regs *regs);
diff --git a/arch/score/include/asm/unistd.h b/arch/score/include/asm/unistd.h
index a862384e9c16..b006ca435120 100644
--- a/arch/score/include/asm/unistd.h
+++ b/arch/score/include/asm/unistd.h
@@ -4,5 +4,6 @@
#define __ARCH_WANT_SYSCALL_NO_FLAGS
#define __ARCH_WANT_SYSCALL_OFF_T
#define __ARCH_WANT_SYSCALL_DEPRECATED
+#define __ARCH_WANT_SYS_EXECVE
#include <asm-generic/unistd.h>
diff --git a/arch/score/kernel/entry.S b/arch/score/kernel/entry.S
index 83bb96079c43..da9901088bbb 100644
--- a/arch/score/kernel/entry.S
+++ b/arch/score/kernel/entry.S
@@ -278,6 +278,13 @@ need_resched:
nop
#endif
+ENTRY(ret_from_kernel_thread)
+ bl schedule_tail # r4=struct task_struct *prev
+ nop
+ mv r4, r13
+ brl r12
+ j syscall_exit
+
ENTRY(ret_from_fork)
bl schedule_tail # r4=struct task_struct *prev
@@ -480,11 +487,6 @@ illegal_syscall:
sw r9, [r0, PT_R7]
j syscall_return
-ENTRY(sys_execve)
- mv r4, r0
- la r8, score_execve
- br r8
-
ENTRY(sys_clone)
mv r4, r0
la r8, score_clone
diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
index 637970cfd3f4..6f311cf64b99 100644
--- a/arch/score/kernel/process.c
+++ b/arch/score/kernel/process.c
@@ -60,6 +60,7 @@ void __noreturn cpu_idle(void)
}
void ret_from_fork(void);
+void ret_from_kernel_thread(void);
void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp)
{
@@ -86,29 +87,27 @@ void flush_thread(void) {}
* set up the kernel stack and exception frames for a new process
*/
int copy_thread(unsigned long clone_flags, unsigned long usp,
- unsigned long unused,
+ unsigned long arg,
struct task_struct *p, struct pt_regs *regs)
{
struct thread_info *ti = task_thread_info(p);
struct pt_regs *childregs = task_pt_regs(p);
- p->set_child_tid = NULL;
- p->clear_child_tid = NULL;
-
- *childregs = *regs;
- childregs->regs[7] = 0; /* Clear error flag */
- childregs->regs[4] = 0; /* Child gets zero as return value */
- regs->regs[4] = p->pid;
-
- if (childregs->cp0_psr & 0x8) { /* test kernel fork or user fork */
- childregs->regs[0] = usp; /* user fork */
+ p->thread.reg0 = (unsigned long) childregs;
+ if (unlikely(!regs)) {
+ memset(childregs, 0, sizeof(struct pt_regs));
+ p->thread->reg12 = usp;
+ p->thread->reg13 = arg;
+ p->thread.reg3 = (unsigned long) ret_from_kernel_thread;
} else {
- childregs->regs[28] = (unsigned long) ti; /* kernel fork */
- childregs->regs[0] = (unsigned long) childregs;
+ *childregs = *regs;
+ childregs->regs[7] = 0; /* Clear error flag */
+ childregs->regs[4] = 0; /* Child gets zero as return value */
+ childregs->regs[0] = usp; /* user fork */
+ regs->regs[4] = p->pid; /* WTF? */
+ p->thread.reg3 = (unsigned long) ret_from_fork;
}
- p->thread.reg0 = (unsigned long) childregs;
- p->thread.reg3 = (unsigned long) ret_from_fork;
p->thread.cp0_psr = 0;
return 0;
@@ -120,32 +119,6 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *r)
return 1;
}
-static void __noreturn
-kernel_thread_helper(void *unused0, int (*fn)(void *),
- void *arg, void *unused1)
-{
- do_exit(fn(arg));
-}
-
-/*
- * Create a kernel thread.
- */
-long kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
-{
- struct pt_regs regs;
-
- memset(&regs, 0, sizeof(regs));
-
- regs.regs[6] = (unsigned long) arg;
- regs.regs[5] = (unsigned long) fn;
- regs.cp0_epc = (unsigned long) kernel_thread_helper;
- regs.cp0_psr = (regs.cp0_psr & ~(0x1|0x4|0x8)) | \
- ((regs.cp0_psr & 0x3) << 2);
-
- return do_fork(flags | CLONE_VM | CLONE_UNTRACED, \
- 0, &regs, 0, NULL, NULL);
-}
-
unsigned long thread_saved_pc(struct task_struct *tsk)
{
return task_pt_regs(tsk)->cp0_epc;
diff --git a/arch/score/kernel/signal.c b/arch/score/kernel/signal.c
index c268bbf8b410..02353bde92d8 100644
--- a/arch/score/kernel/signal.c
+++ b/arch/score/kernel/signal.c
@@ -148,7 +148,6 @@ score_rt_sigreturn(struct pt_regs *regs)
{
struct rt_sigframe __user *frame;
sigset_t set;
- stack_t st;
int sig;
/* Always make any pending restarted system calls return -EINTR */
@@ -168,12 +167,10 @@ score_rt_sigreturn(struct pt_regs *regs)
else if (sig)
force_sig(sig, current);
- if (__copy_from_user(&st, &frame->rs_uc.uc_stack, sizeof(st)))
- goto badframe;
-
/* It is more difficult to avoid calling this function than to
call it and ignore errors. */
- do_sigaltstack((stack_t __user *)&st, NULL, regs->regs[0]);
+ if (do_sigaltstack(&frame->rs_uc.uc_stack, NULL, regs->regs[0]) == -EFAULT)
+ goto badframe;
regs->is_syscall = 0;
__asm__ __volatile__(
diff --git a/arch/score/kernel/sys_score.c b/arch/score/kernel/sys_score.c
index d45cf00a3351..c54434c2fd9d 100644
--- a/arch/score/kernel/sys_score.c
+++ b/arch/score/kernel/sys_score.c
@@ -83,57 +83,3 @@ score_vfork(struct pt_regs *regs)
return do_fork(CLONE_VFORK | CLONE_VM | SIGCHLD,
regs->regs[0], regs, 0, NULL, NULL);
}
-
-/*
- * sys_execve() executes a new program.
- * This is called indirectly via a small wrapper
- */
-asmlinkage long
-score_execve(struct pt_regs *regs)
-{
- int error;
- struct filename *filename;
-
- filename = getname((char __user*)regs->regs[4]);
- error = PTR_ERR(filename);
- if (IS_ERR(filename))
- return error;
-
- error = do_execve(filename->name,
- (const char __user *const __user *)regs->regs[5],
- (const char __user *const __user *)regs->regs[6],
- regs);
-
- putname(filename);
- return error;
-}
-
-/*
- * Do a system call from kernel instead of calling sys_execve so we
- * end up with proper pt_regs.
- */
-asmlinkage
-int kernel_execve(const char *filename,
- const char *const argv[],
- const char *const envp[])
-{
- register unsigned long __r4 asm("r4") = (unsigned long) filename;
- register unsigned long __r5 asm("r5") = (unsigned long) argv;
- register unsigned long __r6 asm("r6") = (unsigned long) envp;
- register unsigned long __r7 asm("r7");
-
- __asm__ __volatile__ (" \n"
- "ldi r27, %5 \n"
- "syscall \n"
- "mv %0, r4 \n"
- "mv %1, r7 \n"
- : "=&r" (__r4), "=r" (__r7)
- : "r" (__r4), "r" (__r5), "r" (__r6), "i" (__NR_execve)
- : "r8", "r9", "r10", "r11", "r22", "r23", "r24", "r25",
- "r26", "r27", "memory");
-
- if (__r7 == 0)
- return __r4;
-
- return -__r4;
-}