blob: 0d7103c9eff3d21c29f15f2f54d5aeabcb0a8449 [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>
10#include <linux/sched.h>
11#include <linux/slab.h>
12#include <asm/current.h>
13#include <asm/processor.h>
14#include <asm/uaccess.h>
Al Viro37185b32012-10-08 03:27:32 +010015#include <as-layout.h>
16#include <mem_user.h>
17#include <skas.h>
18#include <os.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20void flush_thread(void)
21{
Jeff Dike77bf4402007-10-16 01:26:58 -070022 void *data = NULL;
Jeff Dike77bf4402007-10-16 01:26:58 -070023 int ret;
24
Paolo 'Blaisorblade' Giarrussoaa6758d2006-03-31 02:30:22 -080025 arch_flush_thread(&current->thread.arch);
Jeff Dike77bf4402007-10-16 01:26:58 -070026
Jeff Dike39633332008-02-04 22:31:01 -080027 ret = unmap(&current->mm->context.id, 0, STUB_START, 0, &data);
28 ret = ret || unmap(&current->mm->context.id, STUB_END,
Jeff Dike536788f2008-02-08 04:22:07 -080029 host_task_size - STUB_END, 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);
33 force_sig(SIGKILL, current);
34 }
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);