qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] multi-bytes nop and 64bits
@ 2009-04-20 17:51 Mark Karpeles
  2009-04-20 22:10 ` malc
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Karpeles @ 2009-04-20 17:51 UTC (permalink / raw)
  To: qemu-devel

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

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-04-21 22:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-20 17:51 [Qemu-devel] multi-bytes nop and 64bits Mark Karpeles
2009-04-20 22:10 ` malc
2009-04-21  5:50   ` M. Karpelès
2009-04-21  6:38   ` Mark Karpeles
2009-04-21 17:20     ` malc
2009-04-21 17:39       ` [Qemu-devel] [PATCH] " Mark Karpeles
2009-04-21 18:11         ` Avi Kivity
2009-04-21 22:30         ` malc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).