diff options
Diffstat (limited to 'arch/um/sys-x86_64/signal.c')
-rw-r--r-- | arch/um/sys-x86_64/signal.c | 149 |
1 files changed, 67 insertions, 82 deletions
diff --git a/arch/um/sys-x86_64/signal.c b/arch/um/sys-x86_64/signal.c index a06d66d0c409..9001d17fc3d8 100644 --- a/arch/um/sys-x86_64/signal.c +++ b/arch/um/sys-x86_64/signal.c | |||
@@ -3,16 +3,11 @@ | |||
3 | * Licensed under the GPL | 3 | * Licensed under the GPL |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include "linux/stddef.h" | ||
7 | #include "linux/errno.h" | ||
8 | #include "linux/personality.h" | 6 | #include "linux/personality.h" |
9 | #include "linux/ptrace.h" | 7 | #include "linux/ptrace.h" |
10 | #include "asm/current.h" | 8 | #include "asm/unistd.h" |
11 | #include "asm/uaccess.h" | 9 | #include "asm/uaccess.h" |
12 | #include "asm/sigcontext.h" | 10 | #include "asm/ucontext.h" |
13 | #include "asm/ptrace.h" | ||
14 | #include "asm/arch/ucontext.h" | ||
15 | #include "sysdep/ptrace.h" | ||
16 | #include "frame_kern.h" | 11 | #include "frame_kern.h" |
17 | #include "skas.h" | 12 | #include "skas.h" |
18 | 13 | ||
@@ -20,28 +15,28 @@ void copy_sc(struct uml_pt_regs *regs, void *from) | |||
20 | { | 15 | { |
21 | struct sigcontext *sc = from; | 16 | struct sigcontext *sc = from; |
22 | 17 | ||
23 | #define GETREG(regs, regno, sc, regname) \ | 18 | #define GETREG(regs, regno, sc, regname) \ |
24 | (regs)->regs[(regno) / sizeof(unsigned long)] = (sc)->regname | 19 | (regs)->regs[(regno) / sizeof(unsigned long)] = (sc)->regname |
25 | 20 | ||
26 | GETREG(regs, R8, sc, r8); | 21 | GETREG(regs, R8, sc, r8); |
27 | GETREG(regs, R9, sc, r9); | 22 | GETREG(regs, R9, sc, r9); |
28 | GETREG(regs, R10, sc, r10); | 23 | GETREG(regs, R10, sc, r10); |
29 | GETREG(regs, R11, sc, r11); | 24 | GETREG(regs, R11, sc, r11); |
30 | GETREG(regs, R12, sc, r12); | 25 | GETREG(regs, R12, sc, r12); |
31 | GETREG(regs, R13, sc, r13); | 26 | GETREG(regs, R13, sc, r13); |
32 | GETREG(regs, R14, sc, r14); | 27 | GETREG(regs, R14, sc, r14); |
33 | GETREG(regs, R15, sc, r15); | 28 | GETREG(regs, R15, sc, r15); |
34 | GETREG(regs, RDI, sc, rdi); | 29 | GETREG(regs, RDI, sc, rdi); |
35 | GETREG(regs, RSI, sc, rsi); | 30 | GETREG(regs, RSI, sc, rsi); |
36 | GETREG(regs, RBP, sc, rbp); | 31 | GETREG(regs, RBP, sc, rbp); |
37 | GETREG(regs, RBX, sc, rbx); | 32 | GETREG(regs, RBX, sc, rbx); |
38 | GETREG(regs, RDX, sc, rdx); | 33 | GETREG(regs, RDX, sc, rdx); |
39 | GETREG(regs, RAX, sc, rax); | 34 | GETREG(regs, RAX, sc, rax); |
40 | GETREG(regs, RCX, sc, rcx); | 35 | GETREG(regs, RCX, sc, rcx); |
41 | GETREG(regs, RSP, sc, rsp); | 36 | GETREG(regs, RSP, sc, rsp); |
42 | GETREG(regs, RIP, sc, rip); | 37 | GETREG(regs, RIP, sc, rip); |
43 | GETREG(regs, EFLAGS, sc, eflags); | 38 | GETREG(regs, EFLAGS, sc, eflags); |
44 | GETREG(regs, CS, sc, cs); | 39 | GETREG(regs, CS, sc, cs); |
45 | 40 | ||
46 | #undef GETREG | 41 | #undef GETREG |
47 | } | 42 | } |
@@ -49,58 +44,58 @@ void copy_sc(struct uml_pt_regs *regs, void *from) | |||
49 | static int copy_sc_from_user(struct pt_regs *regs, | 44 | static int copy_sc_from_user(struct pt_regs *regs, |
50 | struct sigcontext __user *from) | 45 | struct sigcontext __user *from) |
51 | { | 46 | { |
52 | int err = 0; | 47 | int err = 0; |
53 | 48 | ||
54 | #define GETREG(regs, regno, sc, regname) \ | 49 | #define GETREG(regs, regno, sc, regname) \ |
55 | __get_user((regs)->regs.regs[(regno) / sizeof(unsigned long)], \ | 50 | __get_user((regs)->regs.regs[(regno) / sizeof(unsigned long)], \ |
56 | &(sc)->regname) | 51 | &(sc)->regname) |
57 | 52 | ||
58 | err |= GETREG(regs, R8, from, r8); | 53 | err |= GETREG(regs, R8, from, r8); |
59 | err |= GETREG(regs, R9, from, r9); | 54 | err |= GETREG(regs, R9, from, r9); |
60 | err |= GETREG(regs, R10, from, r10); | 55 | err |= GETREG(regs, R10, from, r10); |
61 | err |= GETREG(regs, R11, from, r11); | 56 | err |= GETREG(regs, R11, from, r11); |
62 | err |= GETREG(regs, R12, from, r12); | 57 | err |= GETREG(regs, R12, from, r12); |
63 | err |= GETREG(regs, R13, from, r13); | 58 | err |= GETREG(regs, R13, from, r13); |
64 | err |= GETREG(regs, R14, from, r14); | 59 | err |= GETREG(regs, R14, from, r14); |
65 | err |= GETREG(regs, R15, from, r15); | 60 | err |= GETREG(regs, R15, from, r15); |
66 | err |= GETREG(regs, RDI, from, rdi); | 61 | err |= GETREG(regs, RDI, from, rdi); |
67 | err |= GETREG(regs, RSI, from, rsi); | 62 | err |= GETREG(regs, RSI, from, rsi); |
68 | err |= GETREG(regs, RBP, from, rbp); | 63 | err |= GETREG(regs, RBP, from, rbp); |
69 | err |= GETREG(regs, RBX, from, rbx); | 64 | err |= GETREG(regs, RBX, from, rbx); |
70 | err |= GETREG(regs, RDX, from, rdx); | 65 | err |= GETREG(regs, RDX, from, rdx); |
71 | err |= GETREG(regs, RAX, from, rax); | 66 | err |= GETREG(regs, RAX, from, rax); |
72 | err |= GETREG(regs, RCX, from, rcx); | 67 | err |= GETREG(regs, RCX, from, rcx); |
73 | err |= GETREG(regs, RSP, from, rsp); | 68 | err |= GETREG(regs, RSP, from, rsp); |
74 | err |= GETREG(regs, RIP, from, rip); | 69 | err |= GETREG(regs, RIP, from, rip); |
75 | err |= GETREG(regs, EFLAGS, from, eflags); | 70 | err |= GETREG(regs, EFLAGS, from, eflags); |
76 | err |= GETREG(regs, CS, from, cs); | 71 | err |= GETREG(regs, CS, from, cs); |
77 | 72 | ||
78 | #undef GETREG | 73 | #undef GETREG |
79 | 74 | ||
80 | return err; | 75 | return err; |
81 | } | 76 | } |
82 | 77 | ||
83 | static int copy_sc_to_user(struct sigcontext __user *to, | 78 | static int copy_sc_to_user(struct sigcontext __user *to, |
84 | struct _fpstate __user *to_fp, struct pt_regs *regs, | 79 | struct _fpstate __user *to_fp, struct pt_regs *regs, |
85 | unsigned long mask, unsigned long sp) | 80 | unsigned long mask, unsigned long sp) |
86 | { | 81 | { |
87 | struct faultinfo * fi = ¤t->thread.arch.faultinfo; | 82 | struct faultinfo * fi = ¤t->thread.arch.faultinfo; |
88 | int err = 0; | 83 | int err = 0; |
89 | 84 | ||
90 | err |= __put_user(0, &to->gs); | 85 | err |= __put_user(0, &to->gs); |
91 | err |= __put_user(0, &to->fs); | 86 | err |= __put_user(0, &to->fs); |
92 | 87 | ||
93 | #define PUTREG(regs, regno, sc, regname) \ | 88 | #define PUTREG(regs, regno, sc, regname) \ |
94 | __put_user((regs)->regs.regs[(regno) / sizeof(unsigned long)], \ | 89 | __put_user((regs)->regs.regs[(regno) / sizeof(unsigned long)], \ |
95 | &(sc)->regname) | 90 | &(sc)->regname) |
96 | 91 | ||
97 | err |= PUTREG(regs, RDI, to, rdi); | 92 | err |= PUTREG(regs, RDI, to, rdi); |
98 | err |= PUTREG(regs, RSI, to, rsi); | 93 | err |= PUTREG(regs, RSI, to, rsi); |
99 | err |= PUTREG(regs, RBP, to, rbp); | 94 | err |= PUTREG(regs, RBP, to, rbp); |
100 | /* Must use orignal RSP, which is passed in, rather than what's in | 95 | /* Must use orignal RSP, which is passed in, rather than what's in |
101 | * the pt_regs, because that's already been updated to point at the | 96 | * the pt_regs, because that's already been updated to point at the |
102 | * signal frame. | 97 | * signal frame. |
103 | */ | 98 | */ |
104 | err |= __put_user(sp, &to->rsp); | 99 | err |= __put_user(sp, &to->rsp); |
105 | err |= PUTREG(regs, RBX, to, rbx); | 100 | err |= PUTREG(regs, RBX, to, rbx); |
106 | err |= PUTREG(regs, RDX, to, rdx); | 101 | err |= PUTREG(regs, RDX, to, rdx); |
@@ -116,9 +111,9 @@ static int copy_sc_to_user(struct sigcontext __user *to, | |||
116 | err |= PUTREG(regs, R15, to, r15); | 111 | err |= PUTREG(regs, R15, to, r15); |
117 | err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */ | 112 | err |= PUTREG(regs, CS, to, cs); /* XXX x86_64 doesn't do this */ |
118 | 113 | ||
119 | err |= __put_user(fi->cr2, &to->cr2); | 114 | err |= __put_user(fi->cr2, &to->cr2); |
120 | err |= __put_user(fi->error_code, &to->err); | 115 | err |= __put_user(fi->error_code, &to->err); |
121 | err |= __put_user(fi->trap_no, &to->trapno); | 116 | err |= __put_user(fi->trap_no, &to->trapno); |
122 | 117 | ||
123 | err |= PUTREG(regs, RIP, to, rip); | 118 | err |= PUTREG(regs, RIP, to, rip); |
124 | err |= PUTREG(regs, EFLAGS, to, eflags); | 119 | err |= PUTREG(regs, EFLAGS, to, eflags); |
@@ -131,9 +126,9 @@ static int copy_sc_to_user(struct sigcontext __user *to, | |||
131 | 126 | ||
132 | struct rt_sigframe | 127 | struct rt_sigframe |
133 | { | 128 | { |
134 | char __user *pretcode; | 129 | char __user *pretcode; |
135 | struct ucontext uc; | 130 | struct ucontext uc; |
136 | struct siginfo info; | 131 | struct siginfo info; |
137 | }; | 132 | }; |
138 | 133 | ||
139 | #define round_down(m, n) (((m) / (n)) * (n)) | 134 | #define round_down(m, n) (((m) / (n)) * (n)) |
@@ -151,7 +146,7 @@ int setup_signal_stack_si(unsigned long stack_top, int sig, | |||
151 | frame = (struct rt_sigframe __user *) | 146 | frame = (struct rt_sigframe __user *) |
152 | round_down(stack_top - sizeof(struct rt_sigframe), 16); | 147 | round_down(stack_top - sizeof(struct rt_sigframe), 16); |
153 | /* Subtract 128 for a red zone and 8 for proper alignment */ | 148 | /* Subtract 128 for a red zone and 8 for proper alignment */ |
154 | frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8); | 149 | frame = (struct rt_sigframe __user *) ((unsigned long) frame - 128 - 8); |
155 | 150 | ||
156 | if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) | 151 | if (!access_ok(VERIFY_WRITE, fp, sizeof(struct _fpstate))) |
157 | goto out; | 152 | goto out; |
@@ -241,7 +236,7 @@ long sys_rt_sigreturn(struct pt_regs *regs) | |||
241 | struct ucontext __user *uc = &frame->uc; | 236 | struct ucontext __user *uc = &frame->uc; |
242 | sigset_t set; | 237 | sigset_t set; |
243 | 238 | ||
244 | if(copy_from_user(&set, &uc->uc_sigmask, sizeof(set))) | 239 | if (copy_from_user(&set, &uc->uc_sigmask, sizeof(set))) |
245 | goto segfault; | 240 | goto segfault; |
246 | 241 | ||
247 | sigdelsetmask(&set, ~_BLOCKABLE); | 242 | sigdelsetmask(&set, ~_BLOCKABLE); |
@@ -251,7 +246,7 @@ long sys_rt_sigreturn(struct pt_regs *regs) | |||
251 | recalc_sigpending(); | 246 | recalc_sigpending(); |
252 | spin_unlock_irq(¤t->sighand->siglock); | 247 | spin_unlock_irq(¤t->sighand->siglock); |
253 | 248 | ||
254 | if(copy_sc_from_user(¤t->thread.regs, &uc->uc_mcontext)) | 249 | if (copy_sc_from_user(¤t->thread.regs, &uc->uc_mcontext)) |
255 | goto segfault; | 250 | goto segfault; |
256 | 251 | ||
257 | /* Avoid ERESTART handling */ | 252 | /* Avoid ERESTART handling */ |
@@ -262,13 +257,3 @@ long sys_rt_sigreturn(struct pt_regs *regs) | |||
262 | force_sig(SIGSEGV, current); | 257 | force_sig(SIGSEGV, current); |
263 | return 0; | 258 | return 0; |
264 | } | 259 | } |
265 | /* | ||
266 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
267 | * Emacs will notice this stuff at the end of the file and automatically | ||
268 | * adjust the settings for this buffer only. This must remain at the end | ||
269 | * of the file. | ||
270 | * --------------------------------------------------------------------------- | ||
271 | * Local variables: | ||
272 | * c-file-style: "linux" | ||
273 | * End: | ||
274 | */ | ||