*-user fixes
Hi!
qemu-sigfpe.patch:
send SIGFPE in case of ARM FPA exceptions. No idea if this is 100% correct, but it's good enough to convince the glibc test suite.
qemu-syscalls.patch:
some trivial syscall implementations; I only needed (and tested) madvise, but while I was there I noticed a number of other syscalls that can be implemented without much effort.
qemu-jobsignals.patch:
proper SIGTSTP/SIGCONT default handling; makes suspending/resuming my editor work.
CU
Uli
Index: linux-user/main.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/main.c,v
retrieving revision 1.61
main.c +24 -1
@@ -325,17 +325,40 @@ {TaskState *ts = env->opaque;uint32_t opcode; +int rc;/* we handle the FPU emulation here, as Linux */ /* we get the opcode */ opcode =ldl_raw ((uint8_t *)env->regs[15 ]); -if (EmulateAll (opcode, &ts->fpa, env->regs) ==0 ) { +/* copied from softfloat library */ +enum { + float_flag_invalid =1 , + float_flag_divbyzero =2 , + float_flag_overflow =4 , + float_flag_underflow =8 , + float_flag_inexact =16 + }; + +if ((rc=EmulateAll (opcode, &ts->fpa, env->regs)) ==0 ) { info.si_signo =SIGILL ; info.si_errno =0 ; info.si_code =TARGET_ILL_ILLOPN ; info._sifields._sigfault._addr = env->regs[15 ];queue_signal (info.si_signo, &info); + }else if (rc <0 && rc != -float_flag_inexact) { + info.si_signo =SIGFPE ; + info.si_errno =0 ; +switch (-rc) + { +case float_flag_invalid: info.si_code =TARGET_FPE_FLTINV ;break ; +case float_flag_divbyzero: info.si_code =TARGET_FPE_FLTDIV ;break ; +case float_flag_overflow: info.si_code =TARGET_FPE_FLTOVF ;break ; +case float_flag_underflow: info.si_code =TARGET_FPE_FLTUND ;break ; +default :break ; + } + info._sifields._sigfault._addr = env->regs[15 ]; +queue_signal (info.si_signo, &info); }else {/* increment PC */ env->regs[15 ] +=4 ;
Index: target-arm/nwfpe/fpa11.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/nwfpe/fpa11.c,v retrieving revision 1.1
nwfpe/fpa11.c +5 -0
@@ -185,6 +185,11 @@ }// restore_flags(flags); +if (nRc ==1 && float_exception_flags) + { +//printf("fef 0x%x\n",float_exception_flags); + nRc=-float_exception_flags; + }//printf("returning %d\n",nRc); return (nRc);
Index: linux-user/signal.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/signal.c,v retrieving revision 1.27
signal.c +6 -1
@@ -348,10 +348,15 @@ k = &sigact_table[sig -1 ]; handler = k->sa._sa_handler;if (handler ==TARGET_SIG_DFL ) { +if (sig ==TARGET_SIGTSTP || sig ==TARGET_SIGTTIN || sig ==TARGET_SIGTTOU ) { +kill (getpid (),SIGSTOP ); +return 0 ; + }else /* default handler : ignore some signal. The other are fatal */ if (sig !=TARGET_SIGCHLD && sig !=TARGET_SIGURG && - sig !=TARGET_SIGWINCH ) { + sig !=TARGET_SIGWINCH && + sig !=TARGET_SIGCONT ) {force_sig (sig); }else {return 0 ;/* indicate ignored */
Index: Makefile.target
===================================================================
RCS file: /cvsroot/qemu/qemu/Makefile.target,v
retrieving revision 1.57
Makefile.target +1 -1
@@ -209,7 +209,7 @@ ######################################################### -DEFINES+=-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE +DEFINES+=-D_GNU_SOURCE -D_BSD_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE LIBS+=-lm ifndef CONFIG_USER_ONLY LIBS+=-lz
Index: linux-user/syscall.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/syscall.c,v retrieving revision 1.57
syscall.c +21 -6
@@ -207,6 +207,7 @@#define __NR_sys_getdents __NR_getdents#define __NR_sys_getdents64 __NR_getdents64#define __NR_sys_rt_sigqueueinfo __NR_rt_sigqueueinfo +#define __NR_sys_syslog __NR_syslog#if defined(__alpha__) || defined (__ia64__) || defined(__x86_64__)#define __NR__llseek __NR_lseek
@@ -228,6 +229,7 @@ _syscall2(int,sys_statfs,const char *,path,struct kernel_statfs *,buf) _syscall2(int,sys_fstatfs,int,fd,struct kernel_statfs *,buf) _syscall3(int,sys_rt_sigqueueinfo,int,pid,int,sig,siginfo_t *,uinfo) +_syscall3(int,sys_syslog,int,type,char*,bufp,int,len)#ifdef __NR_exit_group _syscall1(int,exit_group,int,error_code)#endif
@@ -241,6 +243,7 @@extern int setresgid (gid_t ,gid_t ,gid_t );extern int getresgid (gid_t *,gid_t *,gid_t *);extern int setgroups (int ,gid_t *); +extern int uselib (const char *);static inline long get_errno (long ret) {
@@ -577,7 +580,9 @@case SO_OOBINLINE :case SO_NO_CHECK :case SO_PRIORITY : +#ifdef SO_BSDCOMPAT case SO_BSDCOMPAT : +#endif case SO_PASSCRED :case SO_TIMESTAMP :case SO_RCVLOWAT :
@@ -1828,7 +1833,9 @@ goto unimplemented;case TARGET_NR_acct: - goto unimplemented; + ret =get_errno (acct (path ((const char *)arg1))); +break ; +case TARGET_NR_umount2: ret =get_errno (umount2 ((const char *)arg1, arg2));break ;
@@ -2140,7 +2147,9 @@ ret =get_errno (readlink (path ((const char *)arg1), (char *)arg2, arg3));break ;case TARGET_NR_uselib: - goto unimplemented; + ret =get_errno (uselib (path ((const char *)arg1))); +break ; +case TARGET_NR_swapon: ret =get_errno (swapon ((const char *)arg1, arg2));break ;
@@ -2255,7 +2264,9 @@ ret =do_socketcall (arg1, (int32_t *)arg2);break ;case TARGET_NR_syslog: - goto unimplemented; + ret =get_errno (sys_syslog ((int )arg1, (char *)arg2, (int )arg3)); +break ; +case TARGET_NR_setitimer: {struct target_itimerval *target_value = (void *)arg2;
@@ -3045,11 +3057,14 @@ goto unimplemented;#ifdef TARGET_NR_mincorecase TARGET_NR_mincore: - goto unimplemented; +page_unprotect_range ((void *)arg3, ((size_t )arg2 +TARGET_PAGE_SIZE -1 ) /TARGET_PAGE_SIZE ); + ret =get_errno (mincore ((void *)arg1, (size_t )arg2, (unsigned char *)arg3)); +break ;#endif #ifdef TARGET_NR_madvisecase TARGET_NR_madvise: - goto unimplemented; + ret =get_errno (madvise ((void *)arg1, (size_t )arg2, (int )arg3)); +break ;#endif #if TARGET_LONG_BITS ==32 case TARGET_NR_fcntl64:
@@ -3098,7 +3113,8 @@ ret =get_errno (gettid ());break ;case TARGET_NR_readahead: - goto unimplemented; + ret =get_errno (readahead ((int )arg1, (off64_t )arg2, (size_t )arg3)); +break ;#ifdef TARGET_NR_setxattrcase TARGET_NR_setxattr:case TARGET_NR_lsetxattr:
Quoted 3 lines · Ulrich Hecht
qemu-jobsignals.patch:
proper SIGTSTP/SIGCONT default handling; makes suspending/resuming my editor work.
I already sent a patch for this back in October, but nothing seemed to happen with it.
Jim
Hi!
Quoted 3 lines · Ulrich Hecht
qemu-sigfpe.patch:
send SIGFPE in case of ARM FPA exceptions. No idea if this is 100% correct, but it's good enough to convince the glibc test suite.
Not the python test suite, though. Here's a better fix that, as an added bonus, may actually be correct.
Quoted 8 lines
qemu-syscalls.patch:
some trivial syscall implementations; I only needed (and tested) madvise, but while I was there I noticed a number of other syscalls that can be implemented without much effort.qemu-jobsignals.patch:
proper SIGTSTP/SIGCONT default handling; makes suspending/resuming my editor work.
So what about those, Fabrice?
CU
Uli
Index: linux-user/main.c
===================================================================
RCS file: /cvsroot/qemu/qemu/linux-user/main.c,v
retrieving revision 1.61
main.c +29 -2
@@ -325,18 +325,45 @@ {TaskState *ts = env->opaque;uint32_t opcode; +int rc;/* we handle the FPU emulation here, as Linux */ /* we get the opcode */ opcode =ldl_raw ((uint8_t *)env->regs[15 ]); -if (EmulateAll (opcode, &ts->fpa, env->regs) ==0 ) { +if ((rc=EmulateAll (opcode, &ts->fpa, env->regs)) ==0 ) {/* illegal instruction */ info.si_signo =SIGILL ; info.si_errno =0 ; info.si_code =TARGET_ILL_ILLOPN ; info._sifields._sigfault._addr = env->regs[15 ];queue_signal (info.si_signo, &info); - }else { + }else if (rc <0 ) {/* FP exception */ +FPSR fpsr = ts->fpa.fpsr; +//printf("fpsr 0x%x, -rc 0x%x\n",fpsr,-rc); +if (fpsr & (-rc <<16 ))/* exception enabled? */ + { + info.si_signo =SIGFPE ; + info.si_errno =0 ; +/* ordered by priority, least first */ +if (-rc &BIT_IXC ) info.si_code =TARGET_FPE_FLTRES ; +if (-rc &BIT_UFC ) info.si_code =TARGET_FPE_FLTUND ; +if (-rc &BIT_OFC ) info.si_code =TARGET_FPE_FLTOVF ; +if (-rc &BIT_DZC ) info.si_code =TARGET_FPE_FLTDIV ; +if (-rc &BIT_IOC ) info.si_code =TARGET_FPE_FLTINV ; + info._sifields._sigfault._addr = env->regs[15 ]; +queue_signal (info.si_signo, &info); + } +else + env->regs[15 ] +=4 ; + +/* accumulate unenabled exceptions */ +if ((!(fpsr &BIT_IXE )) && (-rc &BIT_IXC )) fpsr |=BIT_IXC ; +if ((!(fpsr &BIT_UFE )) && (-rc &BIT_UFC )) fpsr |=BIT_UFC ; +if ((!(fpsr &BIT_OFE )) && (-rc &BIT_OFC )) fpsr |=BIT_OFC ; +if ((!(fpsr &BIT_DZE )) && (-rc &BIT_DZC )) fpsr |=BIT_DZC ; +if ((!(fpsr &BIT_IOE )) && (-rc &BIT_IOC )) fpsr |=BIT_IOC ; + ts->fpa.fpsr=fpsr; + }else {/* everything OK */ /* increment PC */ env->regs[15 ] +=4 ; }
Index: target-arm/nwfpe/fpa11.c
===================================================================
RCS file: /cvsroot/qemu/qemu/target-arm/nwfpe/fpa11.c,v retrieving revision 1.1
nwfpe/fpa11.c +7 -0
@@ -155,6 +155,8 @@SetRoundingPrecision (ROUND_EXTENDED ); fpa11->initflag =1 ; } + + float_exception_flags =0 ;if (TEST_OPCODE (opcode,MASK_CPRT )) {
@@ -185,6 +187,11 @@ }// restore_flags(flags); +if (nRc ==1 && float_exception_flags) + { +//printf("fef 0x%x\n",float_exception_flags); + nRc=-float_exception_flags; + }//printf("returning %d\n",nRc); return (nRc);