From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58585) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0YgX-0006kA-DQ for qemu-devel@nongnu.org; Mon, 15 Dec 2014 11:39:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y0YgR-0005Mg-DD for qemu-devel@nongnu.org; Mon, 15 Dec 2014 11:39:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y0YgR-0005LL-1b for qemu-devel@nongnu.org; Mon, 15 Dec 2014 11:39:43 -0500 From: Paolo Bonzini Date: Mon, 15 Dec 2014 17:38:16 +0100 Message-Id: <1418661511-22348-33-git-send-email-pbonzini@redhat.com> In-Reply-To: <1418661511-22348-1-git-send-email-pbonzini@redhat.com> References: <1418661511-22348-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 32/47] i386: do not cross the pages boundaries in replay mode List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Pavel Dovgalyuk From: Pavel Dovgalyuk 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/cpu.h | 3 +++ target-i386/translate.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index 7e36365..3ecff96 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -28,6 +28,9 @@ #define TARGET_LONG_BITS 32 #endif +/* Maximum instruction code size */ +#define TARGET_MAX_INSN_SIZE 16 + /* target supports implicit self modifying code */ #define TARGET_HAS_SMC /* support for self modifying code even if the modified instruction is diff --git a/target-i386/translate.c b/target-i386/translate.c index 782f7d2..31a9f74 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) || -- 1.8.3.1