2 * Copyright 2003 PathScale, Inc.
4 * Licensed under the GPL
7 #include "linux/linkage.h"
8 #include "linux/slab.h"
10 #include "asm/uaccess.h"
11 #define __FRAME_OFFSETS
12 #include "asm/ptrace.h"
13 #include "asm/unistd.h"
14 #include "asm/prctl.h" /* XXX This should get the constants from libc */
15 #include "choose-mode.h"
17 asmlinkage
long wrap_sys_shmat(int shmid
, char __user
*shmaddr
, int shmflg
)
21 return do_shmat(shmid
, shmaddr
, shmflg
, &raddr
) ?: (long) raddr
;
25 extern int modify_ldt(int func
, void *ptr
, unsigned long bytecount
);
27 long sys_modify_ldt_tt(int func
, void *ptr
, unsigned long bytecount
)
29 /* XXX This should check VERIFY_WRITE depending on func, check this
32 if (!access_ok(VERIFY_READ
, ptr
, bytecount
))
34 return(modify_ldt(func
, ptr
, bytecount
));
38 #ifdef CONFIG_MODE_SKAS
39 extern int userspace_pid
[];
41 long sys_modify_ldt_skas(int func
, void *ptr
, unsigned long bytecount
)
43 struct ptrace_ldt ldt
;
47 buf
= kmalloc(bytecount
, GFP_KERNEL
);
56 res
= copy_from_user(buf
, ptr
, bytecount
);
65 ldt
= ((struct ptrace_ldt
) { .func
= func
,
67 .bytecount
= bytecount
});
68 #warning Need to look up userspace_pid by cpu
69 res
= ptrace(PTRACE_LDT
, userspace_pid
[0], 0, (unsigned long) &ldt
);
77 res
= copy_to_user(ptr
, buf
, n
);
91 long sys_modify_ldt(int func
, void *ptr
, unsigned long bytecount
)
93 return(CHOOSE_MODE_PROC(sys_modify_ldt_tt
, sys_modify_ldt_skas
, func
,
98 extern long arch_prctl(int code
, unsigned long addr
);
100 static long arch_prctl_tt(int code
, unsigned long addr
)
108 ret
= arch_prctl(code
, addr
);
112 ret
= arch_prctl(code
, (unsigned long) &tmp
);
114 ret
= put_user(tmp
, &addr
);
125 #ifdef CONFIG_MODE_SKAS
127 static long arch_prctl_skas(int code
, unsigned long addr
)
133 current
->thread
.regs
.regs
.skas
.regs
[GS_BASE
/ sizeof(unsigned long)] = addr
;
136 current
->thread
.regs
.regs
.skas
.regs
[FS_BASE
/ sizeof(unsigned long)] = addr
;
139 ret
= put_user(current
->thread
.regs
.regs
.skas
.regs
[GS
/ sizeof(unsigned long)], &addr
);
142 ret
= put_user(current
->thread
.regs
.regs
.skas
.regs
[FS
/ sizeof(unsigned \
154 long sys_arch_prctl(int code
, unsigned long addr
)
156 return(CHOOSE_MODE_PROC(arch_prctl_tt
, arch_prctl_skas
, code
, addr
));
159 long sys_clone(unsigned long clone_flags
, unsigned long newsp
,
160 void __user
*parent_tid
, void __user
*child_tid
)
164 /* XXX: normal arch do here this pass, and also pass the regs to
165 * do_fork, instead of NULL. Currently the arch-independent code
166 * ignores these values, while the UML code (actually it's
167 * copy_thread) does the right thing. But this should change,
170 newsp = UPT_SP(current->thread.regs);*/
171 current
->thread
.forking
= 1;
172 ret
= do_fork(clone_flags
, newsp
, NULL
, 0, parent_tid
, child_tid
);
173 current
->thread
.forking
= 0;
178 * Overrides for Emacs so that we follow Linus's tabbing style.
179 * Emacs will notice this stuff at the end of the file and automatically
180 * adjust the settings for this buffer only. This must remain at the end
182 * ---------------------------------------------------------------------------
184 * c-file-style: "linux"