[Top][All Lists]

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

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

From: Mark Karpeles
Subject: [Qemu-devel] multi-bytes nop and 64bits
Date: Mon, 20 Apr 2009 19:51:39 +0200


I'm having some troubles with multibytes nops in qemu 0.10.1.

After following the initial 2006 thread :


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

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

reply via email to

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