From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GIViX-00082E-EQ for qemu-devel@nongnu.org; Wed, 30 Aug 2006 15:27:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GIViU-0007zI-3u for qemu-devel@nongnu.org; Wed, 30 Aug 2006 15:27:15 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GIViT-0007z4-Sp for qemu-devel@nongnu.org; Wed, 30 Aug 2006 15:27:13 -0400 Received: from [66.249.92.175] (helo=ug-out-1314.google.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GIVrw-0007af-7k for qemu-devel@nongnu.org; Wed, 30 Aug 2006 15:37:00 -0400 Received: by ug-out-1314.google.com with SMTP id s2so351580uge for ; Wed, 30 Aug 2006 12:27:12 -0700 (PDT) Message-ID: Date: Wed, 30 Aug 2006 23:27:11 +0400 From: "Igor Kovalenko" Subject: Re: [Qemu-devel] [PATCH] handle multibyte NOPs In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_41332_2874775.1156966031570" References: <200608190128.12476.paul@codesourcery.com> 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 ------=_Part_41332_2874775.1156966031570 Content-Type: multipart/alternative; boundary="----=_Part_41333_31523152.1156966031570" ------=_Part_41333_31523152.1156966031570 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/21/06, malc wrote: > > On Mon, 21 Aug 2006, Igor Kovalenko wrote: > > > On 8/21/06, malc wrote: > >> > >> On Mon, 21 Aug 2006, Igor Kovalenko wrote: > >> > >> > >> > >> > Right. Here is the real one with correct case labels. > >> > >> Sorry, forgot to mention that atop of the hex/bin problem the code also > >> suffers from lack of proper 16/64 bit modrm decoding. > > > > > > seems to me that 16 and 64 bit cases does not apply here > > Well, quick experiment in vm86 environment suggests that i'm right at > least for 16bit case. > > > xor ax, ax > int 16h > db 0xf, 0x19, 5, 0xde, 0xad > db 0xf, 0x19, 5, 0xbe, 0xef > mov ah, 9 > mov dx, erm > add dx, 0x100 > int 21h > xor ax, ax > int 16h > ret > erm db "moo$" > > > nasm -o moo.com moo.asm > dosemu moo.com > > 64bit case should be investigated by someone who possesses 64bit OS. > Here is the updated patch, should implement 16/32/64 modes according to public intel docs. Operand size is taken from DisassContext->dflag which is set beforehand; I assume it is decoded correctly wrt appropriate instruction prefixes. -- Kind Regards, Igor V. Kovalenko ------=_Part_41333_31523152.1156966031570 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/21/06, malc <malc@pulsesoft.com> wrote:
On Mon, 21 Aug 2006, Igor Kovalenko wrote:

> On 8/21/06, malc <malc@pulsesoft.com> wrote:
>>
>> On Mon, 21 Aug 2006, Igor Kovalenko wrote:
>>
>> <snip>
>>
>> > Right. Here is the real one with correct case labels.
>>
>> Sorry, forgot to mention that atop of the hex/bin problem the code also
>> suffers from lack of proper 16/64 bit modrm decoding.
>
>
> seems to me that 16 and 64 bit cases does not apply here

Well, quick experiment in vm86 environment suggests that i'm right at
least for 16bit case.

<moo.asm>
         xor ax, ax
         int 16h
         db 0xf, 0x19, 5, 0xde, 0xad
         db 0xf, 0x19, 5, 0xbe, 0xef
         mov ah, 9
         mov dx, erm
         add dx, 0x100
         int 21h
         xor ax, ax
         int 16h
         ret
erm     db     "moo$"
</moo.asm>

nasm -o moo.com moo.asm
dosemu moo.com

64bit case should be investigated by someone who possesses 64bit OS.

Here is the updated patch, should implement 16/32/64 modes according to public intel docs.
Operand size is taken from DisassContext->dflag which is set beforehand; I assume it is decoded correctly wrt appropriate instruction prefixes.

--
Kind Regards,
Igor V. Kovalenko ------=_Part_41333_31523152.1156966031570-- ------=_Part_41332_2874775.1156966031570 Content-Type: text/plain; name=x86-multibyte-noop-6.diff; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: base64 X-Attachment-Id: f_eri3i4h9 Content-Disposition: attachment; filename="x86-multibyte-noop-6.diff" SW5kZXg6IHRhcmdldC1pMzg2L3RyYW5zbGF0ZS5jCj09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KUkNTIGZpbGU6IC9jdnNy b290L3FlbXUvcWVtdS90YXJnZXQtaTM4Ni90cmFuc2xhdGUuYyx2CnJldHJpZXZpbmcgcmV2aXNp b24gMS41OQpkaWZmIC11IC1yMS41OSB0cmFuc2xhdGUuYwotLS0gdGFyZ2V0LWkzODYvdHJhbnNs YXRlLmMJMTAgSnVsIDIwMDYgMTk6NTM6MDQgLTAwMDAJMS41OQorKysgdGFyZ2V0LWkzODYvdHJh bnNsYXRlLmMJMzAgQXVnIDIwMDYgMTk6MTk6NDUgLTAwMDAKQEAgLTE2MTUsNiArMTYxNSw2MyBA QAogICAgICpvZmZzZXRfcHRyID0gZGlzcDsKIH0KIAorc3RhdGljIHZvaWQgZ2VuX25vcF9tb2Ry bShEaXNhc0NvbnRleHQgKnMsIGludCBtb2RybSkKK3sKKyAgICBpbnQgcm0sIG1vZDsKKyAgICBy bSAgPSBtb2RybSAmIDc7CisgICAgbW9kID0gKG1vZHJtID4+IDYpICYgMzsKKworICAgIHN3aXRj aCAocy0+ZGZsYWcpCisgICAgeworICAgICAgICBjYXNlIDA6CisgICAgICAgICAgICAvKiAxNiBi aXQgKi8KKyAgICAgICAgICAgIGlmIChtb2QgPT0gMCAmJiBybSA9PSA2KQorICAgICAgICAgICAg eworICAgICAgICAgICAgICAgIC8qIDE2IGJpdCBkYXRhIGZvbGxvd3MgKi8KKyAgICAgICAgICAg ICAgICBzLT5wYyArPSAyOworICAgICAgICAgICAgfQorICAgICAgICAgICAgZWxzZSBpZiAobW9k IDwgMykKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAgICAvKiAwLCA4IG9yIDE2IGJpdCBk YXRhIGZvbGxvd3MgKi8KKyAgICAgICAgICAgICAgICBzLT5wYyArPSBtb2Q7CisgICAgICAgICAg ICB9CisgICAgICAgICAgICBicmVhazsKKworICAgICAgICBjYXNlIDI6CisgICAgICAgICAgICAv KiA2NCBiaXQsIG1vZHIvbSBzaXplIGRvZXMgbm90IGNoYW5nZSwgdXNlIDMyIGJpdCBjYXNlICov CisgICAgICAgIGNhc2UgMToKKyAgICAgICAgICAgIC8qMzIgYml0Ki8KKyAgICAgICAgICAgIGlm IChtb2QgPT0gMCAmJiBybSA9PSA1KQorICAgICAgICAgICAgeworICAgICAgICAgICAgICAgLyog MzIgYml0IGRhdGEgZm9sbG93cyAqLworICAgICAgICAgICAgICAgcy0+cGMgKz0gNDsKKyAgICAg ICAgICAgIH0KKyAgICAgICAgICAgIGVsc2UKKyAgICAgICAgICAgIHsKKyAgICAgICAgICAgICAg ICBpZiAobW9kIDwgMyAmJiBybSA9PSA0KQorICAgICAgICAgICAgICAgIHsKKyAgICAgICAgICAg ICAgICAgICAgLyogU0lCIGJ5dGUgZm9sbG93cyAqLworICAgICAgICAgICAgICAgICAgICBzLT5w YyArPSAxOworICAgICAgICAgICAgICAgIH0KKworICAgICAgICAgICAgICAgIGlmIChtb2QgPT0g MSkKKyAgICAgICAgICAgICAgICB7CisgICAgICAgICAgICAgICAgICAgIC8qIDggYml0IGRhdGEg Zm9sbG93cyAqLworICAgICAgICAgICAgICAgICAgICBzLT5wYyArPSAxOworICAgICAgICAgICAg ICAgIH0KKyAgICAgICAgICAgICAgICBlbHNlIGlmIChtb2QgPT0gMSkKKyAgICAgICAgICAgICAg ICB7CisgICAgICAgICAgICAgICAgICAgIC8qIDMyIGJpdCBkYXRhIGZvbGxvd3MgKi8KKyAgICAg ICAgICAgICAgICAgICAgcy0+cGMgKz0gNDsKKyAgICAgICAgICAgICAgICB9CisgICAgICAgICAg ICB9CisgICAgICAgICAgICBicmVhazsKKyAgICAgICAgZGVmYXVsdDoKKyAgICAgICAgICAgIC8q IHVuZGVmaW5lZCAqLworICAgICAgICAgICAgYnJlYWs7CisgICAgfQorfQorCiAvKiB1c2VkIGZv ciBMRUEgYW5kIE1PViBBWCwgbWVtICovCiBzdGF0aWMgdm9pZCBnZW5fYWRkX0EwX2RzX3NlZyhE aXNhc0NvbnRleHQgKnMpCiB7CkBAIC01NzkyLDkgKzU4NDksMTUgQEAKICAgICAgICAgICAgIC8q IG5vdGhpbmcgbW9yZSB0byBkbyAqLwogICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgIGRlZmF1 bHQ6Ci0gICAgICAgICAgICBnb3RvIGlsbGVnYWxfb3A7CisgICAgICAgICAgICBnZW5fbm9wX21v ZHJtKHMsIG1vZHJtKTsKKyAgICAgICAgICAgIGJyZWFrOwogICAgICAgICB9CiAgICAgICAgIGJy ZWFrOworICAgIGNhc2UgMHgxMTkgLi4uIDB4MTFmOgorICAgICAgICAvKiBtdWx0aS1ieXRlIG5v b3AgKi8KKyAgICAgICAgbW9kcm0gPSBsZHViX2NvZGUocy0+cGMrKyk7CisgICAgICAgIGdlbl9u b3BfbW9kcm0ocywgbW9kcm0pOworICAgICAgICBicmVhazsKICAgICBjYXNlIDB4MTIwOiAvKiBt b3YgcmVnLCBjck4gKi8KICAgICBjYXNlIDB4MTIyOiAvKiBtb3YgY3JOLCByZWcgKi8KICAgICAg ICAgaWYgKHMtPmNwbCAhPSAwKSB7Cg== ------=_Part_41332_2874775.1156966031570--