Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Licensed under the GPL |
4 | */ | ||||
5 | |||||
Ingo Molnar | 3f07c01 | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 6 | #include <linux/sched/signal.h> |
Ingo Molnar | 2993002 | 2017-02-08 18:51:36 +0100 | [diff] [blame] | 7 | #include <linux/sched/task.h> |
Al Viro | 37185b3 | 2012-10-08 03:27:32 +0100 | [diff] [blame] | 8 | #include <linux/spinlock.h> |
9 | #include <linux/slab.h> | ||||
10 | #include <linux/oom.h> | ||||
11 | #include <kern_util.h> | ||||
12 | #include <os.h> | ||||
13 | #include <skas.h> | ||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | |
Eric W. Biederman | 5e38291 | 2006-01-08 01:03:46 -0800 | [diff] [blame] | 15 | void (*pm_power_off)(void); |
Richard Weinberger | 0834f9c | 2016-01-25 23:24:21 +0100 | [diff] [blame] | 16 | EXPORT_SYMBOL(pm_power_off); |
Eric W. Biederman | 5e38291 | 2006-01-08 01:03:46 -0800 | [diff] [blame] | 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | static void kill_off_processes(void) |
19 | { | ||||
Richard Weinberger | d0b5e15 | 2015-03-18 21:31:27 +0100 | [diff] [blame] | 20 | struct task_struct *p; |
21 | int pid; | ||||
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 22 | |
Richard Weinberger | d0b5e15 | 2015-03-18 21:31:27 +0100 | [diff] [blame] | 23 | read_lock(&tasklist_lock); |
24 | for_each_process(p) { | ||||
25 | struct task_struct *t; | ||||
Anton Vorontsov | 2c922c5 | 2012-05-31 16:26:26 -0700 | [diff] [blame] | 26 | |
Richard Weinberger | d0b5e15 | 2015-03-18 21:31:27 +0100 | [diff] [blame] | 27 | t = find_lock_task_mm(p); |
28 | if (!t) | ||||
29 | continue; | ||||
30 | pid = t->mm->context.id.u.pid; | ||||
31 | task_unlock(t); | ||||
32 | os_kill_ptraced_process(pid, 1); | ||||
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 33 | } |
Richard Weinberger | d0b5e15 | 2015-03-18 21:31:27 +0100 | [diff] [blame] | 34 | read_unlock(&tasklist_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | } |
36 | |||||
37 | void uml_cleanup(void) | ||||
38 | { | ||||
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 39 | kmalloc_ok = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | do_uml_exitcalls(); |
Jeff Dike | 026549d2 | 2005-06-25 14:55:23 -0700 | [diff] [blame] | 41 | kill_off_processes(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | } |
43 | |||||
44 | void machine_restart(char * __unused) | ||||
45 | { | ||||
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 46 | uml_cleanup(); |
Jeff Dike | 6aa802c | 2007-10-16 01:26:56 -0700 | [diff] [blame] | 47 | reboot_skas(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | } |
49 | |||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | void machine_power_off(void) |
51 | { | ||||
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 52 | uml_cleanup(); |
Jeff Dike | 6aa802c | 2007-10-16 01:26:56 -0700 | [diff] [blame] | 53 | halt_skas(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | } |
55 | |||||
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | void machine_halt(void) |
57 | { | ||||
58 | machine_power_off(); | ||||
59 | } |