From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MR6WY-0007I4-Ay for qemu-devel@nongnu.org; Wed, 15 Jul 2009 11:36:02 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MR6WT-0007CH-JZ for qemu-devel@nongnu.org; Wed, 15 Jul 2009 11:36:01 -0400 Received: from [199.232.76.173] (port=42841 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MR6WT-0007By-93 for qemu-devel@nongnu.org; Wed, 15 Jul 2009 11:35:57 -0400 Received: from mail-pz0-f196.google.com ([209.85.222.196]:41103) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MR6WS-0001r7-Mv for qemu-devel@nongnu.org; Wed, 15 Jul 2009 11:35:57 -0400 Received: by pzk34 with SMTP id 34so1564537pzk.4 for ; Wed, 15 Jul 2009 08:35:55 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <3cdfa5bc0907150833w4bf27bfj283242a7e0b5eb9a@mail.gmail.com> References: <3cdfa5bc0907150833w4bf27bfj283242a7e0b5eb9a@mail.gmail.com> Date: Wed, 15 Jul 2009 23:35:55 +0800 Message-ID: <3cdfa5bc0907150835h756ab118y39d83c9f0c1eb7e4@mail.gmail.com> From: Baojun Wang Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] Re: Misbehavior of qemu ppc tcg/translation? List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org BTW: The source code is dummy: # hello.S .data msg: .string "hello, world!\n" len =3D . - msg .text .global _raw_write _raw_write: sc blr .global _start _start: li 0, 4 li 3, 1 lis 4, msg@ha addi 4, 4, msg@l li 5, len bl _raw_write .long 0x10001234 li 0, 1 li 3, 0 sc On Wed, Jul 15, 2009 at 11:33 PM, Baojun Wang wrote: > hi, list: > > =C2=A0I hope the following example is self-explained, in the assembler > code, we can use instruction like (instruction-as-data?): > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0100000b4: =C2=A0 = =C2=A0 =C2=A0 10 00 12 34 =C2=A0 =C2=A0 .long 0x10001234 > > =C2=A0but the ppc translator set the exception flag and raise a PROGRAM > exception later, however on real machine, if the above instruction is > never ran, then everything should be OK. Thus the ppc translator raise > the exception too early? (I think it should only raise the PROGRAM > exception until tcg really trying to exec the instruction, but not on > translation time) > > =C2=A0Thanks, > Wang Baojun > > $ qemu-ppc -L emu-ppc ./hello > hello, world! > invalid/unsupported opcode: 04 - 1a - 08 (10001234) 100000b4 0 > Invalid instruction > NIP 100000b8 =C2=A0 LR 100000b4 CTR 00000000 XER 00000000 > MSR 00006040 HID0 00000000 =C2=A0HF 00006000 idx 0 > TB 00000000 00000000 > GPR00 0000000000000004 000000004007f588 0000000000000000 000000000000000f > GPR04 00000000100100c4 000000000000000f 0000000000000000 0000000000000000 > GPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > GPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > CR 00000000 =C2=A0[ - =C2=A0- =C2=A0- =C2=A0- =C2=A0- =C2=A0- =C2=A0- =C2= =A0- =C2=A0] =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 RES ffffffff > FPR00 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > FPR04 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > FPR08 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > FPR12 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > FPR16 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > FPR20 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > FPR24 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > FPR28 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > FPSCR 00000000 > Segmentation fault > > > on a real machine: > $ ./hello > hello, world! > $ powerpc-unknown-linux-gnu-objdump -d hello > > hello: =C2=A0 =C2=A0 file format elf32-powerpc > > Disassembly of section .text: > > 10000094 <_raw_write>: > 10000094: =C2=A0 =C2=A0 =C2=A0 44 00 00 02 =C2=A0 =C2=A0 sc > 10000098: =C2=A0 =C2=A0 =C2=A0 4e 80 00 20 =C2=A0 =C2=A0 blr > > 1000009c <_start>: > 1000009c: =C2=A0 =C2=A0 =C2=A0 38 00 00 04 =C2=A0 =C2=A0 li =C2=A0 =C2=A0= =C2=A0r0,4 > 100000a0: =C2=A0 =C2=A0 =C2=A0 38 60 00 01 =C2=A0 =C2=A0 li =C2=A0 =C2=A0= =C2=A0r3,1 > 100000a4: =C2=A0 =C2=A0 =C2=A0 3c 80 10 01 =C2=A0 =C2=A0 lis =C2=A0 =C2= =A0 r4,4097 > 100000a8: =C2=A0 =C2=A0 =C2=A0 38 84 00 c4 =C2=A0 =C2=A0 addi =C2=A0 =C2= =A0r4,r4,196 > 100000ac: =C2=A0 =C2=A0 =C2=A0 38 a0 00 0f =C2=A0 =C2=A0 li =C2=A0 =C2=A0= =C2=A0r5,15 > 100000b0: =C2=A0 =C2=A0 =C2=A0 4b ff ff e5 =C2=A0 =C2=A0 bl =C2=A0 =C2=A0= =C2=A010000094 <_raw_write> > 100000b4: =C2=A0 =C2=A0 =C2=A0 10 00 12 34 =C2=A0 =C2=A0 .long 0x10001234 > 100000b8: =C2=A0 =C2=A0 =C2=A0 38 00 00 01 =C2=A0 =C2=A0 li =C2=A0 =C2=A0= =C2=A0r0,1 > 100000bc: =C2=A0 =C2=A0 =C2=A0 38 60 00 00 =C2=A0 =C2=A0 li =C2=A0 =C2=A0= =C2=A0r3,0 > 100000c0: =C2=A0 =C2=A0 =C2=A0 44 00 00 02 =C2=A0 =C2=A0 sc >