qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] multi-bytes nop and 64bits


From: malc
Subject: Re: [Qemu-devel] multi-bytes nop and 64bits
Date: Tue, 21 Apr 2009 02:10:52 +0400 (MSD)

On Mon, 20 Apr 2009, Mark Karpeles wrote:

> 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/address@hidden/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
> <init_paging>
> 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)


The disassembler is disconnected from the main translation engine, so
what you see (produced by the older version of i386 disassmbler from
GNU binutils) might not be what QEMU actually translates/executes. To
be sure use gdbstub and recent GDB to see, hopefully, more coherent view.

> 
> 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).
> 

FWIW if i'm reading the sources correctly the above sequence (marked as
"mine") should work just fine with current QEMU.

-- 
mailto:address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]