All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@kernel.org>
To: qemu-devel@nongnu.org
Cc: "Kirill A . Korinsky" <kirill@korins.ky>, Helge Deller <deller@gmx.de>
Subject: [PULL for 11.2 4/4] target/hppa: Fix tcg_gen_goto_tb assertion
Date: Wed,  2 Dec 2026 00:21:54 +0100	[thread overview]
Message-ID: <20261201232154.3178-5-deller@kernel.org> (raw)
In-Reply-To: <20261201232154.3178-1-deller@kernel.org>

From: "Kirill A. Korinsky" <kirill@korins.ky>

On hppa a branch may generate three exits from one block, but qemu has
only two slots; the third exit reused slot 0 and badaboom happened.
Try to assign a unique slot to avoid the problem.

Signed-off-by: Kirill A. Korinsky <kirill@korins.ky>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4835
Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/hppa/translate.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index c8e2b13c8c..70bc7deabd 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -85,6 +85,7 @@ typedef struct DisasContext {
     uint32_t tb_flags;
     int mmu_idx;
     int privilege;
+    unsigned goto_tb_idx;
     uint32_t psw_xb;
     bool psw_n_nonzero;
     bool psw_b_next;
@@ -791,7 +792,8 @@ static bool gen_illegal(DisasContext *ctx)
 static bool use_goto_tb(DisasContext *ctx, const DisasIAQE *f,
                         const DisasIAQE *b)
 {
-    return (!iaqe_variable(f) &&
+    return (ctx->goto_tb_idx <= TB_EXIT_IDXMAX &&
+            !iaqe_variable(f) &&
             (b == NULL || !iaqe_variable(b)) &&
             translator_use_goto_tb(&ctx->base, ctx->iaoq_first + f->disp));
 }
@@ -808,11 +810,13 @@ static bool use_nullify_skip(DisasContext *ctx)
                 & TARGET_PAGE_MASK) == 0);
 }
 
-static void gen_goto_tb(DisasContext *ctx, int which,
+static void gen_goto_tb(DisasContext *ctx,
                         const DisasIAQE *f, const DisasIAQE *b)
 {
     install_iaq_entries(ctx, f, b);
     if (use_goto_tb(ctx, f, b)) {
+        unsigned which = ctx->goto_tb_idx++;
+
         tcg_gen_goto_tb(which);
         tcg_gen_exit_tb(ctx->base.tb, which);
     } else {
@@ -1960,7 +1964,7 @@ static bool do_dbranch(DisasContext *ctx, int64_t disp,
             if (use_nullify_skip(ctx)) {
                 nullify_set(ctx, 0);
                 store_psw_xb(ctx, 0);
-                gen_goto_tb(ctx, 0, &ctx->iaq_j, NULL);
+                gen_goto_tb(ctx, &ctx->iaq_j, NULL);
                 ctx->base.is_jmp = DISAS_NORETURN;
                 return true;
             }
@@ -1975,17 +1979,17 @@ static bool do_dbranch(DisasContext *ctx, int64_t disp,
         if (is_n && use_nullify_skip(ctx)) {
             nullify_set(ctx, 0);
             store_psw_xb(ctx, 0);
-            gen_goto_tb(ctx, 0, &ctx->iaq_j, NULL);
+            gen_goto_tb(ctx, &ctx->iaq_j, NULL);
         } else {
             nullify_set(ctx, is_n);
             store_psw_xb(ctx, PSW_B);
-            gen_goto_tb(ctx, 0, &ctx->iaq_b, &ctx->iaq_j);
+            gen_goto_tb(ctx, &ctx->iaq_b, &ctx->iaq_j);
         }
         nullify_end(ctx);
 
         nullify_set(ctx, 0);
         store_psw_xb(ctx, 0);
-        gen_goto_tb(ctx, 1, &ctx->iaq_b, NULL);
+        gen_goto_tb(ctx, &ctx->iaq_b, NULL);
         ctx->base.is_jmp = DISAS_NORETURN;
     }
     return true;
@@ -2017,7 +2021,7 @@ static bool do_cbranch(DisasContext *ctx, int64_t disp, bool is_n,
         nullify_set(ctx, 0);
         store_psw_xb(ctx, 0);
         next = iaqe_incr(&ctx->iaq_b, 4);
-        gen_goto_tb(ctx, 0, &next, NULL);
+        gen_goto_tb(ctx, &next, NULL);
     } else {
         if (!n && ctx->null_lab) {
             gen_set_label(ctx->null_lab);
@@ -2025,7 +2029,7 @@ static bool do_cbranch(DisasContext *ctx, int64_t disp, bool is_n,
         }
         nullify_set(ctx, n);
         store_psw_xb(ctx, 0);
-        gen_goto_tb(ctx, 0, &ctx->iaq_b, NULL);
+        gen_goto_tb(ctx, &ctx->iaq_b, NULL);
     }
 
     gen_set_label(taken);
@@ -2037,11 +2041,11 @@ static bool do_cbranch(DisasContext *ctx, int64_t disp, bool is_n,
     if (n && use_nullify_skip(ctx)) {
         nullify_set(ctx, 0);
         store_psw_xb(ctx, 0);
-        gen_goto_tb(ctx, 1, &next, NULL);
+        gen_goto_tb(ctx, &next, NULL);
     } else {
         nullify_set(ctx, n);
         store_psw_xb(ctx, PSW_B);
-        gen_goto_tb(ctx, 1, &ctx->iaq_b, &next);
+        gen_goto_tb(ctx, &ctx->iaq_b, &next);
     }
 
     /* Not taken: the branch itself was nullified.  */
@@ -4970,7 +4974,7 @@ static void hppa_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs)
             && (ctx->null_cond.c == TCG_COND_NEVER
                 || ctx->null_cond.c == TCG_COND_ALWAYS)) {
             nullify_set(ctx, ctx->null_cond.c == TCG_COND_ALWAYS);
-            gen_goto_tb(ctx, 0, f, b);
+            gen_goto_tb(ctx, f, b);
             break;
         }
         /* FALLTHRU */
-- 
2.54.0



      parent reply	other threads:[~2026-12-01 23:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 23:21 [PULL for 11.2 0/4] Hppa fixes patches Helge Deller
2026-12-01 23:21 ` [PULL for 11.2 1/4] target/hppa: Emulate FREM Helge Deller
2026-12-01 23:21 ` [PULL for 11.2 2/4] target/hppa: Defer PA7300LC FCNVFF on NaNs Helge Deller
2026-12-01 23:21 ` [PULL for 11.2 3/4] target/hppa: Defer PA7300LC multiply assists Helge Deller
2026-12-01 23:21 ` Helge Deller [this message]

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=20261201232154.3178-5-deller@kernel.org \
    --to=deller@kernel.org \
    --cc=deller@gmx.de \
    --cc=kirill@korins.ky \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.