From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FGMVw-0002j5-V1 for qemu-devel@nongnu.org; Mon, 06 Mar 2006 15:41:10 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FGMVs-0002eE-9U for qemu-devel@nongnu.org; Mon, 06 Mar 2006 15:41:07 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FGJxT-0003oK-RQ for qemu-devel@nongnu.org; Mon, 06 Mar 2006 12:57:23 -0500 Received: from [195.135.220.15] (helo=mx2.suse.de) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FGGLT-0002vF-PC for qemu-devel@nongnu.org; Mon, 06 Mar 2006 09:05:56 -0500 Received: from Relay1.suse.de (mail2.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 343711CC2B for ; Mon, 6 Mar 2006 15:03:19 +0100 (CET) From: Ulrich Hecht Subject: Re: [Qemu-devel] qemu regression 0.7.2 -> 0.8.0 (ARM user emulation) Date: Mon, 6 Mar 2006 15:03:18 +0100 References: <5b5833aa0603011418j33a74eb4ob9bde3906cad8790@mail.gmail.com> In-Reply-To: <5b5833aa0603011418j33a74eb4ob9bde3906cad8790@mail.gmail.com> MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_mEEDEfEDRxiwggX" Message-Id: <200603061503.18426.uli@suse.de> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --Boundary-00=_mEEDEfEDRxiwggX Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi! On Wednesday 01 March 2006 23:18, Anderson Lizardo wrote: > I was having some issues with the latest qemu (ARM user emulation), > which I tracked down to the following reduced test case: > > #include > int main(void) > { > float a, b; > a = 0.1f; > b = 0.8f; > printf("a < b: %d\n", (a < b)); > return 0; > } This fails because of a bug in the glue code between NWFPE and QEMU. (It relies on a specific layout of the CPUARMState structure.) Fix attached. CU Uli --Boundary-00=_mEEDEfEDRxiwggX Content-Type: text/x-diff; charset="iso-8859-1"; name="qemu-nwfpe-cpsr.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="qemu-nwfpe-cpsr.patch" diff -ru qemu-0.8.0/linux-user/main.c qemu-0.8.0.fixed/linux-user/main.c --- qemu-0.8.0/linux-user/main.c 2005-12-19 23:51:53.000000000 +0100 +++ qemu-0.8.0.fixed/linux-user/main.c 2006-03-06 14:21:49.000000000 +0100 @@ -345,7 +345,7 @@ /* we get the opcode */ opcode = ldl_raw((uint8_t *)env->regs[15]); - if (EmulateAll(opcode, &ts->fpa, env->regs) == 0) { + if (EmulateAll(opcode, &ts->fpa, env) == 0) { info.si_signo = SIGILL; info.si_errno = 0; info.si_code = TARGET_ILL_ILLOPN; diff -ru qemu-0.8.0/target-arm/nwfpe/fpa11.c qemu-0.8.0.fixed/target-arm/nwfpe/fpa11.c --- qemu-0.8.0/target-arm/nwfpe/fpa11.c 2005-12-19 23:51:53.000000000 +0100 +++ qemu-0.8.0.fixed/target-arm/nwfpe/fpa11.c 2006-03-06 14:19:43.000000000 +0100 @@ -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; diff -ru qemu-0.8.0/target-arm/nwfpe/fpa11.h qemu-0.8.0.fixed/target-arm/nwfpe/fpa11.h --- qemu-0.8.0/target-arm/nwfpe/fpa11.h 2005-12-19 23:51:53.000000000 +0100 +++ qemu-0.8.0.fixed/target-arm/nwfpe/fpa11.h 2006-03-06 14:58:21.000000000 +0100 @@ -26,6 +26,8 @@ #include #include +#include + #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" --Boundary-00=_mEEDEfEDRxiwggX--