diff options
| -rw-r--r-- | arch/mips/Kconfig | 2 | ||||
| -rw-r--r-- | arch/mips/include/asm/processor.h | 2 | ||||
| -rw-r--r-- | arch/mips/include/asm/ptrace.h | 6 | ||||
| -rw-r--r-- | arch/mips/include/asm/unistd.h | 1 | ||||
| -rw-r--r-- | arch/mips/kernel/entry.S | 6 | ||||
| -rw-r--r-- | arch/mips/kernel/linux32.c | 21 | ||||
| -rw-r--r-- | arch/mips/kernel/mips_ksyms.c | 2 | ||||
| -rw-r--r-- | arch/mips/kernel/process.c | 62 | ||||
| -rw-r--r-- | arch/mips/kernel/scall64-n32.S | 2 | ||||
| -rw-r--r-- | arch/mips/kernel/scall64-o32.S | 2 | ||||
| -rw-r--r-- | arch/mips/kernel/syscall.c | 53 |
11 files changed, 39 insertions, 120 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index dba9390d37cf..4183e62f178c 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
| @@ -40,6 +40,8 @@ config MIPS | |||
| 40 | select HAVE_MOD_ARCH_SPECIFIC | 40 | select HAVE_MOD_ARCH_SPECIFIC |
| 41 | select MODULES_USE_ELF_REL | 41 | select MODULES_USE_ELF_REL |
| 42 | select MODULES_USE_ELF_RELA if 64BIT | 42 | select MODULES_USE_ELF_RELA if 64BIT |
| 43 | select GENERIC_KERNEL_THREAD | ||
| 44 | select GENERIC_KERNEL_EXECVE | ||
| 43 | 45 | ||
| 44 | menu "Machine selection" | 46 | menu "Machine selection" |
| 45 | 47 | ||
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h index 5e33fabe354d..d28c41e0887c 100644 --- a/arch/mips/include/asm/processor.h +++ b/arch/mips/include/asm/processor.h | |||
| @@ -310,8 +310,6 @@ struct task_struct; | |||
| 310 | /* Free all resources held by a thread. */ | 310 | /* Free all resources held by a thread. */ |
| 311 | #define release_thread(thread) do { } while(0) | 311 | #define release_thread(thread) do { } while(0) |
| 312 | 312 | ||
| 313 | extern long kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | ||
| 314 | |||
| 315 | extern unsigned long thread_saved_pc(struct task_struct *tsk); | 313 | extern unsigned long thread_saved_pc(struct task_struct *tsk); |
| 316 | 314 | ||
| 317 | /* | 315 | /* |
diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h index 4f5da948a777..cec5e125f7e4 100644 --- a/arch/mips/include/asm/ptrace.h +++ b/arch/mips/include/asm/ptrace.h | |||
| @@ -61,4 +61,10 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs) | |||
| 61 | die(str, regs); | 61 | die(str, regs); |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | #define current_pt_regs() \ | ||
| 65 | ({ \ | ||
| 66 | unsigned long sp = (unsigned long)__builtin_frame_address(0); \ | ||
| 67 | (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \ | ||
| 68 | }) | ||
| 69 | |||
| 64 | #endif /* _ASM_PTRACE_H */ | 70 | #endif /* _ASM_PTRACE_H */ |
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h index 9e47cc11aa26..b306e2081cad 100644 --- a/arch/mips/include/asm/unistd.h +++ b/arch/mips/include/asm/unistd.h | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 | 20 | #define __ARCH_OMIT_COMPAT_SYS_GETDENTS64 |
| 21 | #define __ARCH_WANT_OLD_READDIR | 21 | #define __ARCH_WANT_OLD_READDIR |
| 22 | #define __ARCH_WANT_SYS_ALARM | 22 | #define __ARCH_WANT_SYS_ALARM |
| 23 | #define __ARCH_WANT_SYS_EXECVE | ||
| 23 | #define __ARCH_WANT_SYS_GETHOSTNAME | 24 | #define __ARCH_WANT_SYS_GETHOSTNAME |
| 24 | #define __ARCH_WANT_SYS_IPC | 25 | #define __ARCH_WANT_SYS_IPC |
| 25 | #define __ARCH_WANT_SYS_PAUSE | 26 | #define __ARCH_WANT_SYS_PAUSE |
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S index a6c133212003..3320cb4ac1d4 100644 --- a/arch/mips/kernel/entry.S +++ b/arch/mips/kernel/entry.S | |||
| @@ -65,6 +65,12 @@ need_resched: | |||
| 65 | b need_resched | 65 | b need_resched |
| 66 | #endif | 66 | #endif |
| 67 | 67 | ||
| 68 | FEXPORT(ret_from_kernel_thread) | ||
| 69 | jal schedule_tail # a0 = struct task_struct *prev | ||
| 70 | move a0, s1 | ||
| 71 | jal s0 | ||
| 72 | j syscall_exit | ||
| 73 | |||
| 68 | FEXPORT(ret_from_fork) | 74 | FEXPORT(ret_from_fork) |
| 69 | jal schedule_tail # a0 = struct task_struct *prev | 75 | jal schedule_tail # a0 = struct task_struct *prev |
| 70 | 76 | ||
diff --git a/arch/mips/kernel/linux32.c b/arch/mips/kernel/linux32.c index 3a21acedf882..8796dbc7e358 100644 --- a/arch/mips/kernel/linux32.c +++ b/arch/mips/kernel/linux32.c | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2000 Silicon Graphics, Inc. | 4 | * Copyright (C) 2000 Silicon Graphics, Inc. |
| 5 | * Written by Ulf Carlsson (ulfc@engr.sgi.com) | 5 | * Written by Ulf Carlsson (ulfc@engr.sgi.com) |
| 6 | * sys32_execve from ia64/ia32 code, Feb 2000, Kanoj Sarcar (kanoj@sgi.com) | ||
| 7 | */ | 6 | */ |
| 8 | #include <linux/compiler.h> | 7 | #include <linux/compiler.h> |
| 9 | #include <linux/mm.h> | 8 | #include <linux/mm.h> |
| @@ -77,26 +76,6 @@ out: | |||
| 77 | return error; | 76 | return error; |
| 78 | } | 77 | } |
| 79 | 78 | ||
| 80 | /* | ||
| 81 | * sys_execve() executes a new program. | ||
| 82 | */ | ||
| 83 | asmlinkage int sys32_execve(nabi_no_regargs struct pt_regs regs) | ||
| 84 | { | ||
| 85 | int error; | ||
| 86 | struct filename *filename; | ||
| 87 | |||
| 88 | filename = getname(compat_ptr(regs.regs[4])); | ||
| 89 | error = PTR_ERR(filename); | ||
| 90 | if (IS_ERR(filename)) | ||
| 91 | goto out; | ||
| 92 | error = compat_do_execve(filename->name, compat_ptr(regs.regs[5]), | ||
| 93 | compat_ptr(regs.regs[6]), ®s); | ||
| 94 | putname(filename); | ||
| 95 | |||
| 96 | out: | ||
| 97 | return error; | ||
| 98 | } | ||
| 99 | |||
| 100 | #define RLIM_INFINITY32 0x7fffffff | 79 | #define RLIM_INFINITY32 0x7fffffff |
| 101 | #define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x) | 80 | #define RESOURCE32(x) ((x > RLIM_INFINITY32) ? RLIM_INFINITY32 : x) |
| 102 | 81 | ||
diff --git a/arch/mips/kernel/mips_ksyms.c b/arch/mips/kernel/mips_ksyms.c index 3fc1691110dc..2d9304c2b54c 100644 --- a/arch/mips/kernel/mips_ksyms.c +++ b/arch/mips/kernel/mips_ksyms.c | |||
| @@ -32,8 +32,6 @@ EXPORT_SYMBOL(memset); | |||
| 32 | EXPORT_SYMBOL(memcpy); | 32 | EXPORT_SYMBOL(memcpy); |
| 33 | EXPORT_SYMBOL(memmove); | 33 | EXPORT_SYMBOL(memmove); |
| 34 | 34 | ||
| 35 | EXPORT_SYMBOL(kernel_thread); | ||
| 36 | |||
| 37 | /* | 35 | /* |
| 38 | * Functions that operate on entire pages. Mostly used by memory management. | 36 | * Functions that operate on entire pages. Mostly used by memory management. |
| 39 | */ | 37 | */ |
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index e9a5fd7277f4..d13720ac656f 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c | |||
| @@ -84,6 +84,7 @@ void __noreturn cpu_idle(void) | |||
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | asmlinkage void ret_from_fork(void); | 86 | asmlinkage void ret_from_fork(void); |
| 87 | asmlinkage void ret_from_kernel_thread(void); | ||
| 87 | 88 | ||
| 88 | void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp) | 89 | void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp) |
| 89 | { | 90 | { |
| @@ -113,7 +114,7 @@ void flush_thread(void) | |||
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | int copy_thread(unsigned long clone_flags, unsigned long usp, | 116 | int copy_thread(unsigned long clone_flags, unsigned long usp, |
| 116 | unsigned long unused, struct task_struct *p, struct pt_regs *regs) | 117 | unsigned long arg, struct task_struct *p, struct pt_regs *regs) |
| 117 | { | 118 | { |
| 118 | struct thread_info *ti = task_thread_info(p); | 119 | struct thread_info *ti = task_thread_info(p); |
| 119 | struct pt_regs *childregs; | 120 | struct pt_regs *childregs; |
| @@ -136,19 +137,30 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
| 136 | childregs = (struct pt_regs *) childksp - 1; | 137 | childregs = (struct pt_regs *) childksp - 1; |
| 137 | /* Put the stack after the struct pt_regs. */ | 138 | /* Put the stack after the struct pt_regs. */ |
| 138 | childksp = (unsigned long) childregs; | 139 | childksp = (unsigned long) childregs; |
| 140 | p->thread.cp0_status = read_c0_status() & ~(ST0_CU2|ST0_CU1); | ||
| 141 | if (unlikely(p->flags & PF_KTHREAD)) { | ||
| 142 | unsigned long status = p->thread.cp0_status; | ||
| 143 | memset(childregs, 0, sizeof(struct pt_regs)); | ||
| 144 | ti->addr_limit = KERNEL_DS; | ||
| 145 | p->thread.reg16 = usp; /* fn */ | ||
| 146 | p->thread.reg17 = arg; | ||
| 147 | p->thread.reg29 = childksp; | ||
| 148 | p->thread.reg31 = (unsigned long) ret_from_kernel_thread; | ||
| 149 | #if defined(CONFIG_CPU_R3000) || defined(CONFIG_CPU_TX39XX) | ||
| 150 | status = (status & ~(ST0_KUP | ST0_IEP | ST0_IEC)) | | ||
| 151 | ((status & (ST0_KUC | ST0_IEC)) << 2); | ||
| 152 | #else | ||
| 153 | status |= ST0_EXL; | ||
| 154 | #endif | ||
| 155 | childregs->cp0_status = status; | ||
| 156 | return 0; | ||
| 157 | } | ||
| 139 | *childregs = *regs; | 158 | *childregs = *regs; |
| 140 | childregs->regs[7] = 0; /* Clear error flag */ | 159 | childregs->regs[7] = 0; /* Clear error flag */ |
| 141 | |||
| 142 | childregs->regs[2] = 0; /* Child gets zero as return value */ | 160 | childregs->regs[2] = 0; /* Child gets zero as return value */ |
| 161 | childregs->regs[29] = usp; | ||
| 162 | ti->addr_limit = USER_DS; | ||
| 143 | 163 | ||
| 144 | if (childregs->cp0_status & ST0_CU0) { | ||
| 145 | childregs->regs[28] = (unsigned long) ti; | ||
| 146 | childregs->regs[29] = childksp; | ||
| 147 | ti->addr_limit = KERNEL_DS; | ||
