Jeff Dike | 1d3468a | 2006-07-10 04:45:13 -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 | 73395a0 | 2011-08-18 20:14:10 +0100 | [diff] [blame] | 6 | #include <linux/stddef.h> |
| 7 | #include <linux/module.h> |
| 8 | #include <linux/fs.h> |
| 9 | #include <linux/ptrace.h> |
Ingo Molnar | 589ee62 | 2017-02-04 00:16:44 +0100 | [diff] [blame^] | 10 | #include <linux/sched/mm.h> |
Ingo Molnar | 2993002 | 2017-02-08 18:51:36 +0100 | [diff] [blame] | 11 | #include <linux/sched/task.h> |
Ingo Molnar | 68db0cf | 2017-02-08 18:51:37 +0100 | [diff] [blame] | 12 | #include <linux/sched/task_stack.h> |
Al Viro | 73395a0 | 2011-08-18 20:14:10 +0100 | [diff] [blame] | 13 | #include <linux/slab.h> |
| 14 | #include <asm/current.h> |
| 15 | #include <asm/processor.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 16 | #include <linux/uaccess.h> |
Al Viro | 37185b3 | 2012-10-08 03:27:32 +0100 | [diff] [blame] | 17 | #include <as-layout.h> |
| 18 | #include <mem_user.h> |
| 19 | #include <skas.h> |
| 20 | #include <os.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | |
| 22 | void flush_thread(void) |
| 23 | { |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 24 | void *data = NULL; |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 25 | int ret; |
| 26 | |
Paolo 'Blaisorblade' Giarrusso | aa6758d | 2006-03-31 02:30:22 -0800 | [diff] [blame] | 27 | arch_flush_thread(¤t->thread.arch); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 28 | |
Jeff Dike | 3963333 | 2008-02-04 22:31:01 -0800 | [diff] [blame] | 29 | ret = unmap(¤t->mm->context.id, 0, STUB_START, 0, &data); |
| 30 | ret = ret || unmap(¤t->mm->context.id, STUB_END, |
Jeff Dike | 536788f | 2008-02-08 04:22:07 -0800 | [diff] [blame] | 31 | host_task_size - STUB_END, 1, &data); |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 32 | if (ret) { |
| 33 | printk(KERN_ERR "flush_thread - clearing address space failed, " |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 34 | "err = %d\n", ret); |
| 35 | force_sig(SIGKILL, current); |
| 36 | } |
Al Viro | 9436d5c | 2012-11-10 01:15:42 -0500 | [diff] [blame] | 37 | get_safe_registers(current_pt_regs()->regs.gp, |
| 38 | current_pt_regs()->regs.fp); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 39 | |
Jeff Dike | 6c738ff | 2007-10-16 01:27:06 -0700 | [diff] [blame] | 40 | __switch_mm(¤t->mm->context.id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) |
| 44 | { |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 45 | PT_REGS_IP(regs) = eip; |
| 46 | PT_REGS_SP(regs) = esp; |
Al Viro | 4245979 | 2012-09-03 03:24:18 -0400 | [diff] [blame] | 47 | current->ptrace &= ~PT_DTRACE; |
| 48 | #ifdef SUBARCH_EXECVE1 |
| 49 | SUBARCH_EXECVE1(regs->regs); |
| 50 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | } |
Al Viro | 73395a0 | 2011-08-18 20:14:10 +0100 | [diff] [blame] | 52 | EXPORT_SYMBOL(start_thread); |