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: 138217 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp3899601lji; Mon, 11 Jun 2018 03:55:32 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKL/1HJri9y9nB65F154Tp9uqldzZGO/AolUn+0yiSYIi1Jm8+EoNyxGNHp0jzz+ecZ+NfZ X-Received: by 2002:a0c:c944:: with SMTP id v4-v6mr14528608qvj.232.1528714532781; Mon, 11 Jun 2018 03:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528714532; cv=none; d=google.com; s=arc-20160816; b=Z21iDP9JwyvQxwoVHDccESO8SqA6Iw+YTmRPZMbQZmzUOkvV/APFaQWRepF2AI8fCG Qp9QBxo8FUA6oq73hm7BwXWG8YCJEKXmaja1Rzxe9FZRe9sbv+gy20qYyjbJPlJMz5CM MGNAchfao9KF8TuuPwxxa02+l/El5mLHlkim7Po8BrH5hnyN7c1SsEdf7zqCsfdV5NHd tYDoNRfnN9lb/HkZ45LMQS6itpfwpQLHprkSqVCByD2XdXuUN0M9mSLKDbrP9tlz8lAF SeW4/O532qiUbjLS+jOF5hM2ZfcHg/cfyNGvs85K3s4+Usr9xtOHSVcy+vbx4WV0qe6M IhlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=1gVjAkn2eUxl7dnt3pWGT6mtj5X1efpHswpoMQ6HyLk=; b=rT7oLBLbhbgODRVCAZGJDgWi0+G0CrP3h0fv7tf8lvFb9hhGIZ18brziptDWKwF242 cWEJZ0gBFCySgzqrbiII2zlT/cXsVS88htYZJV6YQnvBTleqZZo3HHDvI3sJ93ij8Aay TfjA6MdNT5X+Nu6k33SS1UG6n9ZZxUC8bVUnUReMW6emHEd+wgwJ9GCD54LZ+oDK0Trf 3bTWT6miDBKE6AD3tpGe9IbbDw2UnKPXXysydrpTYkdu0W8K3947StCNSv/jibSvQAOc j73o8HPxPVssOTlOJ1cDoLqQMQj08zZHff54hb6AB3fXLrjiEfPkHuulDOa4StRrSR8S gQSw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i187-v6si1137049qke.393.2018.06.11.03.55.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 11 Jun 2018 03:55:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:47682 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fSKU0-0006pI-Ay for patch@linaro.org; Mon, 11 Jun 2018 06:55:32 -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+patch=linaro.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(-) -- 2.14.4 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; + } } }