All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: "Richard Henderson" <richard.henderson@linaro.org>,
	qemu-riscv@nongnu.org, qemu-s390x@nongnu.org,
	qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	"Anton Johansson" <anjo@rev.ng>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Weiwei Li" <liwei1518@gmail.com>,
	"Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
	"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
	"Chao Liu" <chao.liu@processmission.com>
Subject: [PATCH 17/24] target/riscv: Partially revert use of tb->cs_base
Date: Fri, 27 Nov 2026 00:35:55 +0100	[thread overview]
Message-ID: <20261126233604.67722-18-philmd@oss.qualcomm.com> (raw)
In-Reply-To: <20261126233604.67722-1-philmd@oss.qualcomm.com>

Partially revert commit 1c88ab9e77bd ("target/riscv: Use the
tb->cs_base as the extend tb flags"): now that TranslationBlock::flags
is 64-bit, keep only misa_ext in tb->cs_base (as in 55b490b58fbf) and
move the other extended flags (ALTFMT, BIG_ENDIAN, SDEXT_STEP) into
TB_FLAGS at bits 32+.

Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 include/exec/translation-block.h |  2 +-
 target/riscv/cpu.h               |  8 +++-----
 target/riscv/tcg/tcg-cpu.c       | 12 +++++-------
 target/riscv/tcg/translate.c     |  7 +++----
 4 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/include/exec/translation-block.h b/include/exec/translation-block.h
index f9f4876e6dd3..491de24d71b9 100644
--- a/include/exec/translation-block.h
+++ b/include/exec/translation-block.h
@@ -65,7 +65,7 @@ struct TranslationBlock {
      * arm: an extension of tb->flags,
      * s390x: instruction data for EXECUTE,
      * sparc: the next pc of the instruction queue (for delay slots),
-     * riscv: an extension of tb->flags.
+     * riscv: misa_ext.
      */
     uint64_t cs_base;
 
diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h
index 49a1186bdbb2..be5d520e200b 100644
--- a/target/riscv/cpu.h
+++ b/target/riscv/cpu.h
@@ -777,12 +777,10 @@ FIELD(TB_FLAGS, BCFI_ENABLED, 28, 1)
 /* If pointer masking should be applied and address sign extended */
 FIELD(TB_FLAGS, PM_PMM, 29, 2)
 FIELD(TB_FLAGS, PM_SIGNEXTEND, 31, 1)
-
-FIELD(EXT_TB_FLAGS, MISA_EXT, 0, 32)
-FIELD(EXT_TB_FLAGS, ALTFMT, 32, 1)
-FIELD(EXT_TB_FLAGS, BIG_ENDIAN, 33, 1)
+FIELD(TB_FLAGS, ALTFMT, 32, 1)
+FIELD(TB_FLAGS, BIG_ENDIAN, 33, 1)
 /* sdext single-step needs a TB flag to build 1-insn TBs */
-FIELD(EXT_TB_FLAGS, SDEXT_STEP, 34, 1)
+FIELD(TB_FLAGS, SDEXT_STEP, 34, 1)
 
 #ifdef TARGET_RISCV32
 #define riscv_cpu_mxl(env)  ((void)(env), MXL_RV32)
diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c
index 362471d7c8e4..7a06979f9bee 100644
--- a/target/riscv/tcg/tcg-cpu.c
+++ b/target/riscv/tcg/tcg-cpu.c
@@ -105,7 +105,6 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs)
     RISCVCPU *cpu = env_archcpu(env);
     RISCVExtStatus fs, vs;
     uint64_t flags = 0;
-    uint64_t ext_flags = 0;
     bool pm_signext = riscv_cpu_virt_mem_enabled(env, false);
 
     if (cpu->cfg.ext_zve32x) {
@@ -136,7 +135,7 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs)
         flags = FIELD_DP64(flags, TB_FLAGS, VMA,
                            FIELD_EX64(env->vtype, VTYPE, VMA));
         flags = FIELD_DP64(flags, TB_FLAGS, VSTART_EQ_ZERO, env->vstart == 0);
-        ext_flags = FIELD_DP64(ext_flags, EXT_TB_FLAGS, ALTFMT, altfmt);
+        flags = FIELD_DP64(flags, TB_FLAGS, ALTFMT, altfmt);
     } else {
         flags = FIELD_DP64(flags, TB_FLAGS, VILL, 1);
     }
@@ -194,19 +193,18 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs)
     flags = FIELD_DP64(flags, TB_FLAGS, PM_PMM, riscv_pm_get_pmm(env));
     flags = FIELD_DP64(flags, TB_FLAGS, PM_SIGNEXTEND, pm_signext);
 
-    ext_flags = FIELD_DP64(ext_flags, EXT_TB_FLAGS, MISA_EXT, env->misa_ext);
-    ext_flags = FIELD_DP64(ext_flags, EXT_TB_FLAGS, BIG_ENDIAN,
-                           mo_endian_env(env) == MO_BE);
+    flags = FIELD_DP64(flags, TB_FLAGS, BIG_ENDIAN,
+                       mo_endian_env(env) == MO_BE);
 #ifndef CONFIG_USER_ONLY
     if (cpu->cfg.ext_sdext && !env->debug_mode && (env->dcsr & DCSR_STEP)) {
-        ext_flags = FIELD_DP64(ext_flags, EXT_TB_FLAGS, SDEXT_STEP, 1);
+        flags = FIELD_DP64(flags, TB_FLAGS, SDEXT_STEP, 1);
     }
 #endif
 
     return (TCGTBCPUState){
         .pc = env->xl == MXL_RV32 ? env->pc & UINT32_MAX : env->pc,
         .flags = flags,
-        .cs_base = ext_flags,
+        .cs_base = env->misa_ext,
     };
 }
 
diff --git a/target/riscv/tcg/translate.c b/target/riscv/tcg/translate.c
index 255433593dd9..b810b91dc26a 100644
--- a/target/riscv/tcg/translate.c
+++ b/target/riscv/tcg/translate.c
@@ -1324,7 +1324,6 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
     RISCVCPUClass *mcc = RISCV_CPU_GET_CLASS(cs);
     RISCVCPU *cpu = RISCV_CPU(cs);
     uint64_t tb_flags = ctx->base.tb->flags;
-    uint64_t ext_tb_flags = ctx->base.tb->cs_base;
 
     ctx->pc_save = ctx->base.pc_first;
     ctx->priv = FIELD_EX64(tb_flags, TB_FLAGS, PRIV);
@@ -1344,7 +1343,7 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
     ctx->cfg_vta_all_1s = cpu->cfg.rvv_ta_all_1s;
     ctx->vstart_eq_zero = FIELD_EX64(tb_flags, TB_FLAGS, VSTART_EQ_ZERO);
     ctx->vl_eq_vlmax = FIELD_EX64(tb_flags, TB_FLAGS, VL_EQ_VLMAX);
-    ctx->altfmt = FIELD_EX64(ext_tb_flags, EXT_TB_FLAGS, ALTFMT);
+    ctx->altfmt = FIELD_EX64(tb_flags, TB_FLAGS, ALTFMT);
     ctx->misa_mxl_max = mcc->def->misa_mxl_max;
     ctx->xl = FIELD_EX64(tb_flags, TB_FLAGS, XL);
     ctx->address_xl = FIELD_EX64(tb_flags, TB_FLAGS, AXL);
@@ -1362,11 +1361,11 @@ static void riscv_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
     ctx->bcfi_enabled = FIELD_EX64(tb_flags, TB_FLAGS, BCFI_ENABLED);
     ctx->fcfi_lp_expected = FIELD_EX64(tb_flags, TB_FLAGS, FCFI_LP_EXPECTED);
     ctx->fcfi_enabled = FIELD_EX64(tb_flags, TB_FLAGS, FCFI_ENABLED);
-    ctx->sdext_step = FIELD_EX64(ext_tb_flags, EXT_TB_FLAGS, SDEXT_STEP);
+    ctx->sdext_step = FIELD_EX64(tb_flags, TB_FLAGS, SDEXT_STEP);
     ctx->zero = tcg_constant_tl(0);
     ctx->virt_inst_excp = false;
     ctx->decoders = cpu->decoders;
-    ctx->mo_endianness = FIELD_EX64(ext_tb_flags, EXT_TB_FLAGS, BIG_ENDIAN)
+    ctx->mo_endianness = FIELD_EX64(tb_flags, TB_FLAGS, BIG_ENDIAN)
                          ? MO_BE : MO_LE;
 }
 
-- 
2.55.0



  parent reply	other threads:[~2026-11-26 23:39 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 23:35 [PATCH 00/24] accel/tcg: Widen TranslationBlock::flags to 64 bits Philippe Mathieu-Daudé
2026-11-26 23:35 ` [PATCH 01/24] target/arm: Widen CPUARMTBFlags::flags " Philippe Mathieu-Daudé
2026-11-27  9:58   ` Anton Johansson via
2026-11-27  9:58     ` Anton Johansson via qemu development
2026-11-27  9:58     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 02/24] accel/tcg: Update stale TranslationBlock::jmp_lock comment Philippe Mathieu-Daudé
2026-11-27  9:59   ` Anton Johansson via
2026-11-27  9:59     ` Anton Johansson via qemu development
2026-11-27  9:59     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 03/24] accel/tcg: Widen TranslationBlock::flags to 64 bits Philippe Mathieu-Daudé
2026-11-27 11:03   ` Anton Johansson via
2026-11-27 11:03     ` Anton Johansson via
2026-11-27 11:03     ` Anton Johansson via qemu development
2026-11-27 12:30     ` Philippe Mathieu-Daudé
2026-11-26 23:35 ` [PATCH 04/24] target/arm: Update TB flags split comment for 64-bit tb->flags Philippe Mathieu-Daudé
2026-11-27 11:09   ` Anton Johansson via
2026-11-27 11:09     ` Anton Johansson via qemu development
2026-11-27 11:09     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 05/24] target/alpha: Use 64-bit TB flags Philippe Mathieu-Daudé
2026-11-27 11:11   ` Anton Johansson via
2026-11-27 11:11     ` Anton Johansson via
2026-11-27 11:11     ` Anton Johansson via qemu development
2026-11-26 23:35 ` [PATCH 06/24] target/avr: " Philippe Mathieu-Daudé
2026-11-27 11:12   ` Anton Johansson via qemu development
2026-11-27 11:12     ` Anton Johansson via
2026-11-27 11:12     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 07/24] target/hexagon: " Philippe Mathieu-Daudé
2026-11-27  4:56   ` Brian Cain
2026-12-01  2:22   ` Brian Cain
2026-11-26 23:35 ` [PATCH 08/24] target/hppa: " Philippe Mathieu-Daudé
2026-11-27 11:13   ` Anton Johansson via
2026-11-27 11:13     ` Anton Johansson via
2026-11-27 11:13     ` Anton Johansson via qemu development
2026-11-26 23:35 ` [PATCH 09/24] target/i386: " Philippe Mathieu-Daudé
2026-11-27 11:14   ` Anton Johansson via
2026-11-27 11:14     ` Anton Johansson via
2026-11-27 11:14     ` Anton Johansson via qemu development
2026-11-26 23:35 ` [PATCH 10/24] target/loongarch: " Philippe Mathieu-Daudé
2026-11-27 11:16   ` Anton Johansson via qemu development
2026-11-27 11:16     ` Anton Johansson via
2026-11-27 11:16     ` Anton Johansson via
2026-11-30  1:03   ` Bibo Mao
2026-11-26 23:35 ` [PATCH 11/24] target/m68k: " Philippe Mathieu-Daudé
2026-11-27 11:16   ` Anton Johansson via qemu development
2026-11-27 11:16     ` Anton Johansson via
2026-11-27 11:16     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 12/24] target/microblaze: " Philippe Mathieu-Daudé
2026-11-27 11:17   ` Anton Johansson via
2026-11-27 11:17     ` Anton Johansson via
2026-11-27 11:17     ` Anton Johansson via qemu development
2026-11-26 23:35 ` [PATCH 13/24] target/mips: " Philippe Mathieu-Daudé
2026-11-27 11:19   ` Anton Johansson via qemu development
2026-11-27 11:19     ` Anton Johansson via
2026-11-27 11:19     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 14/24] target/or1k: " Philippe Mathieu-Daudé
2026-11-27 11:20   ` Anton Johansson via qemu development
2026-11-27 11:20     ` Anton Johansson via
2026-11-27 11:20     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 15/24] target/ppc: " Philippe Mathieu-Daudé
2026-11-27  7:57   ` Chinmay Rath
2026-11-27 12:09     ` Philippe Mathieu-Daudé
2026-11-26 23:35 ` [PATCH 16/24] target/riscv: " Philippe Mathieu-Daudé
2026-11-27 11:23   ` Anton Johansson via qemu development
2026-11-27 11:23     ` Anton Johansson via
2026-11-27 11:23     ` Anton Johansson via
2026-12-01  1:15   ` Alistair Francis
2026-12-01  1:16   ` Alistair Francis
2026-11-26 23:35 ` Philippe Mathieu-Daudé [this message]
2026-11-27 11:26   ` [PATCH 17/24] target/riscv: Partially revert use of tb->cs_base Anton Johansson via qemu development
2026-11-27 11:26     ` Anton Johansson via
2026-11-27 11:26     ` Anton Johansson via
2026-12-01  1:18   ` Alistair Francis
2026-11-26 23:35 ` [PATCH 18/24] target/rx: Use 64-bit TB flags Philippe Mathieu-Daudé
2026-11-27 11:27   ` Anton Johansson via qemu development
2026-11-27 11:27     ` Anton Johansson via
2026-11-27 11:27     ` Anton Johansson via
2026-11-28 13:42   ` yoshinori.sato
2026-11-26 23:35 ` [PATCH 19/24] target/s390x: " Philippe Mathieu-Daudé
2026-11-27 11:27   ` Anton Johansson via
2026-11-27 11:27     ` Anton Johansson via qemu development
2026-11-27 11:27     ` Anton Johansson via
2026-11-26 23:35 ` [PATCH 20/24] target/sh4: " Philippe Mathieu-Daudé
2026-11-27 11:29   ` Anton Johansson via qemu development
2026-11-27 11:29     ` Anton Johansson via
2026-11-27 11:29     ` Anton Johansson via
2026-11-28 13:42   ` yoshinori.sato
2026-11-26 23:35 ` [PATCH 21/24] target/sparc: " Philippe Mathieu-Daudé
2026-11-27 11:30   ` Anton Johansson via
2026-11-27 11:30     ` Anton Johansson via
2026-11-27 11:30     ` Anton Johansson via qemu development
2026-11-26 23:36 ` [PATCH 22/24] target/tricore: " Philippe Mathieu-Daudé
2026-11-27 11:31   ` Anton Johansson via qemu development
2026-11-27 11:31     ` Anton Johansson via
2026-11-27 11:31     ` Anton Johansson via
2026-11-26 23:36 ` [PATCH 23/24] target/xtensa: " Philippe Mathieu-Daudé
2026-11-27 11:32   ` Anton Johansson via qemu development
2026-11-27 11:32     ` Anton Johansson via
2026-11-27 11:32     ` Anton Johansson via
2026-11-26 23:36 ` [PATCH 24/24] accel/tcg: Update TranslationBlock::cs_base description Philippe Mathieu-Daudé
2026-11-27 11:34   ` Anton Johansson via
2026-11-27 11:34     ` Anton Johansson via
2026-11-27 11:34     ` Anton Johansson via qemu development

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=20261126233604.67722-18-philmd@oss.qualcomm.com \
    --to=philmd@oss.qualcomm.com \
    --cc=alistair.francis@wdc.com \
    --cc=anjo@rev.ng \
    --cc=chao.liu@processmission.com \
    --cc=daniel.barboza@oss.qualcomm.com \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=pierrick.bouvier@oss.qualcomm.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=zhiwei_liu@linux.alibaba.com \
    /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.