From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>,
Riku Voipio <riku.voipio@iki.fi>,
Richard Henderson <richard.henderson@linaro.org>
Subject: [Qemu-devel] [PULL 8/9] target/m68k: Improve ending TB at page boundaries
Date: Mon, 11 Jun 2018 12:49:34 +0200 [thread overview]
Message-ID: <20180611104935.20499-9-laurent@vivier.eu> (raw)
In-Reply-To: <20180611104935.20499-1-laurent@vivier.eu>
From: Richard Henderson <richard.henderson@linaro.org>
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 <richard.henderson@linaro.org>
Message-Id: <20180512050250.12774-9-richard.henderson@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
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;
+ }
}
}
--
2.14.4
next prev parent reply other threads:[~2018-06-11 10:50 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-11 10:49 [Qemu-devel] [PULL 0/9] M68k for 3.0 patches Laurent Vivier
2018-06-11 10:49 ` [Qemu-devel] [PULL 1/9] target/m68k: Use DISAS_NORETURN for exceptions Laurent Vivier
2018-06-11 10:49 ` [Qemu-devel] [PULL 2/9] target/m68k: Replace DISAS_TB_JUMP with DISAS_NORETURN Laurent Vivier
2018-06-11 10:49 ` [Qemu-devel] [PULL 3/9] target/m68k: Remove DISAS_JUMP_NEXT as unused Laurent Vivier
2018-06-11 10:49 ` [Qemu-devel] [PULL 4/9] target/m68k: Use lookup_and_goto_tb for DISAS_JUMP Laurent Vivier
2018-06-11 10:49 ` [Qemu-devel] [PULL 5/9] target/m68k: Rename DISAS_UPDATE and gen_lookup_tb Laurent Vivier
2018-06-11 10:49 ` [Qemu-devel] [PULL 6/9] target/m68k: Convert to DisasContextBase Laurent Vivier
2018-06-11 10:49 ` [Qemu-devel] [PULL 7/9] target/m68k: Convert to TranslatorOps Laurent Vivier
2018-06-11 10:49 ` Laurent Vivier [this message]
2018-06-11 10:49 ` [Qemu-devel] [PULL 9/9] target/m68k: Merge disas_m68k_insn into m68k_tr_translate_insn Laurent Vivier
2018-06-11 12:37 ` [Qemu-devel] [PULL 0/9] M68k for 3.0 patches Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180611104935.20499-9-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=riku.voipio@iki.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).