blob: a43d42bf0a8640f13c39a9d61ca771103d93faab [file] [log] [blame]
Jeff Dike1d3468a2006-07-10 04:45:13 -07001/*
Jeff Dikeba180fd2007-10-16 01:27:00 -07002 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Licensed under the GPL
4 */
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
Jeff Dike39633332008-02-04 22:31:01 -080029 ret = unmap(&current->mm->context.id, 0, STUB_START, 0, &data);
30 ret = ret || unmap(&current->mm->context.id, STUB_END,
Jeff Dike536788f2008-02-08 04:22:07 -080031 host_task_size - STUB_END, 1, &data);
Jeff Dikeba180fd2007-10-16 01:27:00 -070032 if (ret) {
33 printk(KERN_ERR "flush_thread - clearing address space failed, "
Jeff Dike77bf4402007-10-16 01:26:58 -070034 "err = %d\n", ret);
35 force_sig(SIGKILL, current);
36 }
Al Viro9436d5c2012-11-10 01:15:42 -050037 get_safe_registers(current_pt_regs()->regs.gp,
38 current_pt_regs()->regs.fp);
Jeff Dike77bf4402007-10-16 01:26:58 -070039
Jeff Dike6c738ff2007-10-16 01:27:06 -070040 __switch_mm(&current->mm->context.id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070041}
42
43void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
44{
Jeff Dike77bf4402007-10-16 01:26:58 -070045 PT_REGS_IP(regs) = eip;
46 PT_REGS_SP(regs) = esp;
Al Viro42459792012-09-03 03:24:18 -040047 current->ptrace &= ~PT_DTRACE;
48#ifdef SUBARCH_EXECVE1
49 SUBARCH_EXECVE1(regs->regs);
50#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070051}
Al Viro73395a02011-08-18 20:14:10 +010052EXPORT_SYMBOL(start_thread);