Patch day
Subsystems (2)
Hi!
Here's the current lot of patches from the SuSE QEMU package. As we have now arrived at the point where patches start to conflict with each other, I would be very grateful if at least some of these went into the next release.
qemu-0.7.0-binfmt.patch: some enhancements to the qemu-binfmt-conf.sh script
qemu-0.7.1-armfpaex.patch: proper FPA exception generation for arm-user targets
qemu-0.7.1-jobsignals.patch: handle SIGTTOU/SIGTTIN/SIGTSTP; makes job control work
qemu-0.7.1-syscalls.patch: implements acct, uselib, syslog, mincore, madvise, readahead, clock_gettime; I have not extensively checked these for correctness, but from experience I can say that with this patch applied a lot of breakage vanishes
qemu-0.8.0-ia64.patch: Itanium host fixes by Andreas Schwab
qemu-nwfpe-cpsr.patch: fixes ARM FPA CPSR updates; same as posted before, but fixed to work with qemu-0.7.1-armfpaex.patch
CU
Uli
qemu-binfmt-conf.sh +19 -11
@@ -2,38 +2,46 @@ # enable automatic i386/ARM/SPARC/PPC program execution by the kernel # load the binfmt_misc module -/sbin/modprobe binfmt_misc + +if test ! -e /proc/sys/fs/binfmt_misc/register +then + /sbin/modprobe binfmt_misc + mount -t binfmt_misc none /proc/sys/fs/binfmt_misc +fi # probe cpu type cpu=`uname -m` case "$cpu" in - i386|i486|i586|i686|i86pc|BePC) + i386|i486|i586|i686|i86pc|BePC|x86_64) cpu="i386" ;; "Power Macintosh"|ppc|ppc64) cpu="ppc" ;; - armv4l) + armv[4-9]*l) cpu="arm" ;; + sparc*) + cpu="sparc" + ;; esac # register the interpreter for each cpu except for the native one if [ $cpu != "i386" ] ; then - echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register - echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register + echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register + echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "arm" ] ; then - echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register - echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register + echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register + echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "sparc" ] ; then - echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register + echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "ppc" ] ; then - echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register + echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register fi if [ $cpu != "mips" ] ; then - echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register - echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register + echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register + echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register fi
main.c +38 -2
@@ -339,18 +339,54 @@ {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 */ +int arm_fpe=0 ; +/* translate softfloat flags to FPSR flags */ +if (-rc & float_flag_invalid) arm_fpe |=BIT_IOC ; +if (-rc & float_flag_divbyzero) arm_fpe |=BIT_DZC ; +if (-rc & float_flag_overflow) arm_fpe |=BIT_OFC ; +if (-rc & float_flag_underflow) arm_fpe |=BIT_UFC ; +if (-rc & float_flag_inexact) arm_fpe |=BIT_IXC ; + +FPSR fpsr = ts->fpa.fpsr; +//printf("fpsr 0x%x, arm_fpe 0x%x\n",fpsr,arm_fpe); + +if (fpsr & (arm_fpe <<16 ))/* exception enabled? */ + { + info.si_signo =SIGFPE ; + info.si_errno =0 ; +/* ordered by priority, least first */ +if (arm_fpe &BIT_IXC ) info.si_code =TARGET_FPE_FLTRES ; +if (arm_fpe &BIT_UFC ) info.si_code =TARGET_FPE_FLTUND ; +if (arm_fpe &BIT_OFC ) info.si_code =TARGET_FPE_FLTOVF ; +if (arm_fpe &BIT_DZC ) info.si_code =TARGET_FPE_FLTDIV ; +if (arm_fpe &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 )) && (arm_fpe &BIT_IXC )) fpsr |=BIT_IXC ; +if ((!(fpsr &BIT_UFE )) && (arm_fpe &BIT_UFC )) fpsr |=BIT_UFC ; +if ((!(fpsr &BIT_OFE )) && (arm_fpe &BIT_OFC )) fpsr |=BIT_OFC ; +if ((!(fpsr &BIT_DZE )) && (arm_fpe &BIT_DZC )) fpsr |=BIT_DZC ; +if ((!(fpsr &BIT_IOE )) && (arm_fpe &BIT_IOC )) fpsr |=BIT_IOC ; + ts->fpa.fpsr=fpsr; + }else {/* everything OK */ /* increment PC */ env->regs[15 ] +=4 ; }
nwfpe/fpa11.c +7 -0
@@ -161,6 +161,8 @@ fpa11->initflag =1 ; } +set_float_exception_flags (0 , &fpa11->fp_status); +if (TEST_OPCODE (opcode,MASK_CPRT )) {//fprintf(stderr,"emulating CPRT\n");
@@ -190,6 +192,11 @@ }// restore_flags(flags); +if (nRc ==1 &&get_float_exception_flags (&fpa11->fp_status)) + { +//printf("fef 0x%x\n",float_exception_flags); + nRc=-get_float_exception_flags (&fpa11->fp_status); + }//printf("returning %d\n",nRc); return (nRc);
signal.c +6 -1
@@ -341,10 +341,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 */
arm/syscall_nr.h +1 -0
@@ -259,4 +259,5 @@/* 254 for set_thread_area */ /* 255 for get_thread_area */ /* 256 for set_tid_address */ +#define TARGET_NR_clock_gettime (263)#define TARGET_NR_utimes (269)
syscall.c +35 -6
98 lines not on this page · raw message
--- Makefile.target | 3 --- cpu-exec.c | 3 +-- dyngen.c | 6 ++++-- dyngen.h | 3 +++ linux-user/syscall.c | 2 +- target-mips/exec.h | 4 ++++ 6 files changed, 13 insertions(+), 8 deletions(-)
Makefile.target renamed from Makefile.target.orig +0 -3
@@ -252,9 +252,6 @@ ifeq ($(findstring m68k, $(TARGET_ARCH) LIBOBJS+=m68k-dis.o endif -ifeq ($(ARCH),ia64) -OBJS += ia64-syscall.o -endif ifdef CONFIG_GDBSTUB OBJS+=gdbstub.o endif
cpu-exec.c renamed from cpu-exec.c.orig +1 -2
@@ -1351,7 +1351,6 @@ int cpu_signal_handler(int host_signum,#ifndef __ISR_VALID/* This ought to be in <bits/siginfo.h>... */ # define __ISR_VALID 1 -# define si_flags _sifields._sigfault._si_pad0#endif int cpu_signal_handler (int host_signum,struct siginfo *info,void *puc)
@@ -1367,7 +1366,7 @@ int cpu_signal_handler(int host_signum,case SIGSEGV :case SIGBUS :case SIGTRAP : -if (info->si_code && (info->si_flags & __ISR_VALID)) +if (info->si_code && (info->si_segvflags & __ISR_VALID))/* ISR.W (write-access) is bit 33: */ is_write = (info->si_isr >>33 ) &1 ;break ;
dyngen.c renamed from dyngen.c.orig +4 -2
@@ -2469,10 +2469,12 @@ fprintf(outfile, );#ifdef HOST_IA64 fprintf (outfile, -" ia64_apply_fixes(&gen_code_ptr, ltoff_fixes, " +" {\n" +" extern char code_gen_buffer[];\n" +" ia64_apply_fixes(&gen_code_ptr, ltoff_fixes, " "(uint64_t) code_gen_buffer + 2*(1<<20), plt_fixes,\n\t\t\t" "sizeof(plt_target)/sizeof(plt_target[0]),\n\t\t\t" -"plt_target, plt_offset);\n" ); +"plt_target, plt_offset);\n }\n" );#endif /* generate some code patching */
dyngen.h renamed from dyngen.h.orig +3 -0
@@ -420,6 +420,9 @@ static inline void ia64_apply_fixes (uin }ia64_imm22 (fixup->addr, (long ) vp - gp); } +/* Keep code ptr aligned. */ +if ((long ) gen_code_ptr &15 ) + gen_code_ptr +=8 ; *gen_code_pp = gen_code_ptr; }
syscall.c renamed from syscall.c.orig +1 -1
@@ -1513,7 +1513,7 @@ int do_fork(CPUState *env, unsigned int#endif new_env->opaque = ts;#ifdef __ia64__ - ret =clone2 (clone_func, new_stack +NEW_STACK_SIZE , flags, new_env); + ret =__clone2 (clone_func, new_stack +NEW_STACK_SIZE , flags, new_env);#else ret =clone (clone_func, new_stack +NEW_STACK_SIZE , flags, new_env);#endif
exec.h renamed from exec.h.orig +4 -0
@@ -31,7 +31,11 @@ register double FT2 asm(FREG2);#endif #if defined (DEBUG_OP ) +#if defined (__ia64__) +#define RETURN () __asm__ __volatile__("nop 0"); +#else #define RETURN () __asm__ __volatile__("nop"); +#endif #else #define RETURN () __asm__ __volatile__("");#endif
linux-user/main.c +1 -1
@@ -346,7 +346,7 @@/* we get the opcode */ opcode =ldl_raw ((uint8_t *)env->regs[15 ]); -if ((rc=EmulateAll (opcode, &ts->fpa, env->regs)) ==0 ) {/* illegal instruction */ +if ((rc=EmulateAll (opcode, &ts->fpa, env)) ==0 ) {/* illegal instruction */ info.si_signo =SIGILL ; info.si_errno =0 ; info.si_code =TARGET_ILL_ILLOPN ;
target-arm/nwfpe/fpa11.c +2 -2
@@ -36,7 +36,7 @@unsigned int EmulateCPRT (const unsigned int );FPA11 * qemufpa=0 ; -unsigned int * user_registers=0 ; +CPUARMState * user_registers=0 ;/* Reset the FPA11 chip. Called to initialize and reset the emulator. */ void resetFPA11 (void )
@@ -137,7 +137,7 @@ }/* Emulate the instruction in the opcode. */ -unsigned int EmulateAll (unsigned int opcode,FPA11 * qfpa,unsigned int * qregs) +unsigned int EmulateAll (unsigned int opcode,FPA11 * qfpa,CPUARMState * qregs) {unsigned int nRc =0 ;// unsigned long flags;
target-arm/nwfpe/fpa11.h +7 -22
@@ -26,6 +26,8 @@#include <stdio.h> #include <errno.h> +#include <cpu.h> +#define GET_FPA11 () (qemufpa)/*
@@ -33,7 +35,7 @@* stack+task struct. Use the same method as 'current' uses to * reach them. */ -extern unsigned int *user_registers; +extern CPUARMState *user_registers;#define GET_USERREG () (user_registers)
@@ -94,7 +96,7 @@static inline unsigned int readRegister (unsigned int reg) { -return (user_registers[(reg)]); +return (user_registers->regs[(reg)]); }static inline void writeRegister (unsigned int x,unsigned int y)
@@ -102,34 +104,17 @@#if 0 printf ("writing %d to r%d\n" ,y,x);#endif - user_registers[(x)]=(y); + user_registers->regs[(x)]=(y); }static inline void writeConditionCodes (unsigned int x) { -#if 0 -unsigned int y; -unsigned int ZF ; -printf ("setting flags to %x from %x\n" ,x,user_registers[16 ]); -#endif - user_registers[16 ]=(x);// cpsr - user_registers[17 ]=(x>>29 )&1 ;// cf - user_registers[18 ]=(x<<3 )&(1 <<31 );// vf - user_registers[19 ]=x&(1 <<31 );// nzf -if (!(x&(1 <<30 ))) user_registers[19 ]++;// nzf must be non-zero for zf to be cleared - -#if 0 -ZF = (user_registers[19 ] ==0 ); - y=user_registers[16 ] | (user_registers[19 ] &0x80000000 ) | (ZF <<30 ) | - (user_registers[17 ] <<29 ) | ((user_registers[18 ] &0x80000000 ) >>3 ); -if (y != x) -printf ("GODDAM SHIIIIIIIIIIIIIIIIT! %x %x nzf %x zf %x\n" ,x,y,user_registers[19 ],ZF ); -#endif +cpsr_write (user_registers,x,~CPSR_M ); }#define REG_PC 15 -unsigned int EmulateAll (unsigned int opcode,FPA11 * qfpa,unsigned int * qregs); +unsigned int EmulateAll (unsigned int opcode,FPA11 * qfpa,CPUARMState * qregs);/* included only for get_user/put_user macros */ #include "qemu.h"