This source file includes following definitions.
- arch_prctl
- SYSCALL_DEFINE2
- arch_switch_to
1
2
3
4
5
6
7
8 #include <linux/sched.h>
9 #include <linux/sched/mm.h>
10 #include <linux/syscalls.h>
11 #include <linux/uaccess.h>
12 #include <asm/prctl.h>
13 #include <os.h>
14
15 long arch_prctl(struct task_struct *task, int option,
16 unsigned long __user *arg2)
17 {
18 unsigned long *ptr = arg2, tmp;
19 long ret;
20 int pid = task->mm->context.id.u.pid;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 switch (option) {
36 case ARCH_SET_FS:
37 case ARCH_SET_GS:
38 ret = restore_registers(pid, ¤t->thread.regs.regs);
39 if (ret)
40 return ret;
41 break;
42 case ARCH_GET_FS:
43 case ARCH_GET_GS:
44
45
46
47
48
49
50
51
52 ptr = &tmp;
53 }
54
55 ret = os_arch_prctl(pid, option, ptr);
56 if (ret)
57 return ret;
58
59 switch (option) {
60 case ARCH_SET_FS:
61 current->thread.arch.fs = (unsigned long) ptr;
62 ret = save_registers(pid, ¤t->thread.regs.regs);
63 break;
64 case ARCH_SET_GS:
65 ret = save_registers(pid, ¤t->thread.regs.regs);
66 break;
67 case ARCH_GET_FS:
68 ret = put_user(tmp, arg2);
69 break;
70 case ARCH_GET_GS:
71 ret = put_user(tmp, arg2);
72 break;
73 }
74
75 return ret;
76 }
77
78 SYSCALL_DEFINE2(arch_prctl, int, option, unsigned long, arg2)
79 {
80 return arch_prctl(current, option, (unsigned long __user *) arg2);
81 }
82
83 void arch_switch_to(struct task_struct *to)
84 {
85 if ((to->thread.arch.fs == 0) || (to->mm == NULL))
86 return;
87
88 arch_prctl(to, ARCH_SET_FS, (void __user *) to->thread.arch.fs);
89 }