Alex Dewar | 0d1fb0a | 2019-08-25 10:49:17 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Jeff Dike | 1d3468a | 2006-07-10 04:45:13 -0700 | [diff] [blame] | 2 | /* |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 3 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Al Viro | dbba7f7 | 2021-09-20 21:32:50 +0000 | [diff] [blame] | 19 | #include <registers.h> |
Al Viro | 37185b3 | 2012-10-08 03:27:32 +0100 | [diff] [blame] | 20 | #include <skas.h> |
| 21 | #include <os.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | |
| 23 | void flush_thread(void) |
| 24 | { |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 25 | void *data = NULL; |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 26 | int ret; |
| 27 | |
Paolo 'Blaisorblade' Giarrusso | aa6758d | 2006-03-31 02:30:22 -0800 | [diff] [blame] | 28 | arch_flush_thread(¤t->thread.arch); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 29 | |
Johannes Berg | bfc58e2 | 2021-01-13 22:09:44 +0100 | [diff] [blame] | 30 | ret = unmap(¤t->mm->context.id, 0, TASK_SIZE, 1, &data); |
Jeff Dike | ba180fd | 2007-10-16 01:27:00 -0700 | [diff] [blame] | 31 | if (ret) { |
| 32 | printk(KERN_ERR "flush_thread - clearing address space failed, " |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 33 | "err = %d\n", ret); |
Eric W. Biederman | 3cf5d07 | 2019-05-23 10:17:27 -0500 | [diff] [blame] | 34 | force_sig(SIGKILL); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 35 | } |
Al Viro | 9436d5c | 2012-11-10 01:15:42 -0500 | [diff] [blame] | 36 | get_safe_registers(current_pt_regs()->regs.gp, |
| 37 | current_pt_regs()->regs.fp); |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 38 | |
Jeff Dike | 6c738ff | 2007-10-16 01:27:06 -0700 | [diff] [blame] | 39 | __switch_mm(¤t->mm->context.id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp) |
| 43 | { |
Jeff Dike | 77bf440 | 2007-10-16 01:26:58 -0700 | [diff] [blame] | 44 | PT_REGS_IP(regs) = eip; |
| 45 | PT_REGS_SP(regs) = esp; |
Al Viro | 4245979 | 2012-09-03 03:24:18 -0400 | [diff] [blame] | 46 | current->ptrace &= ~PT_DTRACE; |
| 47 | #ifdef SUBARCH_EXECVE1 |
| 48 | SUBARCH_EXECVE1(regs->regs); |
| 49 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | } |
Al Viro | 73395a0 | 2011-08-18 20:14:10 +0100 | [diff] [blame] | 51 | EXPORT_SYMBOL(start_thread); |