2 * Copyright 2003 PathScale, Inc.
4 * Licensed under the GPL
7 #include "linux/linkage.h"
8 #include "linux/slab.h"
10 #include "linux/utsname.h"
11 #include "linux/personality.h"
12 #include "asm/uaccess.h"
13 #define __FRAME_OFFSETS
14 #include "asm/ptrace.h"
15 #include "asm/unistd.h"
16 #include "asm/prctl.h" /* XXX This should get the constants from libc */
17 #include "choose-mode.h"
20 asmlinkage
long sys_uname64(struct new_utsname __user
* name
)
24 err
= copy_to_user(name
, &system_utsname
, sizeof (*name
));
26 if (personality(current
->personality
) == PER_LINUX32
)
27 err
|= copy_to_user(&name
->machine
, "i686", 5);
28 return err
? -EFAULT
: 0;
32 extern int modify_ldt(int func
, void *ptr
, unsigned long bytecount
);
34 long sys_modify_ldt_tt(int func
, void *ptr
, unsigned long bytecount
)
36 /* XXX This should check VERIFY_WRITE depending on func, check this
39 if (!access_ok(VERIFY_READ
, ptr
, bytecount
))
41 return(modify_ldt(func
, ptr
, bytecount
));
45 #ifdef CONFIG_MODE_SKAS
46 extern int userspace_pid
[];
48 #include "skas_ptrace.h"
50 long sys_modify_ldt_skas(int func
, void *ptr
, unsigned long bytecount
)
52 struct ptrace_ldt ldt
;
56 buf
= kmalloc(bytecount
, GFP_KERNEL
);
65 res
= copy_from_user(buf
, ptr
, bytecount
);
74 ldt
= ((struct ptrace_ldt
) { .func
= func
,
76 .bytecount
= bytecount
});
77 #warning Need to look up userspace_pid by cpu
78 res
= ptrace(PTRACE_LDT
, userspace_pid
[0], 0, (unsigned long) &ldt
);
86 res
= copy_to_user(ptr
, buf
, n
);
100 long sys_modify_ldt(int func
, void *ptr
, unsigned long bytecount
)
102 return(CHOOSE_MODE_PROC(sys_modify_ldt_tt
, sys_modify_ldt_skas
, func
,
106 #ifdef CONFIG_MODE_TT
107 extern long arch_prctl(int code
, unsigned long addr
);
109 static long arch_prctl_tt(int code
, unsigned long addr
)
117 ret
= arch_prctl(code
, addr
);
121 ret
= arch_prctl(code
, (unsigned long) &tmp
);
123 ret
= put_user(tmp
, &addr
);
134 #ifdef CONFIG_MODE_SKAS
136 /* XXX: Must also call arch_prctl in the host, beside saving the segment bases! */
137 static long arch_prctl_skas(int code
, unsigned long addr
)
143 current
->thread
.regs
.regs
.skas
.regs
[FS_BASE
/ sizeof(unsigned long)] = addr
;
146 current
->thread
.regs
.regs
.skas
.regs
[GS_BASE
/ sizeof(unsigned long)] = addr
;
149 ret
= put_user(current
->thread
.regs
.regs
.skas
.
150 regs
[FS_BASE
/ sizeof(unsigned long)],
151 (unsigned long __user
*)addr
);
154 ret
= put_user(current
->thread
.regs
.regs
.skas
.
155 regs
[GS_BASE
/ sizeof(unsigned long)],
156 (unsigned long __user
*)addr
);
167 long sys_arch_prctl(int code
, unsigned long addr
)
169 return(CHOOSE_MODE_PROC(arch_prctl_tt
, arch_prctl_skas
, code
, addr
));
172 long sys_clone(unsigned long clone_flags
, unsigned long newsp
,
173 void __user
*parent_tid
, void __user
*child_tid
)
178 newsp
= UPT_SP(¤t
->thread
.regs
.regs
);
179 current
->thread
.forking
= 1;
180 ret
= do_fork(clone_flags
, newsp
, ¤t
->thread
.regs
, 0, parent_tid
,
182 current
->thread
.forking
= 0;