[PATCH 2/2] target/rx: Check for page crossings in use_goto_tb()

Ahmed Karaman posted 2 patches 5 years, 5 months ago
Maintainers: Yoshinori Sato <ysato@users.sourceforge.jp>, Richard Henderson <rth@twiddle.net>
[PATCH 2/2] target/rx: Check for page crossings in use_goto_tb()
Posted by Ahmed Karaman 5 years, 5 months ago
Add the page crossings check when using system mode. If this
fix is not applied, a number of bugs may occasionally occur during
target rx system mode emulation.

Rename parameter dc of type DisasContext* to the more common
name ctx, to keep consistency with other targets.

Signed-off-by: Ahmed Karaman <ahmedkhaledkaraman@gmail.com>
---
 target/rx/translate.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/target/rx/translate.c b/target/rx/translate.c
index 61e86653a4..77497ddbfb 100644
--- a/target/rx/translate.c
+++ b/target/rx/translate.c
@@ -143,13 +143,17 @@ void rx_cpu_dump_state(CPUState *cs, FILE *f, int flags)
     }
 }
 
-static bool use_goto_tb(DisasContext *dc, target_ulong dest)
+static bool use_goto_tb(DisasContext *ctx, target_ulong dest)
 {
-    if (unlikely(dc->base.singlestep_enabled)) {
+    if (unlikely(ctx->base.singlestep_enabled)) {
         return false;
-    } else {
-        return true;
     }
+
+#ifndef CONFIG_USER_ONLY
+    return (ctx->base.tb->pc & TARGET_PAGE_MASK) == (dest & TARGET_PAGE_MASK);
+#else
+    return true;
+#endif
 }
 
 static void gen_goto_tb(DisasContext *dc, int n, target_ulong dest)
-- 
2.17.1