diff -Naur -X exclude-files ac_cur/arch/um/include/kern_util.h ac/arch/um/include/kern_util.h --- ac_cur/arch/um/include/kern_util.h Sat Nov 3 15:47:56 2001 +++ ac/arch/um/include/kern_util.h Sat Nov 3 14:28:27 2001 @@ -67,7 +67,7 @@ extern void paging_init(void); extern unsigned long um_virt_to_phys(void *t, unsigned long addr); extern void init_flush_vm(void); -extern void *process_state(void *t, unsigned long *cr2_out, int *err_out); +extern void *process_state(void *t); extern struct sys_pt_regs *syscall_state(void *t, void **stack_out, int *size_out); extern void syscall_trace(void); @@ -95,7 +95,6 @@ extern void timer_irq(int user_mode); extern void set_repeat_syscall(int again); extern int get_repeat_syscall(void *t); -extern void set_sigreturn_syscall(int syscall); extern void force_flush_all(void); extern void unprotect_stack(unsigned long stack); extern void kern_start_exec(int new_pid); diff -Naur -X exclude-files ac_cur/arch/um/include/sigcontext.h ac/arch/um/include/sigcontext.h --- ac_cur/arch/um/include/sigcontext.h Wed Dec 31 19:00:00 1969 +++ ac/arch/um/include/sigcontext.h Sat Nov 3 14:31:14 2001 @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2001 Jeff Dike (jdike@karaya.com) + * Licensed under the GPL + */ + +#ifndef __UML_SIGCONTEXT_H__ +#define __UML_SIGCONTEXT_H__ + +extern void fill_in_sigcontext(void *sc, struct sys_pt_regs *regs, + unsigned long cr2, int err); +extern void fill_in_regs(struct sys_pt_regs *regs, void *sc_ptr); + +#endif + +/* + * Overrides for Emacs so that we follow Linus's tabbing style. + * Emacs will notice this stuff at the end of the file and automatically + * adjust the settings for this buffer only. This must remain at the end + * of the file. + * --------------------------------------------------------------------------- + * Local variables: + * c-file-style: "linux" + * End: + */ diff -Naur -X exclude-files ac_cur/arch/um/include/signal_kern.h ac/arch/um/include/signal_kern.h --- ac_cur/arch/um/include/signal_kern.h Sat Nov 3 15:47:56 2001 +++ ac/arch/um/include/signal_kern.h Sat Nov 3 14:28:27 2001 @@ -12,6 +12,7 @@ extern struct sys_pt_regs *signal_state(void *t); extern int probe_stack(unsigned long sp, int delta); extern int have_signals(void *t); +extern void *signal_context(void *t, unsigned long *cr2_out, int *err_out); #endif diff -Naur -X exclude-files ac_cur/arch/um/kernel/process_kern.c ac/arch/um/kernel/process_kern.c --- ac_cur/arch/um/kernel/process_kern.c Sat Nov 3 15:47:56 2001 +++ ac/arch/um/kernel/process_kern.c Sat Nov 3 14:28:27 2001 @@ -514,14 +514,10 @@ return(current); } -void *process_state(void *t, unsigned long *cr2_out, int *err_out) +void *process_state(void *t) { - struct task_struct *task; + struct task_struct *task = t ? t : current; - if(t == NULL) task = current; - else task = t; - if(cr2_out) *cr2_out = task->thread.cr2; - if(err_out) *err_out = task->thread.err; return(&task->thread.process_regs); } diff -Naur -X exclude-files ac_cur/arch/um/kernel/signal_kern.c ac/arch/um/kernel/signal_kern.c --- ac_cur/arch/um/kernel/signal_kern.c Sat Nov 3 15:47:56 2001 +++ ac/arch/um/kernel/signal_kern.c Sat Nov 3 14:28:27 2001 @@ -361,11 +361,6 @@ signal_handler(current, handler, signal); } -void set_sigreturn_syscall(int syscall) -{ - current->thread.sigreturn_syscall = syscall; -} - int sys_sigreturn(struct sys_pt_regs regs) { struct signal_context *context = current->thread.signal_context; @@ -378,9 +373,16 @@ current->thread.process_regs = context->regs; current->thread.repeat_syscall = context->repeat; current->thread.signal_context = context->prev; - UM_SYSCALL_NR(¤t->thread.process_regs) = - current->thread.sigreturn_syscall; return(UM_SYSCALL_RET(¤t->thread.process_regs)); +} + +void *signal_context(void *t, unsigned long *cr2_out, int *err_out) +{ + struct task_struct *task = t ? t : current; + + if(cr2_out) *cr2_out = task->thread.cr2; + if(err_out) *err_out = task->thread.err; + return(&task->thread.signal_context->regs); } /* diff -Naur -X exclude-files ac_cur/arch/um/kernel/signal_user.c ac/arch/um/kernel/signal_user.c --- ac_cur/arch/um/kernel/signal_user.c Sat Nov 3 15:47:56 2001 +++ ac/arch/um/kernel/signal_user.c Sat Nov 3 14:28:27 2001 @@ -143,7 +143,7 @@ int err; UM_ALLOCATE_SC(sc); - regs = process_state(task, &cr2, &err); + regs = signal_context(task, &cr2, &err); fill_in_sigcontext(&sc, regs, cr2, err); handler = (void (*)(int, struct sigcontext)) h; (*handler)(sig, sc); diff -Naur -X exclude-files ac_cur/arch/um/kernel/syscall_user.c ac/arch/um/kernel/syscall_user.c --- ac_cur/arch/um/kernel/syscall_user.c Sat Nov 3 15:47:56 2001 +++ ac/arch/um/kernel/syscall_user.c Sat Nov 3 14:29:10 2001 @@ -61,7 +61,7 @@ index = syscall_index; syscall_index++; unlock_syscall(); - regs = process_state(NULL, NULL, NULL); + regs = process_state(NULL); syscall = UM_SYSCALL_NR(regs); syscall_record[index].syscall = UM_SYSCALL_NR(regs); syscall_record[index].pid = current_pid(); @@ -97,7 +97,7 @@ again = get_repeat_syscall(task); set_repeat_syscall(0); restore = get_restore_regs(task); - regs = process_state(task, NULL, NULL); + regs = process_state(task); if(restore){ if(ptrace_setregs(pid, regs) < 0) tracer_panic("Couldn't restore registers"); @@ -136,12 +136,8 @@ ((unsigned long *) UM_IP(&proc_regs) >= &_stext) && ((unsigned long *) UM_IP(&proc_regs) <= &_etext)) tracer_panic("I'm tracing myself and I can't get out"); - regs = process_state(task, NULL, NULL); - if(syscall == __NR_sigreturn){ - set_sigreturn_syscall(UM_SYSCALL_NR(regs)); - UM_SYSCALL_NR(regs) = __NR_sigreturn; - } - else *regs = proc_regs; + regs = process_state(task); + *regs = proc_regs; set_tracing(task, 0); regs = syscall_state(task, &stack, &n); if(ptrace_setregs(pid, regs) < 0) diff -Naur -X exclude-files ac_cur/arch/um/kernel/trap_user.c ac/arch/um/kernel/trap_user.c --- ac_cur/arch/um/kernel/trap_user.c Sat Nov 3 15:47:56 2001 +++ ac/arch/um/kernel/trap_user.c Sat Nov 3 15:47:43 2001 @@ -21,9 +21,11 @@ #include #include "user_util.h" #include "kern_util.h" +#include "signal_user.h" #include "mem_user.h" #include "user.h" #include "process.h" +#include "sigcontext.h" #include "sysdep/sigcontext.h" #include "init.h" @@ -355,13 +357,16 @@ unprotect_kernel_mem(); timer_on = 0; user_mode = user_context(SC_SP(&sc)); - if(user_mode) timer_ready = 1; + if(user_mode){ + fill_in_regs(process_state(NULL), &sc); + timer_ready = 1; + } change_sig(SIGUSR1, 1); (*handlers[sig])(sig, &sc, user_mode); if(user_mode) interrupt_end(); block_signals(); change_sig(SIGUSR1, 0); - set_user_thread(NULL, user_mode, 0, 0); + set_user_thread(NULL, user_mode, 1, 0); errno = save_errno; if(user_mode) timer_ready = 0; timer_on = save_timer; @@ -375,14 +380,17 @@ unprotect_kernel_mem(); timer_on = 0; user_mode = user_context(SC_SP(&sc)); - if(user_mode) timer_ready = 1; + if(user_mode){ + fill_in_regs(process_state(NULL), &sc); + timer_ready = 1; + } change_sig(SIGUSR1, 1); unblock_signals(); (*handlers[sig])(sig, &sc, user_mode); if(user_mode) interrupt_end(); block_signals(); change_sig(SIGUSR1, 0); - set_user_thread(NULL, user_mode, 0, 0); + set_user_thread(NULL, user_mode, 1, 0); errno = save_errno; if(user_mode) timer_ready = 0; timer_on = save_timer; @@ -413,6 +421,7 @@ } return 0; } + __uml_setup("debug",uml_debug_setup, "debug\n" " Starts up the kernel under the control of gdb. See the \n" diff -Naur -X exclude-files ac_cur/arch/um/sys-i386/sigcontext.c ac/arch/um/sys-i386/sigcontext.c --- ac_cur/arch/um/sys-i386/sigcontext.c Sat Nov 3 15:47:56 2001 +++ ac/arch/um/sys-i386/sigcontext.c Sat Nov 3 14:28:27 2001 @@ -33,6 +33,29 @@ sc->cr2 = cr2; } +void fill_in_regs(struct sys_pt_regs *regs, void *sc_ptr) +{ + struct sigcontext *sc; + + sc = sc_ptr; + regs->regs[EBX] = sc->ebx; + regs->regs[ECX] = sc->ecx; + regs->regs[EDX] = sc->edx; + regs->regs[ESI] = sc->esi; + regs->regs[EDI] = sc->edi; + regs->regs[EBP] = sc->ebp; + regs->regs[EAX] = sc->eax; + regs->regs[DS] = sc->ds; + regs->regs[ES] = sc->es; + regs->regs[FS] = sc->fs; + regs->regs[GS] = sc->gs; + regs->regs[EIP] = sc->eip; + regs->regs[CS] = sc->cs; + regs->regs[EFL] = sc->eflags; + regs->regs[UESP] = sc->esp_at_signal; + regs->regs[SS] = sc->ss; +} + /* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically diff -Naur -X exclude-files ac_cur/arch/um/sys-ppc/sigcontext.c ac/arch/um/sys-ppc/sigcontext.c --- ac_cur/arch/um/sys-ppc/sigcontext.c Sat Nov 3 15:47:56 2001 +++ ac/arch/um/sys-ppc/sigcontext.c Sat Nov 3 14:28:27 2001 @@ -31,6 +31,16 @@ /*(sc->regs) = *regs; */ } +void fill_in_regs(struct sys_pt_regs *regs, void *sc_ptr) +{ + struct sigcontext_struct *sc; + + sc = sc_ptr; + + // FIXME: need to investigate what's going on with struct pt_regs etc. + *regs = *(sc->regs); +} + /* * Overrides for Emacs so that we follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically