From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lvxek-0005p1-IL for qemu-devel@nongnu.org; Mon, 20 Apr 2009 13:51:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lvxei-0005nd-E9 for qemu-devel@nongnu.org; Mon, 20 Apr 2009 13:51:45 -0400 Received: from [199.232.76.173] (port=38961 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lvxei-0005nO-5y for qemu-devel@nongnu.org; Mon, 20 Apr 2009 13:51:44 -0400 Received: from smtp23.services.sfr.fr ([93.17.128.21]:5525) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lvxeh-00056a-Ow for qemu-devel@nongnu.org; Mon, 20 Apr 2009 13:51:43 -0400 Received: from filter.sfr.fr (localhost [127.0.0.1]) by msfrf2312.sfr.fr (SMTP Server) with ESMTP id 2008E7000095 for ; Mon, 20 Apr 2009 19:51:42 +0200 (CEST) Received: from [77.207.3.30] (unknown [77.207.3.30]) by msfrf2312.sfr.fr (SMTP Server) with ESMTP id 091587000094 for ; Mon, 20 Apr 2009 19:51:42 +0200 (CEST) From: Mark Karpeles Content-Type: text/plain Date: Mon, 20 Apr 2009 19:51:39 +0200 Message-Id: <1240249899.9112.2867.camel@localhost> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] multi-bytes nop and 64bits 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 Hello, I'm having some troubles with multibytes nops in qemu 0.10.1. After following the initial 2006 thread : http://www.mail-archive.com/qemu-devel@nongnu.org/msg06470.html I found out that support for 64bits system wasn't 100% sure. Code given to gas: //nopl 0x0(%rax) .byte 0x0f, 0x1f, 0x40, 0x00 jmp EXT_C(init_paging) Dumped by objdump: ffffffffc0001000 <_text>: ffffffffc0001000: 0f 1f 40 00 nopl 0x0(%rax) ffffffffc0001004: e9 29 51 00 00 jmpq ffffffffc0006132 ffffffffc0001009: 00 00 add %al,(%rax) As seen by qemu (QEMU PC emulator version 0.10.1): 0x0000000000201000: (bad) 0x0000000000201002: add %bpl,%cl 0x0000000000201005: sub %edx,0x0(%rcx) 0x0000000000201008: add %al,(%rax) 0x000000000020100a: add %al,(%rax) (The code after this line is not meant to be executed, it's read-only data, and so the system will crash) Because the system I'm compiling code on supports multibytes nops, gcc will use those in some parts of the generated code, rendering it unusable under qemu. I'll add some flags to avoid this for now, however as qemu has (partial) support for multibytes nops, I believe this is something that should be fixed. The bytecodes are documented in intel manual 2B, "NOP" chapter. NOP operations can be up to 9 bytes long. Valid NOP bytecodes are (according to Intel manual): 90H 66 90H 0F 1F 00H 0F 1F 40 00H (this is mine) 0F 1F 44 00 00H 66 0F 1F 44 00 00H 0F 1F 80 00 00 00 00H 0F 1F 84 00 00 00 00 00H 66 0F 1F 84 00 00 00 00 00H I didn't test with an older qemu to see if it works, I'll eventually try if this problem can't be easily solved by someone who knows qemu better than I do (this is not going to be hard). Best regards, Mark Karpeles