hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/arch/ia64/kernel/process.c
....@@ -40,7 +40,6 @@
4040 #include <asm/elf.h>
4141 #include <asm/irq.h>
4242 #include <asm/kexec.h>
43
-#include <asm/pgalloc.h>
4443 #include <asm/processor.h>
4544 #include <asm/sal.h>
4645 #include <asm/switch_to.h>
....@@ -48,12 +47,9 @@
4847 #include <linux/uaccess.h>
4948 #include <asm/unwind.h>
5049 #include <asm/user.h>
50
+#include <asm/xtp.h>
5151
5252 #include "entry.h"
53
-
54
-#ifdef CONFIG_PERFMON
55
-# include <asm/perfmon.h>
56
-#endif
5753
5854 #include "sigframe.h"
5955
....@@ -64,12 +60,13 @@
6460 void (*pm_power_off) (void);
6561 EXPORT_SYMBOL(pm_power_off);
6662
67
-void
63
+static void
6864 ia64_do_show_stack (struct unw_frame_info *info, void *arg)
6965 {
7066 unsigned long ip, sp, bsp;
67
+ const char *loglvl = arg;
7168
72
- printk("\nCall Trace:\n");
69
+ printk("%s\nCall Trace:\n", loglvl);
7370 do {
7471 unw_get_ip(info, &ip);
7572 if (ip == 0)
....@@ -77,22 +74,22 @@
7774
7875 unw_get_sp(info, &sp);
7976 unw_get_bsp(info, &bsp);
80
- printk(" [<%016lx>] %pS\n"
77
+ printk("%s [<%016lx>] %pS\n"
8178 " sp=%016lx bsp=%016lx\n",
82
- ip, (void *)ip, sp, bsp);
79
+ loglvl, ip, (void *)ip, sp, bsp);
8380 } while (unw_unwind(info) >= 0);
8481 }
8582
8683 void
87
-show_stack (struct task_struct *task, unsigned long *sp)
84
+show_stack (struct task_struct *task, unsigned long *sp, const char *loglvl)
8885 {
8986 if (!task)
90
- unw_init_running(ia64_do_show_stack, NULL);
87
+ unw_init_running(ia64_do_show_stack, (void *)loglvl);
9188 else {
9289 struct unw_frame_info info;
9390
9491 unw_init_from_blocked_task(&info, task);
95
- ia64_do_show_stack(&info, NULL);
92
+ ia64_do_show_stack(&info, (void *)loglvl);
9693 }
9794 }
9895
....@@ -150,7 +147,7 @@
150147 ((i == sof - 1) || (i % 3) == 2) ? "\n" : " ");
151148 }
152149 } else
153
- show_stack(NULL, NULL);
150
+ show_stack(NULL, NULL, KERN_DEFAULT);
154151 }
155152
156153 /* local support for deprecated console_print */
....@@ -173,22 +170,14 @@
173170 return;
174171 }
175172
176
-#ifdef CONFIG_PERFMON
177
- if (current->thread.pfm_needs_checking)
178
- /*
179
- * Note: pfm_handle_work() allow us to call it with interrupts
180
- * disabled, and may enable interrupts within the function.
181
- */
182
- pfm_handle_work();
183
-#endif
184
-
185173 /* deal with pending signal delivery */
186
- if (test_thread_flag(TIF_SIGPENDING)) {
174
+ if (test_thread_flag(TIF_SIGPENDING) ||
175
+ test_thread_flag(TIF_NOTIFY_SIGNAL)) {
187176 local_irq_enable(); /* force interrupt enable */
188177 ia64_do_signal(scr, in_syscall);
189178 }
190179
191
- if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME)) {
180
+ if (test_thread_flag(TIF_NOTIFY_RESUME)) {
192181 local_irq_enable(); /* force interrupt enable */
193182 tracehook_notify_resume(&scr->pt);
194183 }
....@@ -251,7 +240,7 @@
251240 if (mark_idle)
252241 (*mark_idle)(1);
253242
254
- safe_halt();
243
+ raw_safe_halt();
255244
256245 if (mark_idle)
257246 (*mark_idle)(0);
....@@ -263,41 +252,15 @@
263252 void
264253 ia64_save_extra (struct task_struct *task)
265254 {
266
-#ifdef CONFIG_PERFMON
267
- unsigned long info;
268
-#endif
269
-
270255 if ((task->thread.flags & IA64_THREAD_DBG_VALID) != 0)
271256 ia64_save_debug_regs(&task->thread.dbr[0]);
272
-
273
-#ifdef CONFIG_PERFMON
274
- if ((task->thread.flags & IA64_THREAD_PM_VALID) != 0)
275
- pfm_save_regs(task);
276
-
277
- info = __this_cpu_read(pfm_syst_info);
278
- if (info & PFM_CPUINFO_SYST_WIDE)
279
- pfm_syst_wide_update_task(task, info, 0);
280
-#endif
281257 }
282258
283259 void
284260 ia64_load_extra (struct task_struct *task)
285261 {
286
-#ifdef CONFIG_PERFMON
287
- unsigned long info;
288
-#endif
289
-
290262 if ((task->thread.flags & IA64_THREAD_DBG_VALID) != 0)
291263 ia64_load_debug_regs(&task->thread.dbr[0]);
292
-
293
-#ifdef CONFIG_PERFMON
294
- if ((task->thread.flags & IA64_THREAD_PM_VALID) != 0)
295
- pfm_load_regs(task);
296
-
297
- info = __this_cpu_read(pfm_syst_info);
298
- if (info & PFM_CPUINFO_SYST_WIDE)
299
- pfm_syst_wide_update_task(task, info, 1);
300
-#endif
301264 }
302265
303266 /*
....@@ -309,7 +272,7 @@
309272 *
310273 * <clone syscall> <some kernel call frames>
311274 * sys_clone :
312
- * do_fork do_fork
275
+ * kernel_clone kernel_clone
313276 * copy_thread copy_thread
314277 *
315278 * This means that the stack layout is as follows:
....@@ -332,9 +295,8 @@
332295 * so there is nothing to worry about.
333296 */
334297 int
335
-copy_thread(unsigned long clone_flags,
336
- unsigned long user_stack_base, unsigned long user_stack_size,
337
- struct task_struct *p)
298
+copy_thread(unsigned long clone_flags, unsigned long user_stack_base,
299
+ unsigned long user_stack_size, struct task_struct *p, unsigned long tls)
338300 {
339301 extern char ia64_ret_from_clone;
340302 struct switch_stack *child_stack, *stack;
....@@ -376,7 +338,7 @@
376338
377339 ia64_drop_fpu(p); /* don't pick up stale state from a CPU's fph */
378340
379
- if (unlikely(p->flags & PF_KTHREAD)) {
341
+ if (unlikely(p->flags & (PF_KTHREAD | PF_IO_WORKER))) {
380342 if (unlikely(!user_stack_base)) {
381343 /* fork_idle() called us */
382344 return 0;
....@@ -415,7 +377,7 @@
415377 rbs_size = stack->ar_bspstore - rbs;
416378 memcpy((void *) child_rbs, (void *) rbs, rbs_size);
417379 if (clone_flags & CLONE_SETTLS)
418
- child_ptregs->r13 = regs->r16; /* see sys_clone2() in entry.S */
380
+ child_ptregs->r13 = tls;
419381 if (user_stack_base) {
420382 child_ptregs->r12 = user_stack_base + user_stack_size - 16;
421383 child_ptregs->ar_bspstore = user_stack_base;
....@@ -432,19 +394,32 @@
432394 */
433395 child_ptregs->cr_ipsr = ((child_ptregs->cr_ipsr | IA64_PSR_BITS_TO_SET)
434396 & ~(IA64_PSR_BITS_TO_CLEAR | IA64_PSR_PP | IA64_PSR_UP));
435
-
436
-#ifdef CONFIG_PERFMON
437
- if (current->thread.pfm_context)
438
- pfm_inherit(p, child_ptregs);
439
-#endif
440397 return retval;
398
+}
399
+
400
+asmlinkage long ia64_clone(unsigned long clone_flags, unsigned long stack_start,
401
+ unsigned long stack_size, unsigned long parent_tidptr,
402
+ unsigned long child_tidptr, unsigned long tls)
403
+{
404
+ struct kernel_clone_args args = {
405
+ .flags = (lower_32_bits(clone_flags) & ~CSIGNAL),
406
+ .pidfd = (int __user *)parent_tidptr,
407
+ .child_tid = (int __user *)child_tidptr,
408
+ .parent_tid = (int __user *)parent_tidptr,
409
+ .exit_signal = (lower_32_bits(clone_flags) & CSIGNAL),
410
+ .stack = stack_start,
411
+ .stack_size = stack_size,
412
+ .tls = tls,
413
+ };
414
+
415
+ return kernel_clone(&args);
441416 }
442417
443418 static void
444419 do_copy_task_regs (struct task_struct *task, struct unw_frame_info *info, void *arg)
445420 {
446421 unsigned long mask, sp, nat_bits = 0, ar_rnat, urbs_end, cfm;
447
- unsigned long uninitialized_var(ip); /* GCC be quiet */
422
+ unsigned long ip;
448423 elf_greg_t *dst = arg;
449424 struct pt_regs *pt;
450425 char nat;
....@@ -514,49 +489,15 @@
514489 }
515490
516491 void
517
-do_dump_task_fpu (struct task_struct *task, struct unw_frame_info *info, void *arg)
518
-{
519
- elf_fpreg_t *dst = arg;
520
- int i;
521
-
522
- memset(dst, 0, sizeof(elf_fpregset_t)); /* don't leak any "random" bits */
523
-
524
- if (unw_unwind_to_user(info) < 0)
525
- return;
526
-
527
- /* f0 is 0.0, f1 is 1.0 */
528
-
529
- for (i = 2; i < 32; ++i)
530
- unw_get_fr(info, i, dst + i);
531
-
532
- ia64_flush_fph(task);
533
- if ((task->thread.flags & IA64_THREAD_FPH_VALID) != 0)
534
- memcpy(dst + 32, task->thread.fph, 96*16);
535
-}
536
-
537
-void
538492 do_copy_regs (struct unw_frame_info *info, void *arg)
539493 {
540494 do_copy_task_regs(current, info, arg);
541495 }
542496
543497 void
544
-do_dump_fpu (struct unw_frame_info *info, void *arg)
545
-{
546
- do_dump_task_fpu(current, info, arg);
547
-}
548
-
549
-void
550498 ia64_elf_core_copy_regs (struct pt_regs *pt, elf_gregset_t dst)
551499 {
552500 unw_init_running(do_copy_regs, dst);
553
-}
554
-
555
-int
556
-dump_fpu (struct pt_regs *pt, elf_fpregset_t dst)
557
-{
558
- unw_init_running(do_dump_fpu, dst);
559
- return 1; /* f0-f31 are always valid so we always return 1 */
560501 }
561502
562503 /*
....@@ -579,15 +520,6 @@
579520 {
580521
581522 ia64_drop_fpu(tsk);
582
-#ifdef CONFIG_PERFMON
583
- /* if needed, stop monitoring and flush state to perfmon context */
584
- if (tsk->thread.pfm_context)
585
- pfm_exit_thread(tsk);
586
-
587
- /* free debug register resources */
588
- if (tsk->thread.flags & IA64_THREAD_DBG_VALID)
589
- pfm_release_debug_registers(tsk);
590
-#endif
591523 }
592524
593525 unsigned long
....@@ -646,14 +578,8 @@
646578
647579 void machine_shutdown(void)
648580 {
649
-#ifdef CONFIG_HOTPLUG_CPU
650
- int cpu;
581
+ smp_shutdown_nonboot_cpus(reboot_cpu);
651582
652
- for_each_online_cpu(cpu) {
653
- if (cpu != smp_processor_id())
654
- cpu_down(cpu);
655
- }
656
-#endif
657583 #ifdef CONFIG_KEXEC
658584 kexec_disable_iosapic();
659585 #endif
....@@ -681,3 +607,4 @@
681607 machine_halt();
682608 }
683609
610
+EXPORT_SYMBOL(ia64_delay_loop);