aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-i386/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/um/sys-i386/signal.c')
-rw-r--r--arch/um/sys-i386/signal.c84
1 files changed, 40 insertions, 44 deletions
diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c
index 3f6acd667717..1cbf95f6858a 100644
--- a/arch/um/sys-i386/signal.c
+++ b/arch/um/sys-i386/signal.c
@@ -18,6 +18,28 @@
18 18
19#include "skas.h" 19#include "skas.h"
20 20
21void copy_sc(union uml_pt_regs *regs, void *from)
22{
23 struct sigcontext *sc = from;
24
25 REGS_GS(regs->skas.regs) = sc->gs;
26 REGS_FS(regs->skas.regs) = sc->fs;
27 REGS_ES(regs->skas.regs) = sc->es;
28 REGS_DS(regs->skas.regs) = sc->ds;
29 REGS_EDI(regs->skas.regs) = sc->edi;
30 REGS_ESI(regs->skas.regs) = sc->esi;
31 REGS_EBP(regs->skas.regs) = sc->ebp;
32 REGS_SP(regs->skas.regs) = sc->esp;
33 REGS_EBX(regs->skas.regs) = sc->ebx;
34 REGS_EDX(regs->skas.regs) = sc->edx;
35 REGS_ECX(regs->skas.regs) = sc->ecx;
36 REGS_EAX(regs->skas.regs) = sc->eax;
37 REGS_IP(regs->skas.regs) = sc->eip;
38 REGS_CS(regs->skas.regs) = sc->cs;
39 REGS_EFLAGS(regs->skas.regs) = sc->eflags;
40 REGS_SS(regs->skas.regs) = sc->ss;
41}
42
21static int copy_sc_from_user_skas(struct pt_regs *regs, 43static int copy_sc_from_user_skas(struct pt_regs *regs,
22 struct sigcontext __user *from) 44 struct sigcontext __user *from)
23{ 45{
@@ -28,33 +50,18 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
28 err = copy_from_user(&sc, from, sizeof(sc)); 50 err = copy_from_user(&sc, from, sizeof(sc));
29 err |= copy_from_user(fpregs, sc.fpstate, sizeof(fpregs)); 51 err |= copy_from_user(fpregs, sc.fpstate, sizeof(fpregs));
30 if(err) 52 if(err)
31 return(err); 53 return err;
32 54
33 REGS_GS(regs->regs.skas.regs) = sc.gs; 55 copy_sc(&regs->regs, &sc);
34 REGS_FS(regs->regs.skas.regs) = sc.fs;
35 REGS_ES(regs->regs.skas.regs) = sc.es;
36 REGS_DS(regs->regs.skas.regs) = sc.ds;
37 REGS_EDI(regs->regs.skas.regs) = sc.edi;
38 REGS_ESI(regs->regs.skas.regs) = sc.esi;
39 REGS_EBP(regs->regs.skas.regs) = sc.ebp;
40 REGS_SP(regs->regs.skas.regs) = sc.esp;
41 REGS_EBX(regs->regs.skas.regs) = sc.ebx;
42 REGS_EDX(regs->regs.skas.regs) = sc.edx;
43 REGS_ECX(regs->regs.skas.regs) = sc.ecx;
44 REGS_EAX(regs->regs.skas.regs) = sc.eax;
45 REGS_IP(regs->regs.skas.regs) = sc.eip;
46 REGS_CS(regs->regs.skas.regs) = sc.cs;
47 REGS_EFLAGS(regs->regs.skas.regs) = sc.eflags;
48 REGS_SS(regs->regs.skas.regs) = sc.ss;
49 56
50 err = restore_fp_registers(userspace_pid[0], fpregs); 57 err = restore_fp_registers(userspace_pid[0], fpregs);
51 if(err < 0){ 58 if(err < 0) {
52 printk("copy_sc_from_user_skas - PTRACE_SETFPREGS failed, " 59 printk("copy_sc_from_user_skas - PTRACE_SETFPREGS failed, "
53 "errno = %d\n", err); 60 "errno = %d\n", -err);
54 return(1); 61 return err;
55 } 62 }
56 63
57 return(0); 64 return 0;
58} 65}
59 66
60int copy_sc_to_user_skas(struct sigcontext __user *to, struct _fpstate __user *to_fp, 67int copy_sc_to_user_skas(struct sigcontext __user *to, struct _fpstate __user *to_fp,
@@ -90,16 +97,16 @@ int copy_sc_to_user_skas(struct sigcontext __user *to, struct _fpstate __user *t
90 if(err < 0){ 97 if(err < 0){
91 printk("copy_sc_to_user_skas - PTRACE_GETFPREGS failed, " 98 printk("copy_sc_to_user_skas - PTRACE_GETFPREGS failed, "
92 "errno = %d\n", err); 99 "errno = %d\n", err);
93 return(1); 100 return 1;
94 } 101 }
95 to_fp = (to_fp ? to_fp : (struct _fpstate __user *) (to + 1)); 102 to_fp = (to_fp ? to_fp : (struct _fpstate __user *) (to + 1));
96 sc.fpstate = to_fp; 103 sc.fpstate = to_fp;
97 104
98 if(err) 105 if(err)
99 return(err); 106 return err;
100 107
101 return(copy_to_user(to, &sc, sizeof(sc)) || 108 return copy_to_user(to, &sc, sizeof(sc)) ||
102 copy_to_user(to_fp, fpregs, sizeof(fpregs))); 109 copy_to_user(to_fp, fpregs, sizeof(fpregs));
103} 110}
104#endif 111#endif
105 112
@@ -129,7 +136,7 @@ int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext __user *from,
129 to->fpstate = to_fp; 136 to->fpstate = to_fp;
130 if(to_fp != NULL) 137 if(to_fp != NULL)
131 err |= copy_from_user(to_fp, from_fp, fpsize); 138 err |= copy_from_user(to_fp, from_fp, fpsize);
132 return(err); 139 return err;
133} 140}
134 141
135int copy_sc_to_user_tt(struct sigcontext __user *to, struct _fpstate __user *fp, 142int copy_sc_to_user_tt(struct sigcontext __user *to, struct _fpstate __user *fp,
@@ -164,15 +171,15 @@ static int copy_sc_from_user(struct pt_regs *to, void __user *from)
164 ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from, 171 ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from,
165 sizeof(struct _fpstate)), 172 sizeof(struct _fpstate)),
166 copy_sc_from_user_skas(to, from)); 173 copy_sc_from_user_skas(to, from));
167 return(ret); 174 return ret;
168} 175}
169 176
170static int copy_sc_to_user(struct sigcontext __user *to, struct _fpstate __user *fp, 177static int copy_sc_to_user(struct sigcontext __user *to, struct _fpstate __user *fp,
171 struct pt_regs *from, unsigned long sp) 178 struct pt_regs *from, unsigned long sp)
172{ 179{
173 return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), 180 return CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
174 sizeof(*fp), sp), 181 sizeof(*fp), sp),
175 copy_sc_to_user_skas(to, fp, from, sp))); 182 copy_sc_to_user_skas(to, fp, from, sp));
176} 183}
177 184
178static int copy_ucontext_to_user(struct ucontext __user *uc, struct _fpstate __user *fp, 185static int copy_ucontext_to_user(struct ucontext __user *uc, struct _fpstate __user *fp,
@@ -185,7 +192,7 @@ static int copy_ucontext_to_user(struct ucontext __user *uc, struct _fpstate __u
185 err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size); 192 err |= put_user(current->sas_ss_size, &uc->uc_stack.ss_size);
186 err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs, sp); 193 err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs, sp);
187 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set)); 194 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set));
188 return(err); 195 return err;
189} 196}
190 197
191struct sigframe 198struct sigframe
@@ -359,7 +366,7 @@ long sys_sigreturn(struct pt_regs regs)
359 366
360 /* Avoid ERESTART handling */ 367 /* Avoid ERESTART handling */
361 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1; 368 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1;
362 return(PT_REGS_SYSCALL_RET(&current->thread.regs)); 369 return PT_REGS_SYSCALL_RET(&current->thread.regs);
363 370
364 segfault: 371 segfault:
365 force_sig(SIGSEGV, current); 372 force_sig(SIGSEGV, current);
@@ -389,20 +396,9 @@ long sys_rt_sigreturn(struct pt_regs regs)
389 396
390 /* Avoid ERESTART handling */ 397 /* Avoid ERESTART handling */
391 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1; 398 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1;
392 return(PT_REGS_SYSCALL_RET(&current->thread.regs)); 399 return PT_REGS_SYSCALL_RET(&current->thread.regs);
393 400
394 segfault: 401 segfault:
395 force_sig(SIGSEGV, current); 402 force_sig(SIGSEGV, current);
396 return 0; 403 return 0;
397} 404}
398
399/*
400 * Overrides for Emacs so that we follow Linus's tabbing style.
401 * Emacs will notice this stuff at the end of the file and automatically
402 * adjust the settings for this buffer only. This must remain at the end
403 * of the file.
404 * ---------------------------------------------------------------------------
405 * Local variables:
406 * c-file-style: "linux"
407 * End:
408 */