From: Mark Karpeles <mark@hell.ne.jp>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] multi-bytes nop and 64bits
Date: Mon, 20 Apr 2009 19:51:39 +0200 [thread overview]
Message-ID: <1240249899.9112.2867.camel@localhost> (raw)
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
next reply other threads:[~2009-04-20 17:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-20 17:51 Mark Karpeles [this message]
2009-04-20 22:10 ` [Qemu-devel] multi-bytes nop and 64bits 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1240249899.9112.2867.camel@localhost \
--to=mark@hell.ne.jp \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).