From patchwork Mon Jun 11 10:49:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 927607 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu 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 41490l6lPxz9rxs for ; Mon, 11 Jun 2018 20:55:50 +1000 (AEST) Received: from localhost ([::1]:47682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSKUF-0006pI-7t for incoming@patchwork.ozlabs.org; Mon, 11 Jun 2018 06:55:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56358) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSKOl-0002aE-9M for qemu-devel@nongnu.org; Mon, 11 Jun 2018 06:50:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fSKOg-0000nv-Ts for qemu-devel@nongnu.org; Mon, 11 Jun 2018 06:50:07 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:41915) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fSKOg-0000mG-Er for qemu-devel@nongnu.org; Mon, 11 Jun 2018 06:50:02 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.167]) with ESMTPSA (Nemesis) id 0LgtBS-1g4QqP3rGQ-00oDmV; Mon, 11 Jun 2018 12:49:52 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Mon, 11 Jun 2018 12:49:34 +0200 Message-Id: <20180611104935.20499-9-laurent@vivier.eu> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180611104935.20499-1-laurent@vivier.eu> References: <20180611104935.20499-1-laurent@vivier.eu> X-Provags-ID: V03:K1:xJuptGrbJoP7xgZbyn2M/H/imje7/kxeZF5Wd9BD2gI4SV5LCBw mgmMNsOZz4XdlE4QrbrbYsJf8n53DKyuowU4cjiZ7kBPh53anSlKgo7V9fzGV/5FCUVZR63 CXVu+ylWSsHwmaWlugUFdQb60PHyr/hLmTBk83EySNCEc1fkpk4z/O4fP6wBFT79SMVsTRf IZC1DmCO0RtojX0jzA2Pg== X-UI-Out-Filterresults: notjunk:1; V01:K0:XvYeMDdpAeA=:nH0hfuDJMYzOJgPr2e8DGa 5Wf9AnMk3CFVnnlxdT3naTvPc2DyYLzcbhex21ml8A6QhIJbc9iTfurv7CbylBaXmjHB4Hpr8 ePCAu/LnEXfyaSDLNk+oGp0D3iYe6gUqok1XA3O17nmntXF5ckSiVbhY81Xstvf5TK/18BT/7 rR4T5k3slJzGY1Fi/KA1uPAobH5ah9zVRBgmujBRZLFJ1yeupE12WoFOLjNC8uPuq1vz+TtZZ nXYWXF+HOny+dH9nFOhXsvOI+QT4JJg6UrThh/hLt44USURXLiVGOrkiF3fU3WuF+CclM/76z A4I41o6A9RoItMfULcQ+gVgxtgSGCt9r4Q3bdAG7uMs7l5XiszpcwZ8QHhZld070zclMtXe2r rhEPAJNXgi4q35h/MiC9nOAIi1JXoEiU1+wIR/mLJQaEb1jOiyPmgYr2tQNjJcdxM2tkhj5Gu VDOe8h0jkTDlWc4EolM4h9+3fTFylo0mp6yTcMgntzvprHPEKOcAQlUK6HG+IlrHs7iLFgbMx cQLRpeMdAZBI6YAyqAOiFBQ5dCVLBryk4Z0W3HBAeaTc07N8+1KkI9oFhz6gX+WAkeMBTH7U1 bI8wk4yy9pfQtxXbZbs3erKOOc46gr3A0AbdJQBYjMtdFah7MGDKnJjcdxqi/hHVWL8MyTbpy 3drRQAaK1MWoiq1CaV+qPwfRgwT6O3MtWFhFgytvXO8XDU8TopbmcspBpY27G7l4a3uY= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PULL 8/9] target/m68k: Improve ending TB at page boundaries X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Rather than limit total TB size to PAGE-32 bytes, end the TB when near the end of a page. This should provide proper semantics of SIGSEGV when executing near the end of a page. Signed-off-by: Richard Henderson Message-Id: <20180512050250.12774-9-richard.henderson@linaro.org> Signed-off-by: Laurent Vivier --- target/m68k/translate.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/target/m68k/translate.c b/target/m68k/translate.c index 62a96bedcd..ff3493d8ab 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -6105,9 +6105,25 @@ static void m68k_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) disas_m68k_insn(cpu->env_ptr, dc); dc->base.pc_next = dc->pc; - if (dc->base.is_jmp == DISAS_NEXT - && dc->pc - dc->base.pc_first >= TARGET_PAGE_SIZE - 32) { - dc->base.is_jmp = DISAS_TOO_MANY; + if (dc->base.is_jmp == DISAS_NEXT) { + /* Stop translation when the next insn might touch a new page. + * This ensures that prefetch aborts at the right place. + * + * We cannot determine the size of the next insn without + * completely decoding it. However, the maximum insn size + * is 32 bytes, so end if we do not have that much remaining. + * This may produce several small TBs at the end of each page, + * but they will all be linked with goto_tb. + * + * ??? ColdFire maximum is 4 bytes; MC68000's maximum is also + * smaller than MC68020's. + */ + target_ulong start_page_offset + = dc->pc - (dc->base.pc_first & TARGET_PAGE_MASK); + + if (start_page_offset >= TARGET_PAGE_SIZE - 32) { + dc->base.is_jmp = DISAS_TOO_MANY; + } } }