diff options
Diffstat (limited to 'arch/um/sys-x86_64/syscalls.c')
-rw-r--r-- | arch/um/sys-x86_64/syscalls.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/arch/um/sys-x86_64/syscalls.c b/arch/um/sys-x86_64/syscalls.c index bbcab773b23d..58ae06562b4a 100644 --- a/arch/um/sys-x86_64/syscalls.c +++ b/arch/um/sys-x86_64/syscalls.c | |||
@@ -1,36 +1,34 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
2 | * Copyright 2003 PathScale, Inc. | 3 | * Copyright 2003 PathScale, Inc. |
3 | * | 4 | * |
4 | * Licensed under the GPL | 5 | * Licensed under the GPL |
5 | */ | 6 | */ |
6 | 7 | ||
7 | #include "linux/linkage.h" | 8 | #include "linux/linkage.h" |
8 | #include "linux/slab.h" | ||
9 | #include "linux/shm.h" | ||
10 | #include "linux/utsname.h" | ||
11 | #include "linux/personality.h" | 9 | #include "linux/personality.h" |
12 | #include "asm/uaccess.h" | 10 | #include "linux/utsname.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 */ | 11 | #include "asm/prctl.h" /* XXX This should get the constants from libc */ |
17 | #include "kern.h" | 12 | #include "asm/uaccess.h" |
18 | #include "os.h" | 13 | #include "os.h" |
19 | 14 | ||
20 | asmlinkage long sys_uname64(struct new_utsname __user * name) | 15 | asmlinkage long sys_uname64(struct new_utsname __user * name) |
21 | { | 16 | { |
22 | int err; | 17 | int err; |
18 | |||
23 | down_read(&uts_sem); | 19 | down_read(&uts_sem); |
24 | err = copy_to_user(name, utsname(), sizeof (*name)); | 20 | err = copy_to_user(name, utsname(), sizeof (*name)); |
25 | up_read(&uts_sem); | 21 | up_read(&uts_sem); |
22 | |||
26 | if (personality(current->personality) == PER_LINUX32) | 23 | if (personality(current->personality) == PER_LINUX32) |
27 | err |= copy_to_user(&name->machine, "i686", 5); | 24 | err |= copy_to_user(&name->machine, "i686", 5); |
25 | |||
28 | return err ? -EFAULT : 0; | 26 | return err ? -EFAULT : 0; |
29 | } | 27 | } |
30 | 28 | ||
31 | long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) | 29 | long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) |
32 | { | 30 | { |
33 | unsigned long *ptr = addr, tmp; | 31 | unsigned long *ptr = addr, tmp; |
34 | long ret; | 32 | long ret; |
35 | int pid = task->mm->context.skas.id.u.pid; | 33 | int pid = task->mm->context.skas.id.u.pid; |
36 | 34 | ||
@@ -47,42 +45,42 @@ long arch_prctl(struct task_struct *task, int code, unsigned long __user *addr) | |||
47 | * arch_prctl is run on the host, then the registers are read | 45 | * arch_prctl is run on the host, then the registers are read |
48 | * back. | 46 | * back. |
49 | */ | 47 | */ |
50 | switch(code){ | 48 | switch (code) { |
51 | case ARCH_SET_FS: | 49 | case ARCH_SET_FS: |
52 | case ARCH_SET_GS: | 50 | case ARCH_SET_GS: |
53 | restore_registers(pid, ¤t->thread.regs.regs); | 51 | restore_registers(pid, ¤t->thread.regs.regs); |
54 | break; | 52 | break; |
55 | case ARCH_GET_FS: | 53 | case ARCH_GET_FS: |
56 | case ARCH_GET_GS: | 54 | case ARCH_GET_GS: |
57 | /* | 55 | /* |
58 | * With these two, we read to a local pointer and | 56 | * With these two, we read to a local pointer and |
59 | * put_user it to the userspace pointer that we were | 57 | * put_user it to the userspace pointer that we were |
60 | * given. If addr isn't valid (because it hasn't been | 58 | * given. If addr isn't valid (because it hasn't been |
61 | * faulted in or is just bogus), we want put_user to | 59 | * faulted in or is just bogus), we want put_user to |
62 | * fault it in (or return -EFAULT) instead of having | 60 | * fault it in (or return -EFAULT) instead of having |
63 | * the host return -EFAULT. | 61 | * the host return -EFAULT. |
64 | */ | 62 | */ |
65 | ptr = &tmp; | 63 | ptr = &tmp; |
66 | } | 64 | } |
67 | 65 | ||
68 | ret = os_arch_prctl(pid, code, ptr); | 66 | ret = os_arch_prctl(pid, code, ptr); |
69 | if(ret) | 67 | if (ret) |
70 | return ret; | 68 | return ret; |
71 | 69 | ||
72 | switch(code){ | 70 | switch (code) { |
73 | case ARCH_SET_FS: | 71 | case ARCH_SET_FS: |
74 | current->thread.arch.fs = (unsigned long) ptr; | 72 | current->thread.arch.fs = (unsigned long) ptr; |
75 | save_registers(pid, ¤t->thread.regs.regs); | 73 | save_registers(pid, ¤t->thread.regs.regs); |
76 | break; | 74 | break; |
77 | case ARCH_SET_GS: | 75 | case ARCH_SET_GS: |
78 | save_registers(pid, ¤t->thread.regs.regs); | 76 | save_registers(pid, ¤t->thread.regs.regs); |
79 | break; | 77 | break; |
80 | case ARCH_GET_FS: | 78 | case ARCH_GET_FS: |
81 | ret = put_user(tmp, addr); | 79 | ret = put_user(tmp, addr); |
82 | break; | 80 | break; |
83 | case ARCH_GET_GS: | 81 | case ARCH_GET_GS: |
84 | ret = put_user(tmp, addr); | 82 | ret = put_user(tmp, addr); |
85 | break; | 83 | break; |
86 | } | 84 | } |
87 | 85 | ||
88 | return ret; | 86 | return ret; |
@@ -109,8 +107,8 @@ long sys_clone(unsigned long clone_flags, unsigned long newsp, | |||
109 | 107 | ||
110 | void arch_switch_to(struct task_struct *from, struct task_struct *to) | 108 | void arch_switch_to(struct task_struct *from, struct task_struct *to) |
111 | { | 109 | { |
112 | if((to->thread.arch.fs == 0) || (to->mm == NULL)) | 110 | if ((to->thread.arch.fs == 0) || (to->mm == NULL)) |
113 | return; | 111 | return; |
114 | 112 | ||
115 | arch_prctl(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs); | 113 | arch_prctl(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs); |
116 | } | 114 | } |