blob: 4d84981003419b7aa8d57de8f8f73238105b26e0 [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>
19#include <skas.h>
20#include <os.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021
22void flush_thread(void)
23{
Jeff Dike77bf4402007-10-16 01:26:58 -070024 void *data = NULL;
Jeff Dike77bf4402007-10-16 01:26:58 -070025 int ret;
26
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -080027 arch_flush_thread(&current->thread.arch);
Jeff Dike77bf4402007-10-16 01:26:58 -070028
Johannes Bergbfc58e22021-01-13 22:09:44 +010029 ret = unmap(&current->mm->context.id, 0, TASK_SIZE, 1, &data);
Jeff Dikeba180fd2007-10-16 01:27:00 -070030 if (ret) {
31 printk(KERN_ERR "flush_thread - clearing address space failed, "
Jeff Dike77bf4402007-10-16 01:26:58 -070032 "err = %d\n", ret);
Eric W. Biederman3cf5d072019-05-23 10:17:27 -050033 force_sig(SIGKILL);
Jeff Dike77bf4402007-10-16 01:26:58 -070034 }
Al Viro9436d5c2012-11-10 01:15:42 -050035 get_safe_registers(current_pt_regs()->regs.gp,
36 current_pt_regs()->regs.fp);
Jeff Dike77bf4402007-10-16 01:26:58 -070037
Jeff Dike6c738ff2007-10-16 01:27:06 -070038 __switch_mm(&current->mm->context.id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039}
40
41void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
42{
Jeff Dike77bf4402007-10-16 01:26:58 -070043 PT_REGS_IP(regs) = eip;
44 PT_REGS_SP(regs) = esp;
Al Viro42459792012-09-03 03:24:18 -040045 current->ptrace &= ~PT_DTRACE;
46#ifdef SUBARCH_EXECVE1
47 SUBARCH_EXECVE1(regs->regs);
48#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070049}
Al Viro73395a02011-08-18 20:14:10 +010050EXPORT_SYMBOL(start_thread);