hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/arc/kernel/process.c
....@@ -1,9 +1,6 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
3
- *
4
- * This program is free software; you can redistribute it and/or modify
5
- * it under the terms of the GNU General Public License version 2 as
6
- * published by the Free Software Foundation.
74 *
85 * Amit Bhor, Kanika Nema: Codito Technologies 2004
96 */
....@@ -22,6 +19,8 @@
2219 #include <linux/syscalls.h>
2320 #include <linux/elf.h>
2421 #include <linux/tick.h>
22
+
23
+#include <asm/fpu.h>
2524
2625 SYSCALL_DEFINE1(arc_settls, void *, user_tls_data_ptr)
2726 {
....@@ -44,7 +43,7 @@
4443 return task_thread_info(current)->thr_ptr;
4544 }
4645
47
-SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
46
+SYSCALL_DEFINE3(arc_usr_cmpxchg, int __user *, uaddr, int, expected, int, new)
4847 {
4948 struct pt_regs *regs = current_pt_regs();
5049 u32 uval;
....@@ -61,7 +60,7 @@
6160 /* Z indicates to userspace if operation succeded */
6261 regs->status32 &= ~STATUS_Z_MASK;
6362
64
- ret = access_ok(VERIFY_WRITE, uaddr, sizeof(*uaddr));
63
+ ret = access_ok(uaddr, sizeof(*uaddr));
6564 if (!ret)
6665 goto fail;
6766
....@@ -91,16 +90,16 @@
9190 if (unlikely(ret != -EFAULT))
9291 goto fail;
9392
94
- down_read(&current->mm->mmap_sem);
95
- ret = fixup_user_fault(current, current->mm, (unsigned long) uaddr,
93
+ mmap_read_lock(current->mm);
94
+ ret = fixup_user_fault(current->mm, (unsigned long) uaddr,
9695 FAULT_FLAG_WRITE, NULL);
97
- up_read(&current->mm->mmap_sem);
96
+ mmap_read_unlock(current->mm);
9897
9998 if (likely(!ret))
10099 goto again;
101100
102101 fail:
103
- force_sig(SIGSEGV, current);
102
+ force_sig(SIGSEGV);
104103 return ret;
105104 }
106105
....@@ -115,17 +114,6 @@
115114 "sleep %0 \n"
116115 :
117116 :"I"(arg)); /* can't be "r" has to be embedded const */
118
-}
119
-
120
-#elif defined(CONFIG_EZNPS_MTM_EXT) /* ARC700 variant in NPS */
121
-
122
-void arch_cpu_idle(void)
123
-{
124
- /* only the calling HW thread needs to sleep */
125
- __asm__ __volatile__(
126
- ".word %0 \n"
127
- :
128
- :"i"(CTOP_INST_HWSCHD_WFT_IE12));
129117 }
130118
131119 #else /* ARC700 */
....@@ -174,9 +162,9 @@
174162 * | user_r25 |
175163 * ------------------ <===== END of PAGE
176164 */
177
-int copy_thread(unsigned long clone_flags,
178
- unsigned long usp, unsigned long kthread_arg,
179
- struct task_struct *p)
165
+int copy_thread(unsigned long clone_flags, unsigned long usp,
166
+ unsigned long kthread_arg, struct task_struct *p,
167
+ unsigned long tls)
180168 {
181169 struct pt_regs *c_regs; /* child's pt_regs */
182170 unsigned long *childksp; /* to unwind out of __switch_to() */
....@@ -203,7 +191,7 @@
203191 childksp[0] = 0; /* fp */
204192 childksp[1] = (unsigned long)ret_from_fork; /* blink */
205193
206
- if (unlikely(p->flags & PF_KTHREAD)) {
194
+ if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
207195 memset(c_regs, 0, sizeof(struct pt_regs));
208196
209197 c_callee->r13 = kthread_arg;
....@@ -234,7 +222,7 @@
234222 * set task's userland tls data ptr from 4th arg
235223 * clone C-lib call is difft from clone sys-call
236224 */
237
- task_thread_info(p)->thr_ptr = regs->r3;
225
+ task_thread_info(p)->thr_ptr = tls;
238226 } else {
239227 /* Normal fork case: set parent's TLS ptr in child */
240228 task_thread_info(p)->thr_ptr =
....@@ -267,7 +255,7 @@
267255 /*
268256 * Do necessary setup to start up a new user task
269257 */
270
-void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long usp)
258
+void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp)
271259 {
272260 regs->sp = usp;
273261 regs->ret = pc;
....@@ -279,9 +267,7 @@
279267 */
280268 regs->status32 = STATUS_U_MASK | STATUS_L_MASK | ISA_INIT_STATUS_BITS;
281269
282
-#ifdef CONFIG_EZNPS_MTM_EXT
283
- regs->eflags = 0;
284
-#endif
270
+ fpu_init_task(regs);
285271
286272 /* bogus seed values for debugging */
287273 regs->lp_start = 0x10;
....@@ -293,11 +279,6 @@
293279 */
294280 void flush_thread(void)
295281 {
296
-}
297
-
298
-int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
299
-{
300
- return 0;
301282 }
302283
303284 int elf_check_arch(const struct elf32_hdr *x)
....@@ -313,7 +294,7 @@
313294 eflags = x->e_flags;
314295 if ((eflags & EF_ARC_OSABI_MSK) != EF_ARC_OSABI_CURRENT) {
315296 pr_err("ABI mismatch - you need newer toolchain\n");
316
- force_sigsegv(SIGSEGV, current);
297
+ force_sigsegv(SIGSEGV);
317298 return 0;
318299 }
319300