blob: c85e40c72779f461e5d3d01c88818d5481308eca [file] [log] [blame]
Alex Dewar0d1fb0a2019-08-25 10:49:17 +01001// SPDX-License-Identifier: GPL-2.0
Jeff Dike1d3468a2006-07-10 04:45:13 -07002/*
Jeff Dikeba180fd2007-10-16 01:27:00 -07003 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 */
5
Al Viro73395a02011-08-18 20:14:10 +01006#include <linux/stddef.h>
7#include <linux/module.h>
8#include <linux/fs.h>
9#include <linux/ptrace.h>
Ingo Molnar589ee622017-02-04 00:16:44 +010010#include <linux/sched/mm.h>
Ingo Molnar29930022017-02-08 18:51:36 +010011#include <linux/sched/task.h>
Ingo Molnar68db0cf2017-02-08 18:51:37 +010012#include <linux/sched/task_stack.h>
Al Viro73395a02011-08-18 20:14:10 +010013#include <linux/slab.h>
14#include <asm/current.h>
15#include <asm/processor.h>
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080016#include <linux/uaccess.h>
Al Viro37185b32012-10-08 03:27:32 +010017#include <as-layout.h>
18#include <mem_user.h>
Al Virodbba7f72021-09-20 21:32:50 +000019#include <registers.h>
Al Viro37185b32012-10-08 03:27:32 +010020#include <skas.h>
21#include <os.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23void flush_thread(void)
24{
Jeff Dike77bf4402007-10-16 01:26:58 -070025 void *data = NULL;
Jeff Dike77bf4402007-10-16 01:26:58 -070026 int ret;
27
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -080028 arch_flush_thread(&current->thread.arch);
Jeff Dike77bf4402007-10-16 01:26:58 -070029
Johannes Bergbfc58e22021-01-13 22:09:44 +010030 ret = unmap(&current->mm->context.id, 0, TASK_SIZE, 1, &data);
Jeff Dikeba180fd2007-10-16 01:27:00 -070031 if (ret) {
32 printk(KERN_ERR "flush_thread - clearing address space failed, "
Jeff Dike77bf4402007-10-16 01:26:58 -070033 "err = %d\n", ret);
Eric W. Biederman3cf5d072019-05-23 10:17:27 -050034 force_sig(SIGKILL);
Jeff Dike77bf4402007-10-16 01:26:58 -070035 }
Al Viro9436d5c2012-11-10 01:15:42 -050036 get_safe_registers(current_pt_regs()->regs.gp,
37 current_pt_regs()->regs.fp);
Jeff Dike77bf4402007-10-16 01:26:58 -070038
Jeff Dike6c738ff2007-10-16 01:27:06 -070039 __switch_mm(&current->mm->context.id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070040}
41
42void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
43{
Jeff Dike77bf4402007-10-16 01:26:58 -070044 PT_REGS_IP(regs) = eip;
45 PT_REGS_SP(regs) = esp;
Al Viro42459792012-09-03 03:24:18 -040046 current->ptrace &= ~PT_DTRACE;
47#ifdef SUBARCH_EXECVE1
48 SUBARCH_EXECVE1(regs->regs);
49#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
Al Viro73395a02011-08-18 20:14:10 +010051EXPORT_SYMBOL(start_thread);