syscall.c 917 字节
Newer Older
1
/*
J
Jeff Dike 已提交
2
 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 4 5
 * Licensed under the GPL
 */

6 7 8 9
#include <linux/kernel.h>
#include <linux/ptrace.h>
#include <kern_util.h>
#include <sysdep/ptrace.h>
10
#include <sysdep/ptrace_user.h>
11
#include <sysdep/syscalls.h>
12

13
void handle_syscall(struct uml_pt_regs *r)
14 15 16 17
{
	struct pt_regs *regs = container_of(r, struct pt_regs, regs);
	int syscall;

18 19 20 21 22
	/* Initialize the syscall number and default return value. */
	UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
	PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);

	if (syscall_trace_enter(regs))
23
		goto out;
24

25 26 27 28 29
	/* Update the syscall number after orig_ax has potentially been updated
	 * with ptrace.
	 */
	UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp);
	syscall = UPT_SYSCALL_NR(r);
30

31 32 33
	if (syscall >= 0 && syscall <= __NR_syscall_max)
		PT_REGS_SET_SYSCALL_RETURN(regs,
				EXECUTE_SYSCALL(syscall, regs));
34

35
out:
36
	syscall_trace_leave(regs);
37
}