hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/arch/um/kernel/process.c
....@@ -1,9 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2015 Anton Ivanov (aivanov@{brocade.com,kot-begemot.co.uk})
34 * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
45 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
56 * Copyright 2003 PathScale, Inc.
6
- * Licensed under the GPL
77 */
88
99 #include <linux/stddef.h>
....@@ -25,14 +25,13 @@
2525 #include <linux/threads.h>
2626 #include <linux/tracehook.h>
2727 #include <asm/current.h>
28
-#include <asm/pgtable.h>
2928 #include <asm/mmu_context.h>
3029 #include <linux/uaccess.h>
3130 #include <as-layout.h>
3231 #include <kern_util.h>
3332 #include <os.h>
3433 #include <skas.h>
35
-#include <timer-internal.h>
34
+#include <linux/time-internal.h>
3635
3736 /*
3837 * This is a per-cpu array. A processor only modifies its entry and it only
....@@ -100,9 +99,10 @@
10099
101100 if (need_resched())
102101 schedule();
103
- if (test_thread_flag(TIF_SIGPENDING))
102
+ if (test_thread_flag(TIF_SIGPENDING) ||
103
+ test_thread_flag(TIF_NOTIFY_SIGNAL))
104104 do_signal(regs);
105
- if (test_and_clear_thread_flag(TIF_NOTIFY_RESUME))
105
+ if (test_thread_flag(TIF_NOTIFY_RESUME))
106106 tracehook_notify_resume(regs);
107107 }
108108
....@@ -154,10 +154,10 @@
154154 }
155155
156156 int copy_thread(unsigned long clone_flags, unsigned long sp,
157
- unsigned long arg, struct task_struct * p)
157
+ unsigned long arg, struct task_struct * p, unsigned long tls)
158158 {
159159 void (*handler)(void);
160
- int kthread = current->flags & PF_KTHREAD;
160
+ int kthread = current->flags & (PF_KTHREAD | PF_IO_WORKER);
161161 int ret = 0;
162162
163163 p->thread = (struct thread_struct) INIT_THREAD;
....@@ -188,7 +188,7 @@
188188 * Set a new TLS for the child thread?
189189 */
190190 if (clone_flags & CLONE_SETTLS)
191
- ret = arch_copy_tls(p);
191
+ ret = arch_set_tls(p, tls);
192192 }
193193
194194 return ret;
....@@ -203,11 +203,22 @@
203203 kmalloc_ok = save_kmalloc_ok;
204204 }
205205
206
+static void um_idle_sleep(void)
207
+{
208
+ unsigned long long duration = UM_NSEC_PER_SEC;
209
+
210
+ if (time_travel_mode != TT_MODE_OFF) {
211
+ time_travel_sleep(duration);
212
+ } else {
213
+ os_idle_sleep(duration);
214
+ }
215
+}
216
+
206217 void arch_cpu_idle(void)
207218 {
208219 cpu_tasks[current_thread_info()->cpu].pid = os_getpid();
209
- os_idle_sleep(UM_NSEC_PER_SEC);
210
- local_irq_enable();
220
+ um_idle_sleep();
221
+ raw_local_irq_enable();
211222 }
212223
213224 int __cant_sleep(void) {
....@@ -300,13 +311,12 @@
300311 return count;
301312 }
302313
303
-static const struct file_operations sysemu_proc_fops = {
304
- .owner = THIS_MODULE,
305
- .open = sysemu_proc_open,
306
- .read = seq_read,
307
- .llseek = seq_lseek,
308
- .release = single_release,
309
- .write = sysemu_proc_write,
314
+static const struct proc_ops sysemu_proc_ops = {
315
+ .proc_open = sysemu_proc_open,
316
+ .proc_read = seq_read,
317
+ .proc_lseek = seq_lseek,
318
+ .proc_release = single_release,
319
+ .proc_write = sysemu_proc_write,
310320 };
311321
312322 int __init make_proc_sysemu(void)
....@@ -315,7 +325,7 @@
315325 if (!sysemu_supported)
316326 return 0;
317327
318
- ent = proc_create("sysemu", 0600, NULL, &sysemu_proc_fops);
328
+ ent = proc_create("sysemu", 0600, NULL, &sysemu_proc_ops);
319329
320330 if (ent == NULL)
321331 {
....@@ -332,7 +342,7 @@
332342 {
333343 struct task_struct *task = t ? t : current;
334344
335
- if (!(task->ptrace & PT_DTRACE))
345
+ if (!test_thread_flag(TIF_SINGLESTEP))
336346 return 0;
337347
338348 if (task->thread.singlestep_syscall)