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