[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 51/59] accel/tcg: Un-inline translator_is_same_page()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 51/59] accel/tcg: Un-inline translator_is_same_page() |
Date: |
Fri, 20 Dec 2024 17:15:42 +0100 |
Remove the single target-specific definition used in
"exec/translator.h" (TARGET_PAGE_MASK) by un-inlining
is_same_page().
Rename the method as translator_is_same_page() and
improve its documentation.
Use it in translator_use_goto_tb().
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20241218154145.71353-1-philmd@linaro.org>
---
include/exec/translator.h | 15 +++++++--------
accel/tcg/translator.c | 7 ++++++-
target/i386/tcg/translate.c | 6 +++---
target/riscv/translate.c | 4 ++--
target/s390x/tcg/translate.c | 4 ++--
5 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/include/exec/translator.h b/include/exec/translator.h
index d8dcb77b5f4..41e2a41180f 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -267,16 +267,15 @@ bool translator_st(const DisasContextBase *db, void *dest,
*/
size_t translator_st_len(const DisasContextBase *db);
-#ifdef COMPILING_PER_TARGET
-/*
- * Return whether addr is on the same page as where disassembly started.
+/**
+ * translator_is_same_page
+ * @db: disassembly context
+ * @addr: virtual address within TB
+ *
+ * Return whether @addr is on the same page as where disassembly started.
* Translators can use this to enforce the rule that only single-insn
* translation blocks are allowed to cross page boundaries.
*/
-static inline bool is_same_page(const DisasContextBase *db, vaddr addr)
-{
- return ((addr ^ db->pc_first) & TARGET_PAGE_MASK) == 0;
-}
-#endif
+bool translator_is_same_page(const DisasContextBase *db, vaddr addr);
#endif /* EXEC__TRANSLATOR_H */
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index ce5eae4349e..ef1538b4fcd 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -104,6 +104,11 @@ static void gen_tb_end(const TranslationBlock *tb,
uint32_t cflags,
}
}
+bool translator_is_same_page(const DisasContextBase *db, vaddr addr)
+{
+ return ((addr ^ db->pc_first) & TARGET_PAGE_MASK) == 0;
+}
+
bool translator_use_goto_tb(DisasContextBase *db, vaddr dest)
{
/* Suppress goto_tb if requested. */
@@ -112,7 +117,7 @@ bool translator_use_goto_tb(DisasContextBase *db, vaddr
dest)
}
/* Check for the dest on the same page as the start of the TB. */
- return ((db->pc_first ^ dest) & TARGET_PAGE_MASK) == 0;
+ return translator_is_same_page(db, dest);
}
void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
diff --git a/target/i386/tcg/translate.c b/target/i386/tcg/translate.c
index 57e83873934..903553dc88e 100644
--- a/target/i386/tcg/translate.c
+++ b/target/i386/tcg/translate.c
@@ -1512,7 +1512,7 @@ static uint64_t advance_pc(CPUX86State *env, DisasContext
*s, int num_bytes)
/* This is a subsequent insn that crosses a page boundary. */
if (s->base.num_insns > 1 &&
- !is_same_page(&s->base, s->pc + num_bytes - 1)) {
+ !translator_is_same_page(&s->base, s->pc + num_bytes - 1)) {
siglongjmp(s->jmpbuf, 2);
}
@@ -2226,7 +2226,7 @@ static void gen_jmp_rel(DisasContext *s, MemOp ot, int
diff, int tb_num)
* no extra masking to apply (data16 branch in code32, see above),
* then we have also proven that the addition does not wrap.
*/
- if (!use_goto_tb || !is_same_page(&s->base, new_pc)) {
+ if (!use_goto_tb || !translator_is_same_page(&s->base, new_pc)) {
tcg_gen_andi_tl(cpu_eip, cpu_eip, mask);
use_goto_tb = false;
}
@@ -3763,7 +3763,7 @@ static void i386_tr_translate_insn(DisasContextBase
*dcbase, CPUState *cpu)
* chance to happen.
*/
dc->base.is_jmp = DISAS_EOB_NEXT;
- } else if (!is_same_page(&dc->base, dc->base.pc_next)) {
+ } else if (!translator_is_same_page(&dc->base, dc->base.pc_next)) {
dc->base.is_jmp = DISAS_TOO_MANY;
}
}
diff --git a/target/riscv/translate.c b/target/riscv/translate.c
index 5fedde363f7..a76f67c5dd0 100644
--- a/target/riscv/translate.c
+++ b/target/riscv/translate.c
@@ -1305,7 +1305,7 @@ static void riscv_tr_translate_insn(DisasContextBase
*dcbase, CPUState *cpu)
/* Only the first insn within a TB is allowed to cross a page boundary. */
if (ctx->base.is_jmp == DISAS_NEXT) {
- if (ctx->itrigger || !is_same_page(&ctx->base, ctx->base.pc_next)) {
+ if (ctx->itrigger || !translator_is_same_page(&ctx->base,
ctx->base.pc_next)) {
ctx->base.is_jmp = DISAS_TOO_MANY;
} else {
unsigned page_ofs = ctx->base.pc_next & ~TARGET_PAGE_MASK;
@@ -1315,7 +1315,7 @@ static void riscv_tr_translate_insn(DisasContextBase
*dcbase, CPUState *cpu)
translator_lduw(env, &ctx->base, ctx->base.pc_next);
int len = insn_len(next_insn);
- if (!is_same_page(&ctx->base, ctx->base.pc_next + len - 1)) {
+ if (!translator_is_same_page(&ctx->base, ctx->base.pc_next +
len - 1)) {
ctx->base.is_jmp = DISAS_TOO_MANY;
}
}
diff --git a/target/s390x/tcg/translate.c b/target/s390x/tcg/translate.c
index e78815c4f7f..81554f2ad9d 100644
--- a/target/s390x/tcg/translate.c
+++ b/target/s390x/tcg/translate.c
@@ -6423,8 +6423,8 @@ static void s390x_tr_translate_insn(DisasContextBase
*dcbase, CPUState *cs)
dc->base.is_jmp = translate_one(env, dc);
if (dc->base.is_jmp == DISAS_NEXT) {
if (dc->ex_value ||
- !is_same_page(dcbase, dc->base.pc_next) ||
- !is_same_page(dcbase, get_next_pc(env, dc, dc->base.pc_next))) {
+ !translator_is_same_page(dcbase, dc->base.pc_next) ||
+ !translator_is_same_page(dcbase, get_next_pc(env, dc,
dc->base.pc_next))) {
dc->base.is_jmp = DISAS_TOO_MANY;
}
}
--
2.47.1
- [PULL 41/59] target/loongarch: Declare loongarch_cpu_dump_state() locally, (continued)
- [PULL 41/59] target/loongarch: Declare loongarch_cpu_dump_state() locally, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 43/59] target/sparc: Move sparc_restore_state_to_opc() to cpu.c, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 42/59] target/sparc: Uninline cpu_get_tb_cpu_state(), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 44/59] exec/cpu-all: Include 'cpu.h' earlier so MMU_USER_IDX is always defined, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 45/59] accel/tcg: Declare cpu_loop_exit_requested() in 'exec/cpu-common.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 46/59] exec/translation-block: Include missing 'qemu/atomic.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 47/59] qemu/coroutine: Include missing 'qemu/atomic.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 48/59] accel/tcg: Restrict curr_cflags() declaration to 'internal-common.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 49/59] accel/tcg: Move tcg_cflags_has/set() to 'exec/translation-block.h', Philippe Mathieu-Daudé, 2024/12/20
- [PULL 50/59] accel/tcg: Include missing 'exec/translation-block.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 51/59] accel/tcg: Un-inline translator_is_same_page(),
Philippe Mathieu-Daudé <=
- [PULL 52/59] target/xtensa: Remove tswap() calls in semihosting simcall() helper, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 53/59] target/mips: Remove tswap() calls in semihosting uhi_fstat_cb(), Philippe Mathieu-Daudé, 2024/12/20
- [PULL 55/59] hw/xen: Remove unnecessary 'exec/cpu-common.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 54/59] target/mips: Drop left-over comment about Jazz machine, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 56/59] system/numa: Remove unnecessary 'exec/cpu-common.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 57/59] system/accel-ops: Remove unnecessary 'exec/cpu-common.h' header, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 58/59] meson: Do not define CONFIG_DEVICES on user emulation, Philippe Mathieu-Daudé, 2024/12/20
- [PULL 59/59] util/qemu-timer: fix indentation, Philippe Mathieu-Daudé, 2024/12/20
- Re: [PULL 00/59] Accel & exec patches for 2024-12-20, Stefan Hajnoczi, 2024/12/21