diff options
Diffstat (limited to 'arch/openrisc')
-rw-r--r-- | arch/openrisc/Kconfig | 2 | ||||
-rw-r--r-- | arch/openrisc/Makefile | 2 | ||||
-rw-r--r-- | arch/openrisc/boot/dts/Makefile (renamed from arch/openrisc/boot/Makefile) | 5 | ||||
-rw-r--r-- | arch/openrisc/include/asm/Kbuild | 2 | ||||
-rw-r--r-- | arch/openrisc/include/asm/processor.h | 2 | ||||
-rw-r--r-- | arch/openrisc/include/asm/syscalls.h | 7 | ||||
-rw-r--r-- | arch/openrisc/include/uapi/asm/kvm_para.h | 1 | ||||
-rw-r--r-- | arch/openrisc/include/uapi/asm/unistd.h | 3 | ||||
-rw-r--r-- | arch/openrisc/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/openrisc/kernel/asm-offsets.c | 6 | ||||
-rw-r--r-- | arch/openrisc/kernel/entry.S | 55 | ||||
-rw-r--r-- | arch/openrisc/kernel/process.c | 164 | ||||
-rw-r--r-- | arch/openrisc/kernel/signal.c | 6 | ||||
-rw-r--r-- | arch/openrisc/kernel/sys_or32.c | 57 |
14 files changed, 98 insertions, 216 deletions
diff --git a/arch/openrisc/Kconfig b/arch/openrisc/Kconfig index 05f2ba41ff1a..0ac66f67521f 100644 --- a/arch/openrisc/Kconfig +++ b/arch/openrisc/Kconfig | |||
@@ -144,7 +144,7 @@ config DEBUG_STACKOVERFLOW | |||
144 | help | 144 | help |
145 | Make extra checks for space available on stack in some | 145 | Make extra checks for space available on stack in some |
146 | critical functions. This will cause kernel to run a bit slower, | 146 | critical functions. This will cause kernel to run a bit slower, |
147 | but will catch most of kernel stack overruns and exit gracefuly. | 147 | but will catch most of kernel stack overruns and exit gracefully. |
148 | 148 | ||
149 | Say Y if you are unsure. | 149 | Say Y if you are unsure. |
150 | 150 | ||
diff --git a/arch/openrisc/Makefile b/arch/openrisc/Makefile index 966886c8daf5..4739b8302a58 100644 --- a/arch/openrisc/Makefile +++ b/arch/openrisc/Makefile | |||
@@ -50,6 +50,6 @@ BUILTIN_DTB := y | |||
50 | else | 50 | else |
51 | BUILTIN_DTB := n | 51 | BUILTIN_DTB := n |
52 | endif | 52 | endif |
53 | core-$(BUILTIN_DTB) += arch/openrisc/boot/ | 53 | core-$(BUILTIN_DTB) += arch/openrisc/boot/dts/ |
54 | 54 | ||
55 | all: vmlinux | 55 | all: vmlinux |
diff --git a/arch/openrisc/boot/Makefile b/arch/openrisc/boot/dts/Makefile index 09958358601a..b092d30d6c23 100644 --- a/arch/openrisc/boot/Makefile +++ b/arch/openrisc/boot/dts/Makefile | |||
@@ -1,5 +1,3 @@ | |||
1 | |||
2 | |||
3 | ifneq '$(CONFIG_OPENRISC_BUILTIN_DTB)' '""' | 1 | ifneq '$(CONFIG_OPENRISC_BUILTIN_DTB)' '""' |
4 | BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_OPENRISC_BUILTIN_DTB)).dtb.o | 2 | BUILTIN_DTB := $(patsubst "%",%,$(CONFIG_OPENRISC_BUILTIN_DTB)).dtb.o |
5 | else | 3 | else |
@@ -10,6 +8,3 @@ obj-y += $(BUILTIN_DTB) | |||
10 | clean-files := *.dtb.S | 8 | clean-files := *.dtb.S |
11 | 9 | ||
12 | #DTC_FLAGS ?= -p 1024 | 10 | #DTC_FLAGS ?= -p 1024 |
13 | |||
14 | $(obj)/%.dtb: $(src)/dts/%.dts FORCE | ||
15 | $(call if_changed_dep,dtc) | ||
diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild index 78de6805268d..f20d01d9aaf9 100644 --- a/arch/openrisc/include/asm/Kbuild +++ b/arch/openrisc/include/asm/Kbuild | |||
@@ -32,6 +32,7 @@ generic-y += ipcbuf.h | |||
32 | generic-y += irq_regs.h | 32 | generic-y += irq_regs.h |
33 | generic-y += kdebug.h | 33 | generic-y += kdebug.h |
34 | generic-y += kmap_types.h | 34 | generic-y += kmap_types.h |
35 | generic-y += kvm_para.h | ||
35 | generic-y += local.h | 36 | generic-y += local.h |
36 | generic-y += mman.h | 37 | generic-y += mman.h |
37 | generic-y += module.h | 38 | generic-y += module.h |
@@ -60,6 +61,7 @@ generic-y += swab.h | |||
60 | generic-y += termbits.h | 61 | generic-y += termbits.h |
61 | generic-y += termios.h | 62 | generic-y += termios.h |
62 | generic-y += topology.h | 63 | generic-y += topology.h |
64 | generic-y += trace_clock.h | ||
63 | generic-y += types.h | 65 | generic-y += types.h |
64 | generic-y += ucontext.h | 66 | generic-y += ucontext.h |
65 | generic-y += user.h | 67 | generic-y += user.h |
diff --git a/arch/openrisc/include/asm/processor.h b/arch/openrisc/include/asm/processor.h index 43decdbdb2ed..33691380608e 100644 --- a/arch/openrisc/include/asm/processor.h +++ b/arch/openrisc/include/asm/processor.h | |||
@@ -81,8 +81,6 @@ struct thread_struct { | |||
81 | #define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp) | 81 | #define KSTK_ESP(tsk) (task_pt_regs(tsk)->sp) |
82 | 82 | ||
83 | 83 | ||
84 | extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | ||
85 | |||
86 | void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp); | 84 | void start_thread(struct pt_regs *regs, unsigned long nip, unsigned long sp); |
87 | void release_thread(struct task_struct *); | 85 | void release_thread(struct task_struct *); |
88 | unsigned long get_wchan(struct task_struct *p); | 86 | unsigned long get_wchan(struct task_struct *p); |
diff --git a/arch/openrisc/include/asm/syscalls.h b/arch/openrisc/include/asm/syscalls.h index 84a978af44d7..8ee816812a9e 100644 --- a/arch/openrisc/include/asm/syscalls.h +++ b/arch/openrisc/include/asm/syscalls.h | |||
@@ -24,4 +24,11 @@ asmlinkage long sys_or1k_atomic(unsigned long type, unsigned long *v1, | |||
24 | 24 | ||
25 | #include <asm-generic/syscalls.h> | 25 | #include <asm-generic/syscalls.h> |
26 | 26 | ||
27 | asmlinkage long __sys_clone(unsigned long clone_flags, unsigned long newsp, | ||
28 | void __user *parent_tid, void __user *child_tid, int tls); | ||
29 | asmlinkage long __sys_fork(void); | ||
30 | |||
31 | #define sys_clone __sys_clone | ||
32 | #define sys_fork __sys_fork | ||
33 | |||
27 | #endif /* __ASM_OPENRISC_SYSCALLS_H */ | 34 | #endif /* __ASM_OPENRISC_SYSCALLS_H */ |
diff --git a/arch/openrisc/include/uapi/asm/kvm_para.h b/arch/openrisc/include/uapi/asm/kvm_para.h deleted file mode 100644 index 14fab8f0b957..000000000000 --- a/arch/openrisc/include/uapi/asm/kvm_para.h +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | #include <asm-generic/kvm_para.h> | ||
diff --git a/arch/openrisc/include/uapi/asm/unistd.h b/arch/openrisc/include/uapi/asm/unistd.h index 437bdbb61b14..ce40b71df006 100644 --- a/arch/openrisc/include/uapi/asm/unistd.h +++ b/arch/openrisc/include/uapi/asm/unistd.h | |||
@@ -20,6 +20,9 @@ | |||
20 | 20 | ||
21 | #define sys_mmap2 sys_mmap_pgoff | 21 | #define sys_mmap2 sys_mmap_pgoff |
22 | 22 | ||
23 | #define __ARCH_WANT_SYS_FORK | ||
24 | #define __ARCH_WANT_SYS_CLONE | ||
25 | |||
23 | #include <asm-generic/unistd.h> | 26 | #include <asm-generic/unistd.h> |
24 | 27 | ||
25 | #define __NR_or1k_atomic __NR_arch_specific_syscall | 28 | #define __NR_or1k_atomic __NR_arch_specific_syscall |
diff --git a/arch/openrisc/kernel/Makefile b/arch/openrisc/kernel/Makefile index e1ee0fa2bbda..35f92ce51c24 100644 --- a/arch/openrisc/kernel/Makefile +++ b/arch/openrisc/kernel/Makefile | |||
@@ -5,7 +5,7 @@ | |||
5 | extra-y := head.o vmlinux.lds | 5 | extra-y := head.o vmlinux.lds |
6 | 6 | ||
7 | obj-y := setup.o idle.o or32_ksyms.o process.o dma.o \ | 7 | obj-y := setup.o idle.o or32_ksyms.o process.o dma.o \ |
8 | traps.o time.o irq.o entry.o ptrace.o signal.o sys_or32.o \ | 8 | traps.o time.o irq.o entry.o ptrace.o signal.o \ |
9 | sys_call_table.o | 9 | sys_call_table.o |
10 | 10 | ||
11 | obj-$(CONFIG_MODULES) += module.o | 11 | obj-$(CONFIG_MODULES) += module.o |
diff --git a/arch/openrisc/kernel/asm-offsets.c b/arch/openrisc/kernel/asm-offsets.c index 1a242a0d7583..ddb736855863 100644 --- a/arch/openrisc/kernel/asm-offsets.c +++ b/arch/openrisc/kernel/asm-offsets.c | |||
@@ -34,15 +34,11 @@ | |||
34 | #include <linux/mm.h> | 34 | #include <linux/mm.h> |
35 | #include <linux/io.h> | 35 | #include <linux/io.h> |
36 | #include <linux/thread_info.h> | 36 | #include <linux/thread_info.h> |
37 | #include <linux/kbuild.h> | ||
37 | #include <asm/page.h> | 38 | #include <asm/page.h> |
38 | #include <asm/pgtable.h> | 39 | #include <asm/pgtable.h> |
39 | #include <asm/processor.h> | 40 | #include <asm/processor.h> |
40 | 41 | ||
41 | #define DEFINE(sym, val) \ | ||
42 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | ||
43 | |||
44 | #define BLANK() asm volatile("\n->" : : ) | ||
45 | |||
46 | int main(void) | 42 | int main(void) |
47 | { | 43 | { |
48 | /* offsets into the task_struct */ | 44 | /* offsets into the task_struct */ |
diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S index ddfcaa828b0e..5e5b30601bbf 100644 --- a/arch/openrisc/kernel/entry.S +++ b/arch/openrisc/kernel/entry.S | |||
@@ -894,6 +894,16 @@ ENTRY(ret_from_fork) | |||
894 | l.jal schedule_tail | 894 | l.jal schedule_tail |
895 | l.nop | 895 | l.nop |
896 | 896 | ||
897 | /* Check if we are a kernel thread */ | ||
898 | l.sfeqi r20,0 | ||
899 | l.bf 1f | ||
900 | l.nop | ||
901 | |||
902 | /* ...we are a kernel thread so invoke the requested callback */ | ||
903 | l.jalr r20 | ||
904 | l.or r3,r22,r0 | ||
905 | |||
906 | 1: | ||
897 | /* _syscall_returns expect r11 to contain return value */ | 907 | /* _syscall_returns expect r11 to contain return value */ |
898 | l.lwz r11,PT_GPR11(r1) | 908 | l.lwz r11,PT_GPR11(r1) |
899 | 909 | ||
@@ -915,26 +925,6 @@ ENTRY(ret_from_fork) | |||
915 | l.j _syscall_return | 925 | l.j _syscall_return |
916 | l.nop | 926 | l.nop |
917 | 927 | ||
918 | /* Since syscalls don't save call-clobbered registers, the args to | ||
919 | * kernel_thread_helper will need to be passed through callee-saved | ||
920 | * registers and copied to the parameter registers when the thread | ||
921 | * begins running. | ||
922 | * | ||
923 | * See arch/openrisc/kernel/process.c: | ||
924 | * The args are passed as follows: | ||
925 | * arg1 (r3) : passed in r20 | ||
926 | * arg2 (r4) : passed in r22 | ||
927 | */ | ||
928 | |||
929 | ENTRY(_kernel_thread_helper) | ||
930 | l.or r3,r20,r0 | ||
931 | l.or r4,r22,r0 | ||
932 | l.movhi r31,hi(kernel_thread_helper) | ||
933 | l.ori r31,r31,lo(kernel_thread_helper) | ||
934 | l.jr r31 | ||
935 | l.nop | ||
936 | |||
937 | |||
938 | /* ========================================================[ switch ] === */ | 928 | /* ========================================================[ switch ] === */ |
939 | 929 | ||
940 | /* | 930 | /* |
@@ -1044,8 +1034,13 @@ ENTRY(_switch) | |||
1044 | /* Unwind stack to pre-switch state */ | 1034 | /* Unwind stack to pre-switch state */ |
1045 | l.addi r1,r1,(INT_FRAME_SIZE) | 1035 | l.addi r1,r1,(INT_FRAME_SIZE) |
1046 | 1036 | ||
1047 | /* Return via the link-register back to where we 'came from', where that can be | 1037 | /* Return via the link-register back to where we 'came from', where |
1048 | * either schedule() or return_from_fork()... */ | 1038 | * that may be either schedule(), ret_from_fork(), or |
1039 | * ret_from_kernel_thread(). If we are returning to a new thread, | ||
1040 | * we are expected to have set up the arg to schedule_tail already, | ||
1041 | * hence we do so here unconditionally: | ||
1042 | */ | ||
1043 | l.lwz r3,TI_STACK(r3) /* Load 'prev' as schedule_tail arg */ | ||
1049 | l.jr r9 | 1044 | l.jr r9 |
1050 | l.nop | 1045 | l.nop |
1051 | 1046 | ||
@@ -1076,22 +1071,18 @@ _fork_save_extra_regs_and_call: | |||
1076 | l.jr r29 | 1071 | l.jr r29 |
1077 | l.sw PT_GPR28(r1),r28 | 1072 | l.sw PT_GPR28(r1),r28 |
1078 | 1073 | ||
1079 | ENTRY(sys_clone) | 1074 | ENTRY(__sys_clone) |
1080 | l.movhi r29,hi(_sys_clone) | 1075 | l.movhi r29,hi(sys_clone) |
1081 | l.ori r29,r29,lo(_sys_clone) | 1076 | l.ori r29,r29,lo(sys_clone) |
1082 | l.j _fork_save_extra_regs_and_call | 1077 | l.j _fork_save_extra_regs_and_call |
1083 | l.addi r7,r1,0 | 1078 | l.addi r7,r1,0 |
1084 | 1079 | ||
1085 | ENTRY(sys_fork) | 1080 | ENTRY(__sys_fork) |
1086 | l.movhi r29,hi(_sys_fork) | 1081 | l.movhi r29,hi(sys_fork) |
1087 | l.ori r29,r29,lo(_sys_fork) | 1082 | l.ori r29,r29,lo(sys_fork) |
1088 | l.j _fork_save_extra_regs_and_call | 1083 | l.j _fork_save_extra_regs_and_call |
1089 | l.addi r3,r1,0 | 1084 | l.addi r3,r1,0 |
1090 | 1085 | ||
1091 | ENTRY(sys_execve) | ||
1092 | l.j _sys_execve | ||
1093 | l.addi r6,r1,0 | ||
1094 | |||
1095 | ENTRY(sys_sigaltstack) | 1086 | ENTRY(sys_sigaltstack) |
1096 | l.j _sys_sigaltstack | 1087 | l.j _sys_sigaltstack |
1097 | l.addi r5,r1,0 | 1088 | l.addi r5,r1,0 |
diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c index c35f3ab1a8d3..00c233bf0d06 100644 --- a/arch/openrisc/kernel/process.c +++ b/arch/openrisc/kernel/process.c | |||
@@ -109,66 +109,83 @@ void release_thread(struct task_struct *dead_task) | |||
109 | */ | 109 | */ |
110 | extern asmlinkage void ret_from_fork(void); | 110 | extern asmlinkage void ret_from_fork(void); |
111 | 111 | ||
112 | /* | ||
113 | * copy_thread | ||
114 | * @clone_flags: flags | ||
115 | * @usp: user stack pointer or fn for kernel thread | ||
116 | * @arg: arg to fn for kernel thread; always NULL for userspace thread | ||
117 | * @p: the newly created task | ||
118 | * @regs: CPU context to copy for userspace thread; always NULL for kthread | ||
119 | * | ||
120 | * At the top of a newly initialized kernel stack are two stacked pt_reg | ||
121 | * structures. The first (topmost) is the userspace context of the thread. | ||
122 | * The second is the kernelspace context of the thread. | ||
123 | * | ||
124 | * A kernel thread will not be returning to userspace, so the topmost pt_regs | ||
125 | * struct can be uninitialized; it _does_ need to exist, though, because | ||
126 | * a kernel thread can become a userspace thread by doing a kernel_execve, in | ||
127 | * which case the topmost context will be initialized and used for 'returning' | ||
128 | * to userspace. | ||
129 | * | ||
130 | * The second pt_reg struct needs to be initialized to 'return' to | ||
131 | * ret_from_fork. A kernel thread will need to set r20 to the address of | ||
132 | * a function to call into (with arg in r22); userspace threads need to set | ||
133 | * r20 to NULL in which case ret_from_fork will just continue a return to | ||
134 | * userspace. | ||
135 | * | ||
136 | * A kernel thread 'fn' may return; this is effectively what happens when | ||
137 | * kernel_execve is called. In that case, the userspace pt_regs must have | ||
138 | * been initialized (which kernel_execve takes care of, see start_thread | ||
139 | * below); ret_from_fork will then continue its execution causing the | ||
140 | * 'kernel thread' to return to userspace as a userspace thread. | ||
141 | */ | ||
142 | |||
112 | int | 143 | int |
113 | copy_thread(unsigned long clone_flags, unsigned long usp, | 144 | copy_thread(unsigned long clone_flags, unsigned long usp, |
114 | unsigned long unused, struct task_struct *p, struct pt_regs *regs) | 145 | unsigned long arg, struct task_struct *p) |
115 | { | 146 | { |
116 | struct pt_regs *childregs; | 147 | struct pt_regs *userregs; |
117 | struct pt_regs *kregs; | 148 | struct pt_regs *kregs; |
118 | unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE; | 149 | unsigned long sp = (unsigned long)task_stack_page(p) + THREAD_SIZE; |
119 | struct thread_info *ti; | ||
120 | unsigned long top_of_kernel_stack; | 150 | unsigned long top_of_kernel_stack; |
121 | 151 | ||
122 | top_of_kernel_stack = sp; | 152 | top_of_kernel_stack = sp; |
123 | 153 | ||
124 | p->set_child_tid = p->clear_child_tid = NULL; | 154 | p->set_child_tid = p->clear_child_tid = NULL; |
125 | 155 | ||
126 | /* Copy registers */ | 156 | /* Locate userspace context on stack... */ |
127 | /* redzone */ | 157 | sp -= STACK_FRAME_OVERHEAD; /* redzone */ |
128 | sp -= STACK_FRAME_OVERHEAD; | ||
129 | sp -= sizeof(struct pt_regs); | 158 | sp -= sizeof(struct pt_regs); |
130 | childregs = (struct pt_regs *)sp; | 159 | userregs = (struct pt_regs *) sp; |
131 | 160 | ||
132 | /* Copy parent registers */ | 161 | /* ...and kernel context */ |
133 | *childregs = *regs; | 162 | sp -= STACK_FRAME_OVERHEAD; /* redzone */ |
163 | sp -= sizeof(struct pt_regs); | ||
164 | kregs = (struct pt_regs *)sp; | ||
134 | 165 | ||
135 | if ((childregs->sr & SPR_SR_SM) == 1) { | 166 | if (unlikely(p->flags & PF_KTHREAD)) { |
136 | /* for kernel thread, set `current_thread_info' | 167 | memset(kregs, 0, sizeof(struct pt_regs)); |
137 | * and stackptr in new task | 168 | kregs->gpr[20] = usp; /* fn, kernel thread */ |
138 | */ | 169 | kregs->gpr[22] = arg; |
139 | childregs->sp = (unsigned long)task_stack_page(p) + THREAD_SIZE; | ||
140 | childregs->gpr[10] = (unsigned long)task_thread_info(p); | ||
141 | } else { | 170 | } else { |
142 | childregs->sp = usp; | 171 | *userregs = *current_pt_regs(); |
143 | } | ||
144 | |||
145 | childregs->gpr[11] = 0; /* Result from fork() */ | ||
146 | 172 | ||
147 | /* | 173 | if (usp) |
148 | * The way this works is that at some point in the future | 174 | userregs->sp = usp; |
149 | * some task will call _switch to switch to the new task. | 175 | userregs->gpr[11] = 0; /* Result from fork() */ |
150 | * That will pop off the stack frame created below and start | ||
151 | * the new task running at ret_from_fork. The new task will | ||
152 | * do some house keeping and then return from the fork or clone | ||
153 | * system call, using the stack frame created above. | ||
154 | */ | ||
155 | /* redzone */ | ||
156 | sp -= STACK_FRAME_OVERHEAD; | ||
157 | sp -= sizeof(struct pt_regs); | ||
158 | kregs = (struct pt_regs *)sp; | ||
159 | 176 | ||
160 | ti = task_thread_info(p); | 177 | kregs->gpr[20] = 0; /* Userspace thread */ |
161 | ti->ksp = sp; | 178 | } |
162 | 179 | ||
163 | /* kregs->sp must store the location of the 'pre-switch' kernel stack | 180 | /* |
164 | * pointer... for a newly forked process, this is simply the top of | 181 | * _switch wants the kernel stack page in pt_regs->sp so that it |
165 | * the kernel stack. | 182 | * can restore it to thread_info->ksp... see _switch for details. |
166 | */ | 183 | */ |
167 | kregs->sp = top_of_kernel_stack; | 184 | kregs->sp = top_of_kernel_stack; |
168 | kregs->gpr[3] = (unsigned long)current; /* arg to schedule_tail */ | ||
169 | kregs->gpr[10] = (unsigned long)task_thread_info(p); | ||
170 | kregs->gpr[9] = (unsigned long)ret_from_fork; | 185 | kregs->gpr[9] = (unsigned long)ret_from_fork; |
171 | 186 | ||
187 | task_thread_info(p)->ksp = (unsigned long)kregs; | ||
188 | |||
172 | return 0; | 189 | return 0; |
173 | } | 190 | } |
174 | 191 | ||
@@ -177,16 +194,14 @@ copy_thread(unsigned long clone_flags, unsigned long usp, | |||
177 | */ | 194 | */ |
178 | void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp) | 195 | void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long sp) |
179 | { | 196 | { |
180 | unsigned long sr = regs->sr & ~SPR_SR_SM; | 197 | unsigned long sr = mfspr(SPR_SR) & ~SPR_SR_SM; |
181 | 198 | ||
182 | set_fs(USER_DS); | 199 | set_fs(USER_DS); |
183 | memset(regs->gpr, 0, sizeof(regs->gpr)); | 200 | memset(regs, 0, sizeof(struct pt_regs)); |
184 | 201 | ||
185 | regs->pc = pc; | 202 | regs->pc = pc; |
186 | regs->sr = sr; | 203 | regs->sr = sr; |
187 | regs->sp = sp; | 204 | regs->sp = sp; |
188 | |||
189 | /* printk("start thread, ksp = %lx\n", current_thread_info()->ksp);*/ | ||
190 | } | 205 | } |
191 | 206 | ||
192 | /* Fill in the fpu structure for a core dump. */ | 207 | /* Fill in the fpu structure for a core dump. */ |
@@ -237,74 +252,9 @@ void dump_elf_thread(elf_greg_t *dest, struct pt_regs* regs) | |||
237 | dest[35] = 0; | 252 | dest[35] = 0; |
238 | } | 253 | } |
239 | 254 | ||
240 | extern void _kernel_thread_helper(void); | ||
241 | |||
242 | void __noreturn kernel_thread_helper(int (*fn) (void *), void *arg) | ||
243 | { | ||
244 | do_exit(fn(arg)); | ||
245 | } | ||
246 | |||
247 | /* | ||
248 | * Create a kernel thread. | ||
249 | */ | ||
250 | int kernel_thread(int (*fn) (void *), void *arg, unsigned long flags) | ||
251 | { | ||
252 | struct pt_regs regs; | ||
253 | |||
254 | memset(®s, 0, sizeof(regs)); | ||
255 | |||
256 | regs.gpr[20] = (unsigned long)fn; | ||
257 | regs.gpr[22] = (unsigned long)arg; | ||
258 | regs.sr = mfspr(SPR_SR); | ||
259 | regs.pc = (unsigned long)_kernel_thread_helper; | ||
260 | |||
261 | return do_fork(flags | CLONE_VM | CLONE_UNTRACED, | ||
262 | 0, ®s, 0, NULL, NULL); | ||
263 | } | ||
264 | |||
265 | /* | ||
266 | * sys_execve() executes a new program. | ||
267 | */ | ||
268 | asmlinkage long _sys_execve(const char __user *name, | ||
269 | const char __user * const __user *argv, | ||
270 | const char __user * const __user *envp, | ||
271 | struct pt_regs *regs) | ||
272 | { | ||
273 | int error; | ||
274 | struct filename *filename; | ||
275 | |||
276 | filename = getname(name); | ||
277 | error = PTR_ERR(filename); | ||
278 | |||
279 | if (IS_ERR(filename)) | ||
280 | goto out; | ||
281 | |||
282 | error = do_execve(filename->name, argv, envp, regs); | ||
283 | putname(filename); | ||
284 | |||
285 | out: | ||
286 | return error; | ||
287 | } | ||
288 | |||
289 | unsigned long get_wchan(struct task_struct *p) | 255 | unsigned long get_wchan(struct task_struct *p) |
290 | { | 256 | { |
291 | /* TODO */ | 257 | /* TODO */ |
292 | 258 | ||
293 | return 0; | 259 | return 0; |
294 | } | 260 | } |
295 | |||
296 | int kernel_execve(const char *filename, char *const argv[], char *const envp[]) | ||
297 | { | ||
298 | register long __res asm("r11") = __NR_execve; | ||
299 | register long __a asm("r3") = (long)(filename); | ||
300 | register long __b asm("r4") = (long)(argv); | ||
301 | register long __c asm("r5") = (long)(envp); | ||
302 | __asm__ volatile ("l.sys 1" | ||
303 | : "=r" (__res), "=r"(__a), "=r"(__b), "=r"(__c) | ||
304 | : "0"(__res), "1"(__a), "2"(__b), "3"(__c) | ||
305 | : "r6", "r7", "r8", "r12", "r13", "r15", | ||
306 | "r17", "r19", "r21", "r23", "r25", "r27", | ||
307 | "r29", "r31"); | ||
308 | __asm__ volatile ("l.nop"); | ||
309 | return __res; | ||
310 | } | ||
diff --git a/arch/openrisc/kernel/signal.c b/arch/openrisc/kernel/signal.c index 30110297f4f9..ddedc8a77861 100644 --- a/arch/openrisc/kernel/signal.c +++ b/arch/openrisc/kernel/signal.c | |||
@@ -84,7 +84,6 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs) | |||
84 | { | 84 | { |
85 | struct rt_sigframe *frame = (struct rt_sigframe __user *)regs->sp; | 85 | struct rt_sigframe *frame = (struct rt_sigframe __user *)regs->sp; |
86 | sigset_t set; | 86 | sigset_t set; |
87 | stack_t st; | ||
88 | 87 | ||
89 | /* | 88 | /* |
90 | * Since we stacked the signal on a dword boundary, | 89 | * Since we stacked the signal on a dword boundary, |
@@ -104,11 +103,10 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs) | |||
104 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) | 103 | if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) |
105 | goto badframe; | 104 | goto badframe; |
106 | 105 | ||
107 | if (__copy_from_user(&st, &frame->uc.uc_stack, sizeof(st))) | ||
108 | goto badframe; | ||
109 | /* It is more difficult to avoid calling this function than to | 106 | /* It is more difficult to avoid calling this function than to |
110 | call it and ignore errors. */ | 107 | call it and ignore errors. */ |
111 | do_sigaltstack(&st, NULL, regs->sp); | 108 | if (do_sigaltstack(&frame->uc.uc_stack, NULL, regs->sp) == -EFAULT) |
109 | goto badframe; | ||
112 | 110 | ||
113 | return regs->gpr[11]; | 111 | return regs->gpr[11]; |
114 | 112 | ||
diff --git a/arch/openrisc/kernel/sys_or32.c b/arch/openrisc/kernel/sys_or32.c deleted file mode 100644 index 57060084c0cc..000000000000 --- a/arch/openrisc/kernel/sys_or32.c +++ /dev/null | |||
@@ -1,57 +0,0 @@ | |||
1 | /* | ||
2 | * OpenRISC sys_or32.c | ||
3 | * | ||
4 | * Linux architectural port borrowing liberally from similar works of | ||
5 | * others. All original copyrights apply as per the original source | ||
6 | * declaration. | ||
7 | * | ||
8 | * Modifications for the OpenRISC architecture: | ||
9 | * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> | ||
10 | * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version | ||
15 | * 2 of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This file contains various random system calls that | ||
18 | * have a non-standard calling sequence on some platforms. | ||
19 | * Since we don't have to do any backwards compatibility, our | ||
20 | * versions are done in the most "normal" way possible. | ||
21 | */ | ||
22 | |||
23 | #include <linux/errno.h> | ||
24 | #include <linux/syscalls.h> | ||
25 | #include <linux/mm.h> | ||
26 | |||
27 | #include <asm/syscalls.h> | ||
28 | |||
29 | /* These are secondary entry points as the primary entry points are defined in | ||
30 | * entry.S where we add the 'regs' parameter value | ||
31 | */ | ||
32 | |||
33 | asmlinkage long _sys_clone(unsigned long clone_flags, unsigned long newsp, | ||
34 | int __user *parent_tid, int __user *child_tid, | ||
35 | struct pt_regs *regs) | ||
36 | { | ||
37 | long ret; | ||
38 | |||
39 | /* FIXME: Is alignment necessary? */ | ||
40 | /* newsp = ALIGN(newsp, 4); */ | ||
41 | |||
42 | if (!newsp) | ||
43 | newsp = regs->sp; | ||
44 | |||
45 | ret = do_fork(clone_flags, newsp, regs, 0, parent_tid, child_tid); | ||
46 | |||
47 | return ret; | ||
48 | } | ||
49 | |||
50 | asmlinkage int _sys_fork(struct pt_regs *regs) | ||
51 | { | ||
52 | #ifdef CONFIG_MMU | ||
53 | return do_fork(SIGCHLD, regs->sp, regs, 0, NULL, NULL); | ||
54 | #else | ||
55 | return -EINVAL; | ||
56 | #endif | ||
57 | } | ||