Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CaKnQ-0001w3-Gc for qemu-devel@nongnu.org; Fri, 03 Dec 2004 16:16:56 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CaKnP-0001vj-Sk for qemu-devel@nongnu.org; Fri, 03 Dec 2004 16:16:56 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CaKnP-0001vZ-Mq for qemu-devel@nongnu.org; Fri, 03 Dec 2004 16:16:55 -0500 Received: from [81.104.201.223] (helo=cray) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CaKdb-0004EO-U6 for qemu-devel@nongnu.org; Fri, 03 Dec 2004 16:06:48 -0500 Received: from cgb23 by cray with local (Exim 3.36 #1 (Debian)) id 1CaKek-0004FN-00 for ; Fri, 03 Dec 2004 21:07:58 +0000 Date: Fri, 3 Dec 2004 21:07:58 +0000 From: Charlie Baylis Message-ID: <20041203210758.GD21652@cray.fish.zetnet.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="FL5UXtIhxfXey3p5" Content-Disposition: inline Sender: Charlie Baylis Subject: [Qemu-devel] Qemu arm emulation 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 --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi Fabrice I have had a look at some faults in the ARM port of Qemu. I have discovered a couple of bugs. To avoid difficulties with my employer I can't distribute my patch which contains the fixes, but they are fairly trivial so I am detailing the changes required here. 1. The RRX operand shift on data processing instructions is incorrectly decoded as a rotate right (ROR) of 0 bits. RRX should have the effect of an extended rotate right of 1 bit where the carry flag is shifted into the top bit of the result. If the S bit is set, then the carry flag is set to the bottom bit of the source value. 2. Shifter carry out for immediates When an immediate value is generated the shifter carry out is set to bit31 of the resulting immediate if the shift value is non zero. If the shift value is zero, then the shifter carry out has the value of the C flag. Therefore, the following instructions should alter the carry flag when used with an immediate which has a non-zero shift. ANDS BICS EORS MOVS MVNS ORRS TEQS and TSTS (The remaining data processing instructions generate the C flag from the calculation performed by the instruction) Test case is attached as a C file and as assembler file. The assembler function f will return if these bugs are fixed and loops forever otherwise. I can email you a statically linked binary if you don't have an ARM toolchain. Apologies for not being able to just send a patch. Regards Charlie --FL5UXtIhxfXey3p5 Content-Type: text/x-csrc; charset=us-ascii Content-Disposition: attachment; filename="p.c" #include extern unsigned f(); int main(unsigned int argc, char**argv) { f(); return 0; } --FL5UXtIhxfXey3p5 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ps.s" .file "ps.s" .section .rodata .align 2 .global f f: cmp r0, r0 @ set carry flag mov r0, r0, rrx cmp r0, #0x80000000 loop1: bne loop1 cmp r0, r0 @ set carry flag tst r0, #0x04000000 loop2: bcs loop2 mov pc, lr --FL5UXtIhxfXey3p5--