0d1fb0a47c09b arch/um/kernel/process.c (Alex Dewar 2019-08-25 10:49:17 +0100 1) // SPDX-License-Identifier: GPL-2.0
995473aec0be1 arch/um/kernel/process.c (Jeff Dike 2006-09-27 01:50:40 -0700 2) /*
2eb5f31bc4ea2 arch/um/kernel/process.c (Anton Ivanov 2015-11-02 16:16:37 +0000 3) * Copyright (C) 2015 Anton Ivanov (aivanov@{brocade.com,kot-begemot.co.uk})
2eb5f31bc4ea2 arch/um/kernel/process.c (Anton Ivanov 2015-11-02 16:16:37 +0000 4) * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 5) * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 6) * Copyright 2003 PathScale, Inc.
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 7) */
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 8)
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 9) #include <linux/stddef.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 10) #include <linux/err.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 11) #include <linux/hardirq.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 12) #include <linux/mm.h>
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 13) #include <linux/module.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 14) #include <linux/personality.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 15) #include <linux/proc_fs.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 16) #include <linux/ptrace.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 17) #include <linux/random.h>
5a0e3ad6af866 arch/um/kernel/process.c (Tejun Heo 2010-03-24 17:04:11 +0900 18) #include <linux/slab.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 19) #include <linux/sched.h>
b17b01533b719 arch/um/kernel/process.c (Ingo Molnar 2017-02-08 18:51:35 +0100 20) #include <linux/sched/debug.h>
299300258d1bc arch/um/kernel/process.c (Ingo Molnar 2017-02-08 18:51:36 +0100 21) #include <linux/sched/task.h>
68db0cf106786 arch/um/kernel/process.c (Ingo Molnar 2017-02-08 18:51:37 +0100 22) #include <linux/sched/task_stack.h>
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 23) #include <linux/seq_file.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 24) #include <linux/tick.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 25) #include <linux/threads.h>
d50349b0c3974 arch/um/kernel/process.c (Al Viro 2012-04-24 02:37:07 -0400 26) #include <linux/tracehook.h>
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 27) #include <asm/current.h>
445c5786c9ce0 arch/um/kernel/process.c (Al Viro 2011-08-18 20:07:59 +0100 28) #include <asm/mmu_context.h>
7c0f6ba682b9c arch/um/kernel/process.c (Linus Torvalds 2016-12-24 11:46:01 -0800 29) #include <linux/uaccess.h>
37185b3324087 arch/um/kernel/process.c (Al Viro 2012-10-08 03:27:32 +0100 30) #include <as-layout.h>
37185b3324087 arch/um/kernel/process.c (Al Viro 2012-10-08 03:27:32 +0100 31) #include <kern_util.h>
37185b3324087 arch/um/kernel/process.c (Al Viro 2012-10-08 03:27:32 +0100 32) #include <os.h>
37185b3324087 arch/um/kernel/process.c (Al Viro 2012-10-08 03:27:32 +0100 33) #include <skas.h>
f185063bff914 arch/um/kernel/process.c (Johannes Berg 2020-02-13 14:26:44 +0100 34) #include <linux/time-internal.h>
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 35)
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 36) /*
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 37) * This is a per-cpu array. A processor only modifies its entry and it only
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 38) * cares about its entry, so it's OK if another processor is modifying its
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 39) * entry.
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 40) */
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 41) struct cpu_task cpu_tasks[NR_CPUS] = { [0 ... NR_CPUS - 1] = { -1, NULL } };
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 42)
2dc5802a22d68 arch/um/kernel/process.c (Karol Swietlicki 2008-02-04 22:31:03 -0800 43) static inline int external_pid(void)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 44) {
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 45) /* FIXME: Need to look up userspace_pid by cpu */
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 46) return userspace_pid[0];
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 47) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 48)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 49) int pid_to_processor_id(int pid)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 50) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 51) int i;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 52)
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 53) for (i = 0; i < ncpus; i++) {
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 54) if (cpu_tasks[i].pid == pid)
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 55) return i;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 56) }
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 57) return -1;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 58) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 59)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 60) void free_stack(unsigned long stack, int order)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 61) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 62) free_pages(stack, order);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 63) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 64)
2fcb4090cd735 arch/um/kernel/process.c (Johannes Berg 2021-01-10 19:05:08 +0100 65) unsigned long alloc_stack(int order, int atomic)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 66) {
2fcb4090cd735 arch/um/kernel/process.c (Johannes Berg 2021-01-10 19:05:08 +0100 67) unsigned long page;
53f9fc93f90a4 arch/um/kernel/process_kern.c (Al Viro 2005-10-21 03:22:24 -0400 68) gfp_t flags = GFP_KERNEL;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 69)
46db4a42dd119 arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2005-09-22 21:44:20 -0700 70) if (atomic)
46db4a42dd119 arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2005-09-22 21:44:20 -0700 71) flags = GFP_ATOMIC;
2fcb4090cd735 arch/um/kernel/process.c (Johannes Berg 2021-01-10 19:05:08 +0100 72) page = __get_free_pages(flags, order);
5c8aaceab88ac arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:46 -0700 73)
2fcb4090cd735 arch/um/kernel/process.c (Johannes Berg 2021-01-10 19:05:08 +0100 74) return page;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 75) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 76)
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 77) static inline void set_current(struct task_struct *task)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 78) {
ca9bc0bb2d1c7 arch/um/kernel/process_kern.c (Al Viro 2006-01-12 01:05:48 -0800 79) cpu_tasks[task_thread_info(task)->cpu] = ((struct cpu_task)
2dc5802a22d68 arch/um/kernel/process.c (Karol Swietlicki 2008-02-04 22:31:03 -0800 80) { external_pid(), task });
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 81) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 82)
291248fd6e371 arch/um/kernel/process.c (Karol Swietlicki 2008-02-04 22:30:49 -0800 83) extern void arch_switch_to(struct task_struct *to);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 84)
76b278edd99fb arch/um/kernel/process.c (Richard Weinberger 2012-03-29 19:10:42 +0200 85) void *__switch_to(struct task_struct *from, struct task_struct *to)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 86) {
995473aec0be1 arch/um/kernel/process.c (Jeff Dike 2006-09-27 01:50:40 -0700 87) to->thread.prev_sched = from;
995473aec0be1 arch/um/kernel/process.c (Jeff Dike 2006-09-27 01:50:40 -0700 88) set_current(to);
f6e34c6af6f18 arch/um/kernel/process_kern.c (Jeff Dike 2005-09-16 19:27:43 -0700 89)
a1850e9c7282d arch/um/kernel/process.c (Richard Weinberger 2013-09-23 17:38:03 +0200 90) switch_threads(&from->thread.switch_buf, &to->thread.switch_buf);
a1850e9c7282d arch/um/kernel/process.c (Richard Weinberger 2013-09-23 17:38:03 +0200 91) arch_switch_to(current);
f6e34c6af6f18 arch/um/kernel/process_kern.c (Jeff Dike 2005-09-16 19:27:43 -0700 92)
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 93) return current->thread.prev_sched;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 94) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 95)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 96) void interrupt_end(void)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 97) {
ccaee5f851470 arch/um/kernel/process.c (Ingo Molnar 2015-07-03 12:44:20 -0700 98) struct pt_regs *regs = ¤t->thread.regs;
ccaee5f851470 arch/um/kernel/process.c (Ingo Molnar 2015-07-03 12:44:20 -0700 99)
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 100) if (need_resched())
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 101) schedule();
09041c92f0aac arch/um/kernel/process.c (Jens Axboe 2020-10-29 10:23:12 -0600 102) if (test_thread_flag(TIF_SIGPENDING) ||
09041c92f0aac arch/um/kernel/process.c (Jens Axboe 2020-10-29 10:23:12 -0600 103) test_thread_flag(TIF_NOTIFY_SIGNAL))
ccaee5f851470 arch/um/kernel/process.c (Ingo Molnar 2015-07-03 12:44:20 -0700 104) do_signal(regs);
3c532798ec96b arch/um/kernel/process.c (Jens Axboe 2020-10-03 10:49:22 -0600 105) if (test_thread_flag(TIF_NOTIFY_RESUME))
ccaee5f851470 arch/um/kernel/process.c (Ingo Molnar 2015-07-03 12:44:20 -0700 106) tracehook_notify_resume(regs);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 107) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 108)
c2220b2a124d2 arch/um/kernel/process.c (Al Viro 2012-01-30 16:30:48 -0500 109) int get_current_pid(void)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 110) {
c2220b2a124d2 arch/um/kernel/process.c (Al Viro 2012-01-30 16:30:48 -0500 111) return task_pid_nr(current);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 112) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 113)
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 114) /*
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 115) * This is called magically, by its address being stuffed in a jmp_buf
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 116) * and being longjmp-d to.
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 117) */
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 118) void new_thread_handler(void)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 119) {
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 120) int (*fn)(void *), n;
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 121) void *arg;
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 122)
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 123) if (current->thread.prev_sched != NULL)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 124) schedule_tail(current->thread.prev_sched);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 125) current->thread.prev_sched = NULL;
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 126)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 127) fn = current->thread.request.u.thread.proc;
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 128) arg = current->thread.request.u.thread.arg;
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 129)
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 130) /*
22e2430d60dbd arch/um/kernel/process.c (Al Viro 2012-10-10 21:35:42 -0400 131) * callback returns only if the kernel thread execs a process
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 132) */
22e2430d60dbd arch/um/kernel/process.c (Al Viro 2012-10-10 21:35:42 -0400 133) n = fn(arg);
6f602afda7275 arch/um/kernel/process.c (Thomas Meyer 2017-07-29 17:03:23 +0200 134) userspace(¤t->thread.regs.regs, current_thread_info()->aux_fp_regs);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 135) }
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 136)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 137) /* Called magically, see new_thread_handler above */
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 138) void fork_handler(void)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 139) {
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 140) force_flush_all();
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 141)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 142) schedule_tail(current->thread.prev_sched);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 143)
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 144) /*
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 145) * XXX: if interrupt_end() calls schedule, this call to
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 146) * arch_switch_to isn't needed. We could want to apply this to
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 147) * improve performance. -bb
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 148) */
291248fd6e371 arch/um/kernel/process.c (Karol Swietlicki 2008-02-04 22:30:49 -0800 149) arch_switch_to(current);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 150)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 151) current->thread.prev_sched = NULL;
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 152)
6f602afda7275 arch/um/kernel/process.c (Thomas Meyer 2017-07-29 17:03:23 +0200 153) userspace(¤t->thread.regs.regs, current_thread_info()->aux_fp_regs);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 154) }
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 155)
714acdbd1c94e arch/um/kernel/process.c (Christian Brauner 2020-06-11 11:04:15 +0200 156) int copy_thread(unsigned long clone_flags, unsigned long sp,
457677c70c767 arch/um/kernel/process.c (Amanieu d'Antras 2020-01-04 13:39:30 +0100 157) unsigned long arg, struct task_struct * p, unsigned long tls)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 158) {
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 159) void (*handler)(void);
4727dc20e0422 arch/um/kernel/process.c (Jens Axboe 2021-02-17 08:48:00 -0700 160) int kthread = current->flags & (PF_KTHREAD | PF_IO_WORKER);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 161) int ret = 0;
aa6758d4867cd arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-03-31 02:30:22 -0800 162)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 163) p->thread = (struct thread_struct) INIT_THREAD;
aa6758d4867cd arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-03-31 02:30:22 -0800 164)
d2ce4e92fa4f7 arch/um/kernel/process.c (Al Viro 2012-09-20 09:28:25 -0400 165) if (!kthread) {
2b067fc9dd143 arch/um/kernel/process.c (Al Viro 2012-10-29 21:36:45 -0400 166) memcpy(&p->thread.regs.regs, current_pt_regs(),
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 167) sizeof(p->thread.regs.regs));
a3170d2ec25f8 arch/um/kernel/process.c (Al Viro 2012-05-22 21:16:35 -0400 168) PT_REGS_SET_SYSCALL_RETURN(&p->thread.regs, 0);
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 169) if (sp != 0)
18badddaa84e1 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:07 -0700 170) REGS_SP(p->thread.regs.regs.gp) = sp;
aa6758d4867cd arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-03-31 02:30:22 -0800 171)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 172) handler = fork_handler;
aa6758d4867cd arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-03-31 02:30:22 -0800 173)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 174) arch_copy_thread(¤t->thread.arch, &p->thread.arch);
d2ce4e92fa4f7 arch/um/kernel/process.c (Al Viro 2012-09-20 09:28:25 -0400 175) } else {
fbfe9c847edf5 arch/um/kernel/process.c (Ingo van Lil 2011-09-14 16:21:23 -0700 176) get_safe_registers(p->thread.regs.regs.gp, p->thread.regs.regs.fp);
1f02ab4a23708 arch/um/kernel/process.c (Al Viro 2012-09-21 20:32:29 -0400 177) p->thread.request.u.thread.proc = (int (*)(void *))sp;
1f02ab4a23708 arch/um/kernel/process.c (Al Viro 2012-09-21 20:32:29 -0400 178) p->thread.request.u.thread.arg = (void *)arg;
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 179) handler = new_thread_handler;
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 180) }
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 181)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 182) new_thread(task_stack_page(p), &p->thread.switch_buf, handler);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 183)
d2ce4e92fa4f7 arch/um/kernel/process.c (Al Viro 2012-09-20 09:28:25 -0400 184) if (!kthread) {
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 185) clear_flushed_tls(p);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 186)
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 187) /*
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 188) * Set a new TLS for the child thread?
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 189) */
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 190) if (clone_flags & CLONE_SETTLS)
457677c70c767 arch/um/kernel/process.c (Amanieu d'Antras 2020-01-04 13:39:30 +0100 191) ret = arch_set_tls(p, tls);
77bf4400319db arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:58 -0700 192) }
aa6758d4867cd arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-03-31 02:30:22 -0800 193)
aa6758d4867cd arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-03-31 02:30:22 -0800 194) return ret;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 195) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 196)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 197) void initial_thread_cb(void (*proc)(void *), void *arg)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 198) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 199) int save_kmalloc_ok = kmalloc_ok;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 200)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 201) kmalloc_ok = 0;
6aa802ce6acc9 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:26:56 -0700 202) initial_thread_cb_skas(proc, arg);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 203) kmalloc_ok = save_kmalloc_ok;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 204) }
995473aec0be1 arch/um/kernel/process.c (Jeff Dike 2006-09-27 01:50:40 -0700 205)
a374b7cb1ea64 arch/um/kernel/process.c (Johannes Berg 2020-12-02 20:58:07 +0100 206) void um_idle_sleep(void)
065038706f77a arch/um/kernel/process.c (Johannes Berg 2019-05-27 10:34:27 +0200 207) {
49da38a3ef330 arch/um/kernel/process.c (Johannes Berg 2020-12-02 20:58:04 +0100 208) if (time_travel_mode != TT_MODE_OFF)
49da38a3ef330 arch/um/kernel/process.c (Johannes Berg 2020-12-02 20:58:04 +0100 209) time_travel_sleep();
49da38a3ef330 arch/um/kernel/process.c (Johannes Berg 2020-12-02 20:58:04 +0100 210) else
49da38a3ef330 arch/um/kernel/process.c (Johannes Berg 2020-12-02 20:58:04 +0100 211) os_idle_sleep();
065038706f77a arch/um/kernel/process.c (Johannes Berg 2019-05-27 10:34:27 +0200 212) }
065038706f77a arch/um/kernel/process.c (Johannes Berg 2019-05-27 10:34:27 +0200 213)
8198c1696a2cd arch/um/kernel/process.c (Richard Weinberger 2013-04-16 23:53:29 +0200 214) void arch_cpu_idle(void)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 215) {
a5a678c80beac arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:54 -0800 216) cpu_tasks[current_thread_info()->cpu].pid = os_getpid();
065038706f77a arch/um/kernel/process.c (Johannes Berg 2019-05-27 10:34:27 +0200 217) um_idle_sleep();
58c644ba512cf arch/um/kernel/process.c (Peter Zijlstra 2020-11-20 11:50:35 +0100 218) raw_local_irq_enable();
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 219) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 220)
b63162939cd79 arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-01-18 17:42:58 -0800 221) int __cant_sleep(void) {
b63162939cd79 arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-01-18 17:42:58 -0800 222) return in_atomic() || irqs_disabled() || in_interrupt();
b63162939cd79 arch/um/kernel/process_kern.c (Paolo 'Blaisorblade' Giarrusso 2006-01-18 17:42:58 -0800 223) /* Is in_interrupt() really needed? */
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 224) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 225)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 226) int user_context(unsigned long sp)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 227) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 228) unsigned long stack;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 229)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 230) stack = sp & (PAGE_MASK << CONFIG_KERNEL_STACK_ORDER);
a5a678c80beac arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:54 -0800 231) return stack != (unsigned long) current_thread_info();
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 232) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 233)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 234) extern exitcall_t __uml_exitcall_begin, __uml_exitcall_end;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 235)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 236) void do_uml_exitcalls(void)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 237) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 238) exitcall_t *call;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 239)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 240) call = &__uml_exitcall_end;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 241) while (--call >= &__uml_exitcall_begin)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 242) (*call)();
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 243) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 244)
c0a9290ecf0db arch/um/kernel/process.c (WANG Cong 2008-02-04 22:30:41 -0800 245) char *uml_strdup(const char *string)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 246) {
dfe52244e004f arch/um/kernel/process_kern.c (Robert Love 2005-06-23 00:09:04 -0700 247) return kstrdup(string, GFP_KERNEL);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 248) }
73395a0002aa9 arch/um/kernel/process.c (Al Viro 2011-08-18 20:14:10 +0100 249) EXPORT_SYMBOL(uml_strdup);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 250)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 251) int copy_to_user_proc(void __user *to, void *from, int size)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 252) {
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 253) return copy_to_user(to, from, size);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 254) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 255)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 256) int copy_from_user_proc(void *to, void __user *from, int size)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 257) {
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 258) return copy_from_user(to, from, size);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 259) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 260)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 261) int clear_user_proc(void __user *buf, int size)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 262) {
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 263) return clear_user(buf, size);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 264) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 265)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 266) int cpu(void)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 267) {
a5a678c80beac arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:54 -0800 268) return current_thread_info()->cpu;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 269) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 270)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 271) static atomic_t using_sysemu = ATOMIC_INIT(0);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 272) int sysemu_supported;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 273)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 274) void set_using_sysemu(int value)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 275) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 276) if (value > sysemu_supported)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 277) return;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 278) atomic_set(&using_sysemu, value);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 279) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 280)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 281) int get_using_sysemu(void)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 282) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 283) return atomic_read(&using_sysemu);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 284) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 285)
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 286) static int sysemu_proc_show(struct seq_file *m, void *v)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 287) {
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 288) seq_printf(m, "%d\n", get_using_sysemu());
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 289) return 0;
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 290) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 291)
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 292) static int sysemu_proc_open(struct inode *inode, struct file *file)
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 293) {
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 294) return single_open(file, sysemu_proc_show, NULL);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 295) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 296)
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 297) static ssize_t sysemu_proc_write(struct file *file, const char __user *buf,
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 298) size_t count, loff_t *pos)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 299) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 300) char tmp[2];
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 301)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 302) if (copy_from_user(tmp, buf, 1))
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 303) return -EFAULT;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 304)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 305) if (tmp[0] >= '0' && tmp[0] <= '2')
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 306) set_using_sysemu(tmp[0] - '0');
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 307) /* We use the first char, but pretend to write everything */
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 308) return count;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 309) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 310)
97a32539b9568 arch/um/kernel/process.c (Alexey Dobriyan 2020-02-03 17:37:17 -0800 311) static const struct proc_ops sysemu_proc_ops = {
97a32539b9568 arch/um/kernel/process.c (Alexey Dobriyan 2020-02-03 17:37:17 -0800 312) .proc_open = sysemu_proc_open,
97a32539b9568 arch/um/kernel/process.c (Alexey Dobriyan 2020-02-03 17:37:17 -0800 313) .proc_read = seq_read,
97a32539b9568 arch/um/kernel/process.c (Alexey Dobriyan 2020-02-03 17:37:17 -0800 314) .proc_lseek = seq_lseek,
97a32539b9568 arch/um/kernel/process.c (Alexey Dobriyan 2020-02-03 17:37:17 -0800 315) .proc_release = single_release,
97a32539b9568 arch/um/kernel/process.c (Alexey Dobriyan 2020-02-03 17:37:17 -0800 316) .proc_write = sysemu_proc_write,
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 317) };
6613c5e8603bc arch/um/kernel/process.c (Alexey Dobriyan 2009-12-14 18:00:11 -0800 318)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 319) int __init make_proc_sysemu(void)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 320) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 321) struct proc_dir_entry *ent;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 322) if (!sysemu_supported)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 323) return 0;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 324)
97a32539b9568 arch/um/kernel/process.c (Alexey Dobriyan 2020-02-03 17:37:17 -0800 325) ent = proc_create("sysemu", 0600, NULL, &sysemu_proc_ops);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 326)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 327) if (ent == NULL)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 328) {
30f417c65e151 arch/um/kernel/process_kern.c (Christophe Lucas 2005-07-28 21:16:12 -0700 329) printk(KERN_WARNING "Failed to register /proc/sysemu\n");
6e21aec3fcf6c arch/um/kernel/process.c (Jeff Dike 2007-05-06 14:51:21 -0700 330) return 0;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 331) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 332)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 333) return 0;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 334) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 335)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 336) late_initcall(make_proc_sysemu);
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 337)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 338) int singlestepping(void * t)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 339) {
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 340) struct task_struct *task = t ? t : current;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 341)
c5d4bb171cab1 arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:31:14 -0800 342) if (!(task->ptrace & PT_DTRACE))
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 343) return 0;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 344)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 345) if (task->thread.singlestep_syscall)
ba180fd437156 arch/um/kernel/process.c (Jeff Dike 2007-10-16 01:27:00 -0700 346) return 1;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 347)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 348) return 2;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 349) }
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 350)
b8bd0220c1ac6 arch/um/kernel/process_kern.c (Bodo Stroesser 2005-05-06 21:30:53 -0700 351) /*
b8bd0220c1ac6 arch/um/kernel/process_kern.c (Bodo Stroesser 2005-05-06 21:30:53 -0700 352) * Only x86 and x86_64 have an arch_align_stack().
b8bd0220c1ac6 arch/um/kernel/process_kern.c (Bodo Stroesser 2005-05-06 21:30:53 -0700 353) * All other arches have "#define arch_align_stack(x) (x)"
cf7bc58f6dd4f arch/um/kernel/process.c (David Howells 2014-04-07 15:39:22 -0700 354) * in their asm/exec.h
b8bd0220c1ac6 arch/um/kernel/process_kern.c (Bodo Stroesser 2005-05-06 21:30:53 -0700 355) * As this is included in UML from asm-um/system-generic.h,
b8bd0220c1ac6 arch/um/kernel/process_kern.c (Bodo Stroesser 2005-05-06 21:30:53 -0700 356) * we can use it to behave as the subarch does.
b8bd0220c1ac6 arch/um/kernel/process_kern.c (Bodo Stroesser 2005-05-06 21:30:53 -0700 357) */
b8bd0220c1ac6 arch/um/kernel/process_kern.c (Bodo Stroesser 2005-05-06 21:30:53 -0700 358) #ifndef arch_align_stack
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 359) unsigned long arch_align_stack(unsigned long sp)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 360) {
8f80e9466e182 arch/um/kernel/process_kern.c (Jeff Dike 2006-09-25 23:33:01 -0700 361) if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 362) sp -= get_random_int() % 8192;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 363) return sp & ~0xf;
^1da177e4c3f4 arch/um/kernel/process_kern.c (Linus Torvalds 2005-04-16 15:20:36 -0700 364) }
b8bd0220c1ac6 arch/um/kernel/process_kern.c (Bodo Stroesser 2005-05-06 21:30:53 -0700 365) #endif
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 366)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 367) unsigned long get_wchan(struct task_struct *p)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 368) {
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 369) unsigned long stack_page, sp, ip;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 370) bool seen_sched = 0;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 371)
b03fbd4ff24c5 arch/um/kernel/process.c (Peter Zijlstra 2021-06-11 10:28:12 +0200 372) if ((p == NULL) || (p == current) || task_is_running(p))
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 373) return 0;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 374)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 375) stack_page = (unsigned long) task_stack_page(p);
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 376) /* Bail if the process has no kernel stack for some reason */
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 377) if (stack_page == 0)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 378) return 0;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 379)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 380) sp = p->thread.switch_buf->JB_SP;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 381) /*
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 382) * Bail if the stack pointer is below the bottom of the kernel
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 383) * stack for some reason
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 384) */
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 385) if (sp < stack_page)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 386) return 0;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 387)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 388) while (sp < stack_page + THREAD_SIZE) {
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 389) ip = *((unsigned long *) sp);
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 390) if (in_sched_functions(ip))
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 391) /* Ignore everything until we're above the scheduler */
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 392) seen_sched = 1;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 393) else if (kernel_text_address(ip) && seen_sched)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 394) return ip;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 395)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 396) sp += sizeof(unsigned long);
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 397) }
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 398)
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 399) return 0;
c11274655558e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:36 -0800 400) }
8192ab42bf60e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:53 -0800 401)
8192ab42bf60e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:53 -0800 402) int elf_core_copy_fpregs(struct task_struct *t, elf_fpregset_t *fpu)
8192ab42bf60e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:53 -0800 403) {
8192ab42bf60e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:53 -0800 404) int cpu = current_thread_info()->cpu;
8192ab42bf60e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:53 -0800 405)
a78ff1112263f arch/um/kernel/process.c (Eli Cooper 2016-03-20 00:58:41 +0800 406) return save_i387_registers(userspace_pid[cpu], (unsigned long *) fpu);
8192ab42bf60e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:53 -0800 407) }
8192ab42bf60e arch/um/kernel/process.c (Jeff Dike 2008-02-04 22:30:53 -0800 408)