Received: from eggs.gnu.org ([2001:4830:134:3::10]:34501) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWRqV-0007Hu-Lh for qemu-devel@nongnu.org; Thu, 18 Feb 2016 11:54:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aWRqR-0000Wf-9d for qemu-devel@nongnu.org; Thu, 18 Feb 2016 11:54:27 -0500 Received: from nm28-vm10.bullet.mail.gq1.yahoo.com ([98.136.216.169]:42217) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aWRqR-0000Wa-0a for qemu-devel@nongnu.org; Thu, 18 Feb 2016 11:54:23 -0500 Date: Thu, 18 Feb 2016 16:53:52 +0000 (UTC) From: "Egbert S." Message-ID: <1799079795.5917055.1455814432510.JavaMail.yahoo@mail.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5917054_871331146.1455814432507" References: <1799079795.5917055.1455814432510.JavaMail.yahoo.ref@mail.yahoo.com> Subject: [Qemu-devel] flushing before updating pc.ram Reply-To: "Egbert S." List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "qemu-devel@nongnu.org" ------=_Part_5917054_871331146.1455814432507 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I have here a case (over at GitHub unicorn-engine/unicorn tests/unit/test_t= b_x86.c) that is running a stack-based Alpha-Mixed sample that contains an = instruction that changed an operand of the next instruction, the one that Q= EMU does not detect nor execute properly (even with TARGET_HAS_PRECISE_SMC = define compiled in).=C2=A0 Stack-based writeable MemoryRegion "pc.ram" star= ts at 0x60000000. Live trace of QEMU is:ecx =3D 0x5ffffff8# Modify code location 60000028 to = 0x10 from 0x51 60000021=C2=A0 304130=C2=A0 xor=C2=A0 byte ptr [ocx + 0x30], al60000024=C2= =A0 41=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 inc ecx60000025=C2=A0 6b414151 imul ea= x, dword ptr [ecx + 0x41], 0x51 In the notdirty_mem_write(), it does a tb_invalidate_phys_page_fast() first= ly before writing directly to the "pc.ram". As a result, the newly reconstructed TB rebuilds the 'imul' micro-operation= sequence , but still retrieving the original 0x51 immediate byte operand (= and not the expected 0x10). Interestingly, doing a read operation of the exact 0x60000028 byte retrieve= s that updated (and correct) 0x10. Could it be that in the notdirty_mem_write(), that stX_p() must be performe= d firstly before the tb_invalidate_phys_page_fast()? ------=_Part_5917054_871331146.1455814432507 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I have here a case (over at GitHub unicorn-engine/unicorn tests/un= it/test_tb_x86.c) that is running a stack-based Alpha-Mixed sample that con= tains an instruction that changed an operand of the next instruction, the o= ne that QEMU does not detect nor execute properly (even with TARGET_HAS_PRE= CISE_SMC define compiled in).  Stack-based writeable MemoryRegion "pc.= ram" starts at 0x60000000.


Live trace of QEMU is:
ecx =3D 0x5ffffff8
# Modify code location 60000028 to 0x10 from 0x51
=
60000021 = ; 304130  xor  byte ptr [ocx + 0x30], al
60000024  41   &nb= sp;  inc ecx
60000025  6b414151 imul eax, dword ptr [ecx + 0x41], 0x51

In the notdirty_mem_write(), it= does a tb_invalidate_phys_page_fast() firstly before writing directly to t= he "pc.ram".
<= br>
As a resul= t, the newly reconstructed TB rebuilds the 'imul' micro-operation sequence = , but still retrieving the original 0x51 immediate byte operand (and not th= e expected 0x10).

Interestingly, doing a read operation of the exact= 0x60000028 byte retrieves that updated (and correct) 0x10.

Could it= be that in the notdirty_mem_write(), that stX_p() must be performed firstl= y before the tb_invalidate_phys_page_fast()?

------=_Part_5917054_871331146.1455814432507--