exec.c 1.8 KB
Newer Older
J
Jeff Dike 已提交
1
/*
J
Jeff Dike 已提交
2
 * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
L
Linus Torvalds 已提交
3 4 5
 * Licensed under the GPL
 */

6 7 8 9 10 11 12 13 14
#include <linux/stddef.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/ptrace.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <asm/current.h>
#include <asm/processor.h>
#include <asm/uaccess.h>
15 16 17 18
#include <as-layout.h>
#include <mem_user.h>
#include <skas.h>
#include <os.h>
A
Al Viro 已提交
19
#include "internal.h"
L
Linus Torvalds 已提交
20 21 22

void flush_thread(void)
{
23 24 25
	void *data = NULL;
	int ret;

26
	arch_flush_thread(&current->thread.arch);
27

J
Jeff Dike 已提交
28 29
	ret = unmap(&current->mm->context.id, 0, STUB_START, 0, &data);
	ret = ret || unmap(&current->mm->context.id, STUB_END,
J
Jeff Dike 已提交
30
			   host_task_size - STUB_END, 1, &data);
J
Jeff Dike 已提交
31 32
	if (ret) {
		printk(KERN_ERR "flush_thread - clearing address space failed, "
33 34 35 36
		       "err = %d\n", ret);
		force_sig(SIGKILL, current);
	}

37
	__switch_mm(&current->mm->context.id);
L
Linus Torvalds 已提交
38 39 40 41
}

void start_thread(struct pt_regs *regs, unsigned long eip, unsigned long esp)
{
42
	get_safe_registers(regs->regs.gp, regs->regs.fp);
43 44
	PT_REGS_IP(regs) = eip;
	PT_REGS_SP(regs) = esp;
45
	current->ptrace &= ~PT_DTRACE;
J
Jeff Dike 已提交
46
#ifdef SUBARCH_EXECVE1
47
	SUBARCH_EXECVE1(regs->regs);
J
Jeff Dike 已提交
48
#endif
L
Linus Torvalds 已提交
49
}
50
EXPORT_SYMBOL(start_thread);
L
Linus Torvalds 已提交
51

R
Richard Weinberger 已提交
52
long um_execve(const char *file, const char __user *const __user *argv, const char __user *const __user *env)
L
Linus Torvalds 已提交
53 54 55
{
	long err;

56
	err = do_execve(file, argv, env, &current->thread.regs);
J
Jeff Dike 已提交
57
	if (!err)
J
Jeff Dike 已提交
58
		UML_LONGJMP(current->thread.exec_buf, 1);
J
Jeff Dike 已提交
59
	return err;
L
Linus Torvalds 已提交
60 61
}

R
Richard Weinberger 已提交
62 63
long sys_execve(const char __user *file, const char __user *const __user *argv,
		const char __user *const __user *env)
L
Linus Torvalds 已提交
64 65 66 67
{
	long error;
	char *filename;

A
Al Viro 已提交
68
	filename = getname(file);
L
Linus Torvalds 已提交
69 70
	error = PTR_ERR(filename);
	if (IS_ERR(filename)) goto out;
71
	error = do_execve(filename, argv, env, &current->thread.regs);
L
Linus Torvalds 已提交
72 73
	putname(filename);
 out:
J
Jeff Dike 已提交
74
	return error;
L
Linus Torvalds 已提交
75
}