i386: do not cross the pages boundaries in replay mode

This patch denies crossing the boundary of the pages in the replay mode,
because it can cause an exception. Do it only when boundary is
crossed by the first instruction in the block.
If current instruction already crossed the bound - it's ok,
because an exception hasn't stopped this code.

Backports commit 5b9efc39aee90bbd343793e942bf8f582a0c9e4f from qemu
This commit is contained in:
Pavel Dovgalyuk 2018-02-14 16:08:55 -05:00 committed by Lioncash
parent e73fbde2ce
commit ee0d7ba219
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7
2 changed files with 18 additions and 0 deletions

View File

@ -28,6 +28,9 @@
#define TARGET_LONG_BITS 32
#endif
/* Maximum instruction code size */
#define TARGET_MAX_INSN_SIZE 16
/* support for self modifying code even if the modified instruction is
close to the modifying instruction */
#define TARGET_HAS_PRECISE_SMC

View File

@ -8765,6 +8765,21 @@ static inline void gen_intermediate_code_internal(uint8_t *gen_opc_cc_op,
gen_eob(dc);
break;
}
/* Do not cross the boundary of the pages in icount mode,
it can cause an exception. Do it only when boundary is
crossed by the first instruction in the block.
If current instruction already crossed the bound - it's ok,
because an exception hasn't stopped this code.
*/
/* UNICORN: Commented out
if (use_icount
&& ((pc_ptr & TARGET_PAGE_MASK)
!= ((pc_ptr + TARGET_MAX_INSN_SIZE - 1) & TARGET_PAGE_MASK)
|| (pc_ptr & ~TARGET_PAGE_MASK) == 0)) {
gen_jmp_im(dc, pc_ptr - dc->cs_base);
gen_eob(dc);
break;
}*/
/* if too long translation, stop generation too */
if (tcg_op_buf_full(tcg_ctx) ||
(pc_ptr - pc_start) >= (TARGET_PAGE_SIZE - 32) ||