Add mips-user signal handling
PATCH 1/1 Add mips-user signal handling
Hello,
this patch adds signal handling for mips-user (and mipsel also).
However it doesn't implement setup_rt_frame, but it seems it is not used a lot, so the current patch should support the vast majority of applications.
Also note that since we are not in real kernel mode, the switch to the signal handler is not done by setting CP0_EPC and doing an "eret" but by directly modifying PC.
Please consider it for inclusion into the mainline.
Raphaël Rigo
Index: linux-user/main.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/main.c,v
retrieving revision 1.88
main.c +5 -1
@@ -1327,7 +1327,8 @@ arg5, arg6); } - env->PC +=4 ; +if (syscall_num != TARGET_NR_sigreturn-4000 ) + env->PC +=4 ;if ((unsigned int )ret >= (unsigned int )(-1133 )) { env->gpr[7 ] =1 ;/* error flag */ ret = -ret;
@@ -1346,6 +1347,9 @@ info.si_code =0 ;queue_signal (info.si_signo, &info);break ; +case EXCP_INTERRUPT : +/* just indicate that signals should be handled asap */ +break ;default :// error: fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
Index: linux-user/signal.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/signal.c,v retrieving revision 1.31
signal.c +334 -2
353 lines not on this page · raw message
Index: linux-user/syscall.c
===================================================================
RCS file: /sources/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.72
syscall.c +28 -0
@@ -2140,6 +2140,7 @@break ;case TARGET_NR_sigaction: { +#if !defined(TARGET_MIPS )struct target_old_sigaction *old_act;struct target_sigaction act, oact, *pact;if (arg2) {
@@ -2162,6 +2163,33 @@ old_act->sa_restorer = oact.sa_restorer;unlock_user_struct (old_act, arg3,1 ); } +#else +struct target_sigaction act, oact, *pact, *old_act; + +if (arg2) { +lock_user_struct (old_act, arg2,1 ); + act._sa_handler = old_act->_sa_handler; +target_siginitset (&act.sa_mask, old_act->sa_mask.sig[0 ]); + act.sa_flags = old_act->sa_flags; +unlock_user_struct (old_act, arg2,0 ); + pact = &act; + }else { + pact =NULL ; + } + + ret =get_errno (do_sigaction (arg1, pact, &oact)); + +if (!is_error (ret) && arg3) { +lock_user_struct (old_act, arg3,0 ); + old_act->_sa_handler = oact._sa_handler; + old_act->sa_flags = oact.sa_flags; + old_act->sa_mask.sig[0 ] = oact.sa_mask.sig[0 ]; + old_act->sa_mask.sig[1 ] =0 ; + old_act->sa_mask.sig[2 ] =0 ; + old_act->sa_mask.sig[3 ] =0 ; +unlock_user_struct (old_act, arg3,1 ); + } +#endif }break ;case TARGET_NR_rt_sigaction:
Index: linux-user/syscall_defs.h
===================================================================
RCS file: /sources/qemu/qemu/linux-user/syscall_defs.h,v retrieving revision 1.26
syscall_defs.h +10 -0
@@ -448,6 +448,15 @@#endif +#if defined(TARGET_MIPS) + +struct target_sigaction { + target_ulong sa_flags; + target_ulong _sa_handler; + target_sigset_t sa_mask; +}; + +#else struct target_old_sigaction { target_ulong _sa_handler; target_ulong sa_mask;
@@ -461,6 +470,7 @@target_ulong sa_restorer;target_sigset_t sa_mask; }; +#endif typedef union target_sigval { int sival_int;
Quoted 5 lines · Raphaël Rigo
Hello,
this patch adds signal handling for mips-user (and mipsel also). However it doesn't implementsetup_rt_frame, but it seems it is not used a lot, so the current patch should support the vast majority of applications.
Note that some web servers and other networking programs that you might want to use depend on setup_rt_frame.
It is used by code which uses queued SIGIO signals for event queuing (it's the old "scalable I/O" method before epoll replaced it), and it's also used by code that uses dnotify to check for file changes. I think Samba may also use it in conjunction with F_SETLEASE.
Since you seem to be aiming at networking support, I thought to mention this...
Enjoy,
-- Jamie
Quoted 15 lines · Jamie Lokier
Quoted 4 lines · Raphaël Rigo
Hello,
this patch adds signal handling for mips-user (and mipsel also).
However it doesn't implementsetup_rt_frame, but it seems it is not used a lot, so the current patch should support the vast majority of applications.Note that some web servers and other networking programs that you might want to use depend on
setup_rt_frame.It is used by code which uses queued SIGIO signals for event queuing (it's the old "scalable I/O" method before epoll replaced it), and it's also used by code that uses dnotify to check for file changes. I think Samba may also use it in conjunction with
F_SETLEASE.
Quoted 6 lines
Since you seem to be aiming at networking support, I thought to mention this...
Enjoy,
-- Jamie
The program I wrote the patch for doesn't use them. But it shouldn't be very hard to add support for setup_rt_frame, I'll try to add it in the coming weeks. But the current patch can be very useful already :)
Thanks for pointing this.
Regards,
Raphaël