Skip to content

Commit e32dacb

Browse files
cfd-36Linus Torvalds
authored andcommitted
[PATCH] uml: system call path cleanup
This merges two sets of files which had no business being split apart in the first place. Signed-off-by: Jeff Dike <jdike@addtoit.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 08964c5 commit e32dacb

13 files changed

Lines changed: 131 additions & 215 deletions

File tree

‎arch/um/include/syscall.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3+
* Licensed under the GPL
4+
*/
5+
6+
#ifndef __SYSCALL_USER_H
7+
#define __SYSCALL_USER_H
8+
9+
extern int record_syscall_start(int syscall);
10+
extern void record_syscall_end(int index, long result);
11+
12+
#endif

‎arch/um/include/syscall_user.h‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎arch/um/include/sysdep-i386/syscalls.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ extern syscall_handler_t sys_rt_sigaction;
1616

1717
extern syscall_handler_t old_mmap_i386;
1818

19+
extern syscall_handler_t *sys_call_table[];
20+
1921
#define EXECUTE_SYSCALL(syscall, regs) \
2022
((long (*)(struct syscall_args)) (*sys_call_table[syscall]))(SYSCALL_ARGS(&regs->regs))
2123

‎arch/um/include/sysdep-x86_64/syscalls.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ typedef long syscall_handler_t(void);
1414

1515
extern syscall_handler_t *ia32_sys_call_table[];
1616

17+
extern syscall_handler_t *sys_call_table[];
18+
1719
#define EXECUTE_SYSCALL(syscall, regs) \
1820
(((long (*)(long, long, long, long, long, long)) \
1921
(*sys_call_table[syscall]))(UPT_SYSCALL_ARG1(&regs->regs), \

‎arch/um/kernel/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ obj-$(CONFIG_BLK_DEV_INITRD) += initrd.o
1818
obj-$(CONFIG_GPROF) += gprof_syms.o
1919
obj-$(CONFIG_GCOV) += gmon_syms.o
2020
obj-$(CONFIG_TTY_LOG) += tty_log.o
21-
obj-$(CONFIG_SYSCALL_DEBUG) += syscall_user.o
21+
obj-$(CONFIG_SYSCALL_DEBUG) += syscall.o
2222

2323
obj-$(CONFIG_MODE_TT) += tt/
2424
obj-$(CONFIG_MODE_SKAS) += skas/

‎arch/um/kernel/skas/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55

66
obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \
7-
syscall_kern.o syscall_user.o tlb.o trap_user.o uaccess.o \
7+
syscall.o tlb.o trap_user.o uaccess.o
88

99
subdir- := util
1010

‎arch/um/kernel/skas/syscall.c‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3+
* Licensed under the GPL
4+
*/
5+
6+
#include "linux/sys.h"
7+
#include "linux/ptrace.h"
8+
#include "asm/errno.h"
9+
#include "asm/unistd.h"
10+
#include "asm/ptrace.h"
11+
#include "asm/current.h"
12+
#include "sysdep/syscalls.h"
13+
#include "kern_util.h"
14+
#include "syscall.h"
15+
16+
void handle_syscall(union uml_pt_regs *r)
17+
{
18+
struct pt_regs *regs = container_of(r, struct pt_regs, regs);
19+
long result;
20+
int syscall;
21+
#ifdef UML_CONFIG_SYSCALL_DEBUG
22+
int index;
23+
24+
index = record_syscall_start(UPT_SYSCALL_NR(r));
25+
#endif
26+
syscall_trace(r, 0);
27+
28+
current->thread.nsyscalls++;
29+
nsyscalls++;
30+
31+
/* This should go in the declaration of syscall, but when I do that,
32+
* strace -f -c bash -c 'ls ; ls' breaks, sometimes not tracing
33+
* children at all, sometimes hanging when bash doesn't see the first
34+
* ls exit.
35+
* The assembly looks functionally the same to me. This is
36+
* gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)
37+
* in case it's a compiler bug.
38+
*/
39+
syscall = UPT_SYSCALL_NR(r);
40+
if((syscall >= NR_syscalls) || (syscall < 0))
41+
result = -ENOSYS;
42+
else result = EXECUTE_SYSCALL(syscall, regs);
43+
44+
REGS_SET_SYSCALL_RETURN(r->skas.regs, result);
45+
46+
syscall_trace(r, 1);
47+
#ifdef UML_CONFIG_SYSCALL_DEBUG
48+
record_syscall_end(index, result);
49+
#endif
50+
}

‎arch/um/kernel/skas/syscall_kern.c‎

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎arch/um/kernel/skas/syscall_user.c‎

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎arch/um/kernel/syscall.c‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3+
* Licensed under the GPL
4+
*/
5+
6+
#include "kern_util.h"
7+
#include "syscall.h"
8+
#include "os.h"
9+
10+
struct {
11+
int syscall;
12+
int pid;
13+
long result;
14+
unsigned long long start;
15+
unsigned long long end;
16+
} syscall_record[1024];
17+
18+
int record_syscall_start(int syscall)
19+
{
20+
int max, index;
21+
22+
max = sizeof(syscall_record)/sizeof(syscall_record[0]);
23+
index = next_syscall_index(max);
24+
25+
syscall_record[index].syscall = syscall;
26+
syscall_record[index].pid = current_pid();
27+
syscall_record[index].result = 0xdeadbeef;
28+
syscall_record[index].start = os_usecs();
29+
return(index);
30+
}
31+
32+
void record_syscall_end(int index, long result)
33+
{
34+
syscall_record[index].result = result;
35+
syscall_record[index].end = os_usecs();
36+
}

0 commit comments

Comments
 (0)