From patchwork Mon Jan 26 15:53:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Alrae X-Patchwork-Id: 432865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5AFA414019D for ; Tue, 27 Jan 2015 02:54:17 +1100 (AEDT) Received: from localhost ([::1]:42435 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFlzT-000111-58 for incoming@patchwork.ozlabs.org; Mon, 26 Jan 2015 10:54:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50349) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFlzC-0000iC-Ik for qemu-devel@nongnu.org; Mon, 26 Jan 2015 10:53:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YFlz7-0001mP-ML for qemu-devel@nongnu.org; Mon, 26 Jan 2015 10:53:58 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:18166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YFlz7-0001lu-Ek for qemu-devel@nongnu.org; Mon, 26 Jan 2015 10:53:53 -0500 Received: from KLMAIL01.kl.imgtec.org (unknown [192.168.5.35]) by Websense Email Security Gateway with ESMTPS id C7EF96D33C432 for ; Mon, 26 Jan 2015 15:53:47 +0000 (GMT) Received: from lalrae-linux.kl.imgtec.org (192.168.14.163) by KLMAIL01.kl.imgtec.org (192.168.5.35) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 26 Jan 2015 15:53:50 +0000 From: Leon Alrae To: Date: Mon, 26 Jan 2015 15:53:16 +0000 Message-ID: <1422287596-5621-1-git-send-email-leon.alrae@imgtec.com> X-Mailer: git-send-email 1.7.9.5 MIME-Version: 1.0 X-Originating-IP: [192.168.14.163] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 195.59.15.196 Subject: [Qemu-devel] [PATCH] target-mips: fix detection of the end of the page during translation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The test is supposed to terminate TB if the end of the page is reached. However, with current implementation it may never succeed for microMIPS or mips16. Reported-by: Richard Henderson Signed-off-by: Leon Alrae Reviewed-by: Maciej W. Rozycki Reviewed-by: Richard Henderson --- target-mips/translate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target-mips/translate.c b/target-mips/translate.c index e9d86b2..f33c10c 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -19091,6 +19091,7 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb, CPUMIPSState *env = &cpu->env; DisasContext ctx; target_ulong pc_start; + target_ulong next_page_start; uint16_t *gen_opc_end; CPUBreakpoint *bp; int j, lj = -1; @@ -19103,6 +19104,7 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb, qemu_log("search pc %d\n", search_pc); pc_start = tb->pc; + next_page_start = (pc_start & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; ctx.pc = pc_start; ctx.saved_pc = -1; @@ -19202,8 +19204,9 @@ gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb, break; } - if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0) + if (ctx.pc >= next_page_start) { break; + } if (tcg_ctx.gen_opc_ptr >= gen_opc_end) { break;