[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-8.1.2 37/45] accel/tcg: Track current value of can_do_io in the
From: |
Michael Tokarev |
Subject: |
[Stable-8.1.2 37/45] accel/tcg: Track current value of can_do_io in the TB |
Date: |
Wed, 4 Oct 2023 11:01:58 +0300 |
From: Richard Henderson <richard.henderson@linaro.org>
Simplify translator_io_start by recording the current
known value of can_do_io within DisasContextBase.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
(cherry picked from commit 0ca41ccf1c555f97873b8e02a47390fd6af4b18f)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index b6ab9f3d33..850d82e26f 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -16,11 +16,14 @@
#include "tcg/tcg-op-common.h"
#include "internal.h"
-static void gen_io_start(void)
+static void set_can_do_io(DisasContextBase *db, bool val)
{
- tcg_gen_st_i32(tcg_constant_i32(1), cpu_env,
- offsetof(ArchCPU, parent_obj.can_do_io) -
- offsetof(ArchCPU, env));
+ if (db->saved_can_do_io != val) {
+ db->saved_can_do_io = val;
+ tcg_gen_st_i32(tcg_constant_i32(val), cpu_env,
+ offsetof(ArchCPU, parent_obj.can_do_io) -
+ offsetof(ArchCPU, env));
+ }
}
bool translator_io_start(DisasContextBase *db)
@@ -30,12 +33,8 @@ bool translator_io_start(DisasContextBase *db)
if (!(cflags & CF_USE_ICOUNT)) {
return false;
}
- if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) {
- /* Already started in translator_loop. */
- return true;
- }
- gen_io_start();
+ set_can_do_io(db, true);
/*
* Ensure that this instruction will be the last in the TB.
@@ -47,7 +46,7 @@ bool translator_io_start(DisasContextBase *db)
return true;
}
-static TCGOp *gen_tb_start(uint32_t cflags)
+static TCGOp *gen_tb_start(DisasContextBase *db, uint32_t cflags)
{
TCGv_i32 count = NULL;
TCGOp *icount_start_insn = NULL;
@@ -91,12 +90,9 @@ static TCGOp *gen_tb_start(uint32_t cflags)
* cpu->can_do_io is cleared automatically here at the beginning of
* each translation block. The cost is minimal and only paid for
* -icount, plus it would be very easy to forget doing it in the
- * translator. Doing it here means we don't need a gen_io_end() to
- * go with gen_io_start().
+ * translator.
*/
- tcg_gen_st_i32(tcg_constant_i32(0), cpu_env,
- offsetof(ArchCPU, parent_obj.can_do_io) -
- offsetof(ArchCPU, env));
+ set_can_do_io(db, false);
}
return icount_start_insn;
@@ -147,6 +143,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb,
int *max_insns,
db->num_insns = 0;
db->max_insns = *max_insns;
db->singlestep_enabled = cflags & CF_SINGLE_STEP;
+ db->saved_can_do_io = -1;
db->host_addr[0] = host_pc;
db->host_addr[1] = NULL;
@@ -154,7 +151,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb,
int *max_insns,
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
/* Start translating. */
- icount_start_insn = gen_tb_start(cflags);
+ icount_start_insn = gen_tb_start(db, cflags);
ops->tb_start(db, cpu);
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
@@ -181,7 +178,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb,
int *max_insns,
the next instruction. */
if (db->num_insns == db->max_insns && (cflags & CF_LAST_IO)) {
/* Accept I/O on the last instruction. */
- gen_io_start();
+ set_can_do_io(db, true);
}
ops->translate_insn(db, cpu);
diff --git a/include/exec/translator.h b/include/exec/translator.h
index a53d3243d4..0f4ecad7a2 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -72,6 +72,7 @@ typedef enum DisasJumpType {
* @num_insns: Number of translated instructions (including current).
* @max_insns: Maximum number of instructions to be translated in this TB.
* @singlestep_enabled: "Hardware" single stepping enabled.
+ * @saved_can_do_io: Known value of cpu->neg.can_do_io, or -1 for unknown.
*
* Architecture-agnostic disassembly context.
*/
@@ -83,6 +84,7 @@ typedef struct DisasContextBase {
int num_insns;
int max_insns;
bool singlestep_enabled;
+ int8_t saved_can_do_io;
void *host_addr[2];
} DisasContextBase;
--
2.39.2
- [Stable-8.1.2 31/45] migration: Consolidate return path closing code, (continued)
- [Stable-8.1.2 31/45] migration: Consolidate return path closing code, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 33/45] migration: Move return path cleanup to main migration thread, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 32/45] migration: Replace the return path retry logic, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 34/45] softmmu: Use async_run_on_cpu in tcg_commit, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 35/45] accel/tcg: Avoid load of icount_decr if unused, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 39/45] accel/tcg: Always set CF_LAST_IO with CF_NOIRQ, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 40/45] accel/tcg: Always require can_do_io, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 43/45] esp: use correct type for esp_dma_enable() in sysbus_esp_gpio_demux(), Michael Tokarev, 2023/10/04
- [Stable-8.1.2 41/45] target/tricore: Fix RCPW/RRPW_INSERT insns for width = 0, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 38/45] accel/tcg: Improve setting of can_do_io at start of TB, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 37/45] accel/tcg: Track current value of can_do_io in the TB,
Michael Tokarev <=
- [Stable-8.1.2 42/45] optionrom: Remove build-id section, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 36/45] accel/tcg: Hoist CF_MEMI_ONLY check outside translation loop, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 45/45] scsi-disk: ensure that FORMAT UNIT commands are terminated, Michael Tokarev, 2023/10/04
- [Stable-8.1.2 44/45] esp: restrict non-DMA transfer length to that of available data, Michael Tokarev, 2023/10/04
- Re: [Stable-8.1.2 00/45] Patch Round-up for stable 8.1.2, freeze on 2023-10-14, Olaf Hering, 2023/10/04