aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um/sys-i386
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2007-05-06 17:51:24 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:13:02 -0400
commit5d86456d3852cb95a38d2b23fe01cede54984ba5 (patch)
treea0e973d629717d93c7b4dc32ad7afd9e64f5f974 /arch/um/sys-i386
parentccdddb57874522e6b267204f9c5e94ba7d9d66b0 (diff)
uml: tidy fault code
Tidying in preparation for the segfault register dumping patch which follows. void * pointers are changed to union uml_pt_regs *. This makes the types match reality, except in arch_fixup, which is changed to operate on a union uml_pt_regs. This fixes a bug in the call from segv_handler, which passes a union uml_pt_regs, to segv, which expects to pass a struct sigcontext to arch_fixup. Whitespace and other style fixes. There's also a errno printk fix. Signed-off-by: Jeff Dike <jdike@linux.intel.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/um/sys-i386')
-rw-r--r--arch/um/sys-i386/fault.c18
-rw-r--r--arch/um/sys-i386/signal.c41
2 files changed, 17 insertions, 42 deletions
diff --git a/arch/um/sys-i386/fault.c b/arch/um/sys-i386/fault.c
index d0bbcdfdb53f..745b4fd49e9f 100644
--- a/arch/um/sys-i386/fault.c
+++ b/arch/um/sys-i386/fault.c
@@ -3,9 +3,7 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <signal.h>
7#include "sysdep/ptrace.h" 6#include "sysdep/ptrace.h"
8#include "sysdep/sigcontext.h"
9 7
10/* These two are from asm-um/uaccess.h and linux/module.h, check them. */ 8/* These two are from asm-um/uaccess.h and linux/module.h, check them. */
11struct exception_table_entry 9struct exception_table_entry
@@ -17,26 +15,14 @@ struct exception_table_entry
17const struct exception_table_entry *search_exception_tables(unsigned long add); 15const struct exception_table_entry *search_exception_tables(unsigned long add);
18 16
19/* Compare this to arch/i386/mm/extable.c:fixup_exception() */ 17/* Compare this to arch/i386/mm/extable.c:fixup_exception() */
20int arch_fixup(unsigned long address, void *sc_ptr) 18int arch_fixup(unsigned long address, union uml_pt_regs *regs)
21{ 19{
22 struct sigcontext *sc = sc_ptr;
23 const struct exception_table_entry *fixup; 20 const struct exception_table_entry *fixup;
24 21
25 fixup = search_exception_tables(address); 22 fixup = search_exception_tables(address);
26 if(fixup != 0){ 23 if(fixup != 0){
27 sc->eip = fixup->fixup; 24 UPT_IP(regs) = fixup->fixup;
28 return(1); 25 return(1);
29 } 26 }
30 return(0); 27 return(0);
31} 28}
32
33/*
34 * Overrides for Emacs so that we follow Linus's tabbing style.
35 * Emacs will notice this stuff at the end of the file and automatically
36 * adjust the settings for this buffer only. This must remain at the end
37 * of the file.
38 * ---------------------------------------------------------------------------
39 * Local variables:
40 * c-file-style: "linux"
41 * End:
42 */
diff --git a/arch/um/sys-i386/signal.c b/arch/um/sys-i386/signal.c
index 3f6acd667717..42ecf8e8ad08 100644
--- a/arch/um/sys-i386/signal.c
+++ b/arch/um/sys-i386/signal.c
@@ -28,7 +28,7 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
28 err = copy_from_user(&sc, from, sizeof(sc)); 28 err = copy_from_user(&sc, from, sizeof(sc));
29 err |= copy_from_user(fpregs, sc.fpstate, sizeof(fpregs)); 29 err |= copy_from_user(fpregs, sc.fpstate, sizeof(fpregs));
30 if(err) 30 if(err)
31 return(err); 31 return err;
32 32
33 REGS_GS(regs->regs.skas.regs) = sc.gs; 33 REGS_GS(regs->regs.skas.regs) = sc.gs;
34 REGS_FS(regs->regs.skas.regs) = sc.fs; 34 REGS_FS(regs->regs.skas.regs) = sc.fs;
@@ -50,11 +50,11 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
50 err = restore_fp_registers(userspace_pid[0], fpregs); 50 err = restore_fp_registers(userspace_pid[0], fpregs);
51 if(err < 0){ 51 if(err < 0){
52 printk("copy_sc_from_user_skas - PTRACE_SETFPREGS failed, " 52 printk("copy_sc_from_user_skas - PTRACE_SETFPREGS failed, "
53 "errno = %d\n", err); 53 "errno = %d\n", -err);
54 return(1); 54 return err;
55 } 55 }
56 56
57 return(0); 57 return 0;
58} 58}
59 59
60int copy_sc_to_user_skas(struct sigcontext __user *to, struct _fpstate __user *to_fp, 60int copy_sc_to_user_skas(struct sigcontext __user *to, struct _fpstate __user *to_fp,
@@ -90,16 +90,16 @@ int copy_sc_to_user_skas(struct sigcontext __user *to, struct _fpstate __user *t
90 if(err < 0){ 90 if(err < 0){
91 printk("copy_sc_to_user_skas - PTRACE_GETFPREGS failed, " 91 printk("copy_sc_to_user_skas - PTRACE_GETFPREGS failed, "
92 "errno = %d\n", err); 92 "errno = %d\n", err);
93 return(1); 93 return 1;
94 } 94 }
95 to_fp = (to_fp ? to_fp : (struct _fpstate __user *) (to + 1)); 95 to_fp = (to_fp ? to_fp : (struct _fpstate __user *) (to + 1));
96 sc.fpstate = to_fp; 96 sc.fpstate = to_fp;
97 97
98 if(err) 98 if(err)
99 return(err); 99 return err;
100 100
101 return(copy_to_user(to, &sc, sizeof(sc)) || 101 return copy_to_user(to, &sc, sizeof(sc)) ||
102 copy_to_user(to_fp, fpregs, sizeof(fpregs))); 102 copy_to_user(to_fp, fpregs, sizeof(fpregs));
103} 103}
104#endif 104#endif
105 105
@@ -129,7 +129,7 @@ int copy_sc_from_user_tt(struct sigcontext *to, struct sigcontext __user *from,
129 to->fpstate = to_fp; 129 to->fpstate = to_fp;
130 if(to_fp != NULL) 130 if(to_fp != NULL)
131 err |= copy_from_user(to_fp, from_fp, fpsize); 131 err |= copy_from_user(to_fp, from_fp, fpsize);
132 return(err); 132 return err;
133} 133}
134 134
135int copy_sc_to_user_tt(struct sigcontext __user *to, struct _fpstate __user *fp, 135int copy_sc_to_user_tt(struct sigcontext __user *to, struct _fpstate __user *fp,
@@ -164,15 +164,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, 164 ret = CHOOSE_MODE(copy_sc_from_user_tt(UPT_SC(&to->regs), from,
165 sizeof(struct _fpstate)), 165 sizeof(struct _fpstate)),
166 copy_sc_from_user_skas(to, from)); 166 copy_sc_from_user_skas(to, from));
167 return(ret); 167 return ret;
168} 168}
169 169
170static int copy_sc_to_user(struct sigcontext __user *to, struct _fpstate __user *fp, 170static int copy_sc_to_user(struct sigcontext __user *to, struct _fpstate __user *fp,
171 struct pt_regs *from, unsigned long sp) 171 struct pt_regs *from, unsigned long sp)
172{ 172{
173 return(CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs), 173 return CHOOSE_MODE(copy_sc_to_user_tt(to, fp, UPT_SC(&from->regs),
174 sizeof(*fp), sp), 174 sizeof(*fp), sp),
175 copy_sc_to_user_skas(to, fp, from, sp))); 175 copy_sc_to_user_skas(to, fp, from, sp));
176} 176}
177 177
178static int copy_ucontext_to_user(struct ucontext __user *uc, struct _fpstate __user *fp, 178static int copy_ucontext_to_user(struct ucontext __user *uc, struct _fpstate __user *fp,
@@ -185,7 +185,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); 185 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); 186 err |= copy_sc_to_user(&uc->uc_mcontext, fp, &current->thread.regs, sp);
187 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set)); 187 err |= copy_to_user(&uc->uc_sigmask, set, sizeof(*set));
188 return(err); 188 return err;
189} 189}
190 190
191struct sigframe 191struct sigframe
@@ -359,7 +359,7 @@ long sys_sigreturn(struct pt_regs regs)
359 359
360 /* Avoid ERESTART handling */ 360 /* Avoid ERESTART handling */
361 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1; 361 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1;
362 return(PT_REGS_SYSCALL_RET(&current->thread.regs)); 362 return PT_REGS_SYSCALL_RET(&current->thread.regs);
363 363
364 segfault: 364 segfault:
365 force_sig(SIGSEGV, current); 365 force_sig(SIGSEGV, current);
@@ -389,20 +389,9 @@ long sys_rt_sigreturn(struct pt_regs regs)
389 389
390 /* Avoid ERESTART handling */ 390 /* Avoid ERESTART handling */
391 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1; 391 PT_REGS_SYSCALL_NR(&current->thread.regs) = -1;
392 return(PT_REGS_SYSCALL_RET(&current->thread.regs)); 392 return PT_REGS_SYSCALL_RET(&current->thread.regs);
393 393
394 segfault: 394 segfault:
395 force_sig(SIGSEGV, current); 395 force_sig(SIGSEGV, current);
396 return 0; 396 return 0;
397} 397}
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 */