From 5b9efc39aee90bbd343793e942bf8f582a0c9e4f Mon Sep 17 00:00:00 2001 From: Pavel Dovgalyuk Date: Wed, 26 Nov 2014 13:39:42 +0300 Subject: 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. Signed-off-by: Pavel Dovgalyuk Signed-off-by: Paolo Bonzini --- target-i386/translate.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'target-i386/translate.c') diff --git a/target-i386/translate.c b/target-i386/translate.c index 782f7d2666..31a9f74467 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -8022,6 +8022,20 @@ static inline void gen_intermediate_code_internal(X86CPU *cpu, 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. + */ + 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(pc_ptr - dc->cs_base); + gen_eob(dc); + break; + } /* if too long translation, stop generation too */ if (tcg_ctx.gen_opc_ptr >= gen_opc_end || (pc_ptr - pc_start) >= (TARGET_PAGE_SIZE - 32) || -- cgit v1.2.3