diff options
-rw-r--r-- | arch/hexagon/Kconfig | 2 | ||||
-rw-r--r-- | arch/hexagon/include/asm/processor.h | 1 | ||||
-rw-r--r-- | arch/hexagon/include/asm/ptrace.h | 4 | ||||
-rw-r--r-- | arch/hexagon/include/asm/unistd.h | 1 | ||||
-rw-r--r-- | arch/hexagon/kernel/process.c | 102 | ||||
-rw-r--r-- | arch/hexagon/kernel/signal.c | 4 | ||||
-rw-r--r-- | arch/hexagon/kernel/syscall.c | 44 | ||||
-rw-r--r-- | arch/hexagon/kernel/vm_entry.S | 4 |
8 files changed, 46 insertions, 116 deletions
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig index 0744f7d7b1fd..e418803b6c8e 100644 --- a/arch/hexagon/Kconfig +++ b/arch/hexagon/Kconfig | |||
@@ -31,6 +31,8 @@ config HEXAGON | |||
31 | select GENERIC_CLOCKEVENTS | 31 | select GENERIC_CLOCKEVENTS |
32 | select GENERIC_CLOCKEVENTS_BROADCAST | 32 | select GENERIC_CLOCKEVENTS_BROADCAST |
33 | select MODULES_USE_ELF_RELA | 33 | select MODULES_USE_ELF_RELA |
34 | select GENERIC_KERNEL_THREAD | ||
35 | select GENERIC_KERNEL_EXECVE | ||
34 | ---help--- | 36 | ---help--- |
35 | Qualcomm Hexagon is a processor architecture designed for high | 37 | Qualcomm Hexagon is a processor architecture designed for high |
36 | performance and low power across a wide variety of applications. | 38 | performance and low power across a wide variety of applications. |
diff --git a/arch/hexagon/include/asm/processor.h b/arch/hexagon/include/asm/processor.h index e8ea459002a4..8483b49de036 100644 --- a/arch/hexagon/include/asm/processor.h +++ b/arch/hexagon/include/asm/processor.h | |||
@@ -34,7 +34,6 @@ | |||
34 | struct task_struct; | 34 | struct task_struct; |
35 | 35 | ||
36 | /* this is defined in arch/process.c */ | 36 | /* this is defined in arch/process.c */ |
37 | extern pid_t kernel_thread(int (*fn)(void *), void * arg, unsigned long flags); | ||
38 | extern unsigned long thread_saved_pc(struct task_struct *tsk); | 37 | extern unsigned long thread_saved_pc(struct task_struct *tsk); |
39 | 38 | ||
40 | extern void start_thread(struct pt_regs *, unsigned long, unsigned long); | 39 | extern void start_thread(struct pt_regs *, unsigned long, unsigned long); |
diff --git a/arch/hexagon/include/asm/ptrace.h b/arch/hexagon/include/asm/ptrace.h index 3d2f607cd63c..7e1e3745cb8a 100644 --- a/arch/hexagon/include/asm/ptrace.h +++ b/arch/hexagon/include/asm/ptrace.h | |||
@@ -32,4 +32,8 @@ | |||
32 | extern int regs_query_register_offset(const char *name); | 32 | extern int regs_query_register_offset(const char *name); |
33 | extern const char *regs_query_register_name(unsigned int offset); | 33 | extern const char *regs_query_register_name(unsigned int offset); |
34 | 34 | ||
35 | #define current_pt_regs() \ | ||
36 | ((struct pt_regs *) \ | ||
37 | ((unsigned long)current_thread_info() + THREAD_SIZE) - 1) | ||
38 | |||
35 | #endif | 39 | #endif |
diff --git a/arch/hexagon/include/asm/unistd.h b/arch/hexagon/include/asm/unistd.h index c0d5565030ae..acbd5adc9814 100644 --- a/arch/hexagon/include/asm/unistd.h +++ b/arch/hexagon/include/asm/unistd.h | |||
@@ -27,5 +27,6 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #define sys_mmap2 sys_mmap_pgoff | 29 | #define sys_mmap2 sys_mmap_pgoff |
30 | #define __ARCH_WANT_SYS_EXECVE | ||
30 | 31 | ||
31 | #include <asm-generic/unistd.h> | 32 | #include <asm-generic/unistd.h> |
diff --git a/arch/hexagon/kernel/process.c b/arch/hexagon/kernel/process.c index af51de63b835..8a016f7e3949 100644 --- a/arch/hexagon/kernel/process.c +++ b/arch/hexagon/kernel/process.c | |||
@@ -26,33 +26,6 @@ | |||
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * Kernel thread creation. The desired kernel function is "wrapped" | ||
30 | * in the kernel_thread_helper function, which does cleanup | ||
31 | * afterwards. | ||
32 | */ | ||
33 | static void __noreturn kernel_thread_helper(void *arg, int (*fn)(void *)) | ||
34 | { | ||
35 | do_exit(fn(arg)); | ||
36 | } | ||
37 | |||
38 | int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) | ||
39 | { | ||
40 | struct pt_regs regs; | ||
41 | |||
42 | memset(®s, 0, sizeof(regs)); | ||
43 | /* | ||
44 | * Yes, we're exploting illicit knowledge of the ABI here. | ||
45 | */ | ||
46 | regs.r00 = (unsigned long) arg; | ||
47 | regs.r01 = (unsigned long) fn; | ||
48 | pt_set_elr(®s, (unsigned long)kernel_thread_helper); | ||
49 | pt_set_kmode(®s); | ||
50 | |||
51 | return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL); | ||
52 | } | ||
53 | EXPORT_SYMBOL(kernel_thread); | ||
54 | |||
55 | /* | ||
56 | * Program thread launch. Often defined as a macro in processor.h, | 29 | * Program thread launch. Often defined as a macro in processor.h, |
57 | * but we're shooting for a small footprint and it's not an inner-loop | 30 | * but we're shooting for a small footprint and it's not an inner-loop |
58 | * performance-critical operation. | 31 | * performance-critical operation. |
@@ -114,7 +87,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk) | |||
114 | * Copy architecture-specific thread state | 87 | * Copy architecture-specific thread state |
115 | */ | 88 | */ |
116 | int copy_thread(unsigned long clone_flags, unsigned long usp, | 89 | int copy_thread(unsigned long clone_flags, unsigned long usp, |
117 | unsigned long unused, struct task_struct *p, | 90 | unsigned long arg, struct task_struct *p, |
118 | struct pt_regs *regs) | 91 | struct pt_regs *regs) |
119 | { | 92 | { |
120 | struct thread_info *ti = task_thread_info(p); | 93 | struct thread_info *ti = task_thread_info(p); |
@@ -125,61 +98,50 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
125 | childregs = (struct pt_regs *) (((unsigned long) ti + THREAD_SIZE) - | 98 | childregs = (struct pt_regs *) (((unsigned long) ti + THREAD_SIZE) - |
126 | sizeof(*childregs)); | 99 | sizeof(*childregs)); |
127 | 100 | ||
128 | memcpy(childregs, regs, sizeof(*childregs)); | ||
129 | ti->regs = childregs; | 101 | ti->regs = childregs; |
130 | 102 | ||
131 | /* | 103 | /* |
132 | * Establish kernel stack pointer and initial PC for new thread | 104 | * Establish kernel stack pointer and initial PC for new thread |
105 | * Note that unlike the usual situation, we do not copy the | ||
106 | * parent's callee-saved here; those are in pt_regs and whatever | ||
107 | * we leave here will be overridden on return to userland. | ||
133 | */ | 108 | */ |
134 | ss = (struct hexagon_switch_stack *) ((unsigned long) childregs - | 109 | ss = (struct hexagon_switch_stack *) ((unsigned long) childregs - |
135 | sizeof(*ss)); | 110 | sizeof(*ss)); |
136 | ss->lr = (unsigned long)ret_from_fork; | 111 | ss->lr = (unsigned long)ret_from_fork; |
137 | p->thread.switch_sp = ss; | 112 | p->thread.switch_sp = ss; |
138 | 113 | if (unlikely(p->flags & PF_KTHREAD)) { | |
139 | /* If User mode thread, set pt_reg stack pointer as per parameter */ | 114 | memset(childregs, 0, sizeof(struct pt_regs)); |
140 | if (user_mode(childregs)) { | 115 | /* r24 <- fn, r25 <- arg */ |
141 | pt_set_rte_sp(childregs, usp); | 116 | ss->r2524 = usp | ((u64)arg << 32); |
142 | 117 | pt_set_kmode(childregs); | |
143 | /* Child sees zero return value */ | 118 | return 0; |
144 | childregs->r00 = 0; | ||
145 | |||
146 | /* | ||
147 | * The clone syscall has the C signature: | ||
148 | * int [r0] clone(int flags [r0], | ||
149 | * void *child_frame [r1], | ||
150 | * void *parent_tid [r2], | ||
151 | * void *child_tid [r3], | ||
152 | * void *thread_control_block [r4]); | ||
153 | * ugp is used to provide TLS support. | ||
154 | */ | ||
155 | if (clone_flags & CLONE_SETTLS) | ||
156 | childregs->ugp = childregs->r04; | ||
157 | |||
158 | /* | ||
159 | * Parent sees new pid -- not necessary, not even possible at | ||
160 | * this point in the fork process | ||
161 | * Might also want to set things like ti->addr_limit | ||
162 | */ | ||
163 | } else { | ||
164 | /* | ||
165 | * If kernel thread, resume stack is kernel stack base. | ||
166 | * Note that this is pointer arithmetic on pt_regs * | ||
167 | */ | ||
168 | pt_set_rte_sp(childregs, (unsigned long)(childregs + 1)); | ||
169 | /* | ||
170 | * We need the current thread_info fast path pointer | ||
171 | * set up in pt_regs. The register to be used is | ||
172 | * parametric for assembler code, but the mechanism | ||
173 | * doesn't drop neatly into C. Needs to be fixed. | ||
174 | */ | ||
175 | childregs->THREADINFO_REG = (unsigned long) ti; | ||
176 | } | 119 | } |
120 | memcpy(childregs, regs, sizeof(*childregs)); | ||
121 | ss->r2524 = 0; | ||
122 | |||
123 | pt_set_rte_sp(childregs, usp); | ||
124 | |||
125 | /* Child sees zero return value */ | ||
126 | childregs->r00 = 0; | ||
127 | |||
128 | /* | ||
129 | * The clone syscall has the C signature: | ||
130 | * int [r0] clone(int flags [r0], | ||
131 | * void *child_frame [r1], | ||
132 | * void *parent_tid [r2], | ||
133 | * void *child_tid [r3], | ||
134 | * void *thread_control_block [r4]); | ||
135 | * ugp is used to provide TLS support. | ||
136 | */ | ||
137 | if (clone_flags & CLONE_SETTLS) | ||
138 | childregs->ugp = childregs->r04; | ||
177 | 139 | ||
178 | /* | 140 | /* |
179 | * thread_info pointer is pulled out of task_struct "stack" | 141 | * Parent sees new pid -- not necessary, not even possible at |
180 | * field on switch_to. | 142 | * this point in the fork process |
143 | * Might also want to set things like ti->addr_limit | ||
181 | */ | 144 | */ |
182 | p->stack = (void *)ti; | ||
183 | 145 | ||
184 | return 0; | 146 | return 0; |
185 | } | 147 | } |
diff --git a/arch/hexagon/kernel/signal.c b/arch/hexagon/kernel/signal.c index 1ea16bec7b91..28b9e2617769 100644 --- a/arch/hexagon/kernel/signal.c +++ b/arch/hexagon/kernel/signal.c | |||
@@ -249,14 +249,14 @@ void do_notify_resume(struct pt_regs *regs, unsigned long thread_info_flags) | |||
249 | */ | 249 | */ |
250 | asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss) | 250 | asmlinkage int sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss) |
251 | { | 251 | { |
252 | struct pt_regs *regs = current_thread_info()->regs; | 252 | struct pt_regs *regs = current_pt_regs(); |
253 | 253 | ||
254 | return do_sigaltstack(uss, uoss, regs->r29); | 254 | return do_sigaltstack(uss, uoss, regs->r29); |
255 | } | 255 | } |
256 | 256 | ||
257 | asmlinkage int sys_rt_sigreturn(void) | 257 | asmlinkage int sys_rt_sigreturn(void) |
258 | { | 258 | { |
259 | struct pt_regs *regs = current_thread_info()->regs; | 259 | struct pt_regs *regs = current_pt_regs(); |
260 | struct rt_sigframe __user *frame; | 260 | struct rt_sigframe __user *frame; |
261 | sigset_t blocked; | 261 | sigset_t blocked; |
262 | 262 | ||
diff --git a/arch/hexagon/kernel/syscall.c b/arch/hexagon/kernel/syscall.c index 25a9bfe3445d..e28f4e5a6a7a 100644 --- a/arch/hexagon/kernel/syscall.c +++ b/arch/hexagon/kernel/syscall.c | |||
@@ -35,55 +35,13 @@ | |||
35 | * See signal.c for signal-related system call wrappers. | 35 | * See signal.c for signal-related system call wrappers. |
36 | */ | 36 | */ |
37 | 37 | ||
38 | asmlinkage int sys_execve(char __user *ufilename, | ||
39 | const char __user *const __user *argv, | ||
40 | const char __user *const __user *envp) | ||
41 | { | ||
42 | struct pt_regs *pregs = current_thread_info()->regs; | ||
43 | struct filename *filename; | ||
44 | int retval; | ||
45 | |||
46 | filename = getname(ufilename); | ||
47 | retval = PTR_ERR(filename); | ||
48 | if (IS_ERR(filename)) | ||
49 | return retval; | ||
50 | |||
51 | retval = do_execve(filename->name, argv, envp, pregs); | ||
52 | putname(filename); | ||
53 | |||
54 | return retval; | ||
55 | } | ||
56 | |||
57 | asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, | 38 | asmlinkage int sys_clone(unsigned long clone_flags, unsigned long newsp, |
58 | unsigned long parent_tidp, unsigned long child_tidp) | 39 | unsigned long parent_tidp, unsigned long child_tidp) |
59 | { | 40 | { |
60 | struct pt_regs *pregs = current_thread_info()->regs; | 41 | struct pt_regs *pregs = current_pt_regs(); |
61 | 42 | ||
62 | if (!newsp) | 43 | if (!newsp) |
63 | newsp = pregs->SP; | 44 | newsp = pregs->SP; |
64 | return do_fork(clone_flags, newsp, pregs, 0, (int __user *)parent_tidp, | 45 | return do_fork(clone_flags, newsp, pregs, 0, (int __user *)parent_tidp, |
65 | (int __user *)child_tidp); | 46 | (int __user *)child_tidp); |
66 | } | 47 | } |
67 | |||
68 | /* | ||
69 | * Do a system call from the kernel, so as to have a proper pt_regs | ||
70 | * and recycle the sys_execvpe infrustructure. | ||
71 | */ | ||
72 | int kernel_execve(const char *filename, | ||
73 | const char *const argv[], const char *const envp[]) | ||
74 | { | ||
75 | register unsigned long __a0 asm("r0") = (unsigned long) filename; | ||
76 | register unsigned long __a1 asm("r1") = (unsigned long) argv; | ||
77 | register unsigned long __a2 asm("r2") = (unsigned long) envp; | ||
78 | int retval; | ||
79 | |||
80 | __asm__ volatile( | ||
81 | " R6 = #%4;\n" | ||
82 | " trap0(#1);\n" | ||
83 | " %0 = R0;\n" | ||
84 | : "=r" (retval) | ||
85 | : "r" (__a0), "r" (__a1), "r" (__a2), "i" (__NR_execve) | ||
86 | ); | ||
87 | |||
88 | return retval; | ||
89 | } | ||
diff --git a/arch/hexagon/kernel/vm_entry.S b/arch/hexagon/kernel/vm_entry.S index 5b99066cbc8d..1a7fcf502093 100644 --- a/arch/hexagon/kernel/vm_entry.S +++ b/arch/hexagon/kernel/vm_entry.S | |||
@@ -266,4 +266,8 @@ _K_enter_machcheck: | |||
266 | .globl ret_from_fork | 266 | .globl ret_from_fork |
267 | ret_from_fork: | 267 | ret_from_fork: |
268 | call schedule_tail | 268 | call schedule_tail |
269 | P0 = cmp.eq(R24, #0); | ||
270 | if P0 jump return_from_syscall | ||
271 | R0 = R25; | ||
272 | callr R24 | ||
269 | jump return_from_syscall | 273 | jump return_from_syscall |