[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 56/84] tcg: Move TLB_FLAGS_MASK check out of get_alignment_bits
|
From: |
Richard Henderson |
|
Subject: |
[PATCH 56/84] tcg: Move TLB_FLAGS_MASK check out of get_alignment_bits |
|
Date: |
Wed, 3 May 2023 08:23:03 +0100 |
The replacement isn't ideal, as the raw count of bits
is not easily synced with exec/cpu-all.h, but it does
remove from tcg.h the target dependency on TARGET_PAGE_BITS_MIN
which is built into TLB_FLAGS_MASK.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/cpu-all.h | 3 +++
include/tcg/tcg.h | 4 ----
tcg/tcg-op-ldst.c | 18 ++++++++++++++++--
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index ad824fee52..95b9947e20 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -317,6 +317,9 @@ CPUArchState *cpu_copy(CPUArchState *env);
*
* Use TARGET_PAGE_BITS_MIN so that these bits are constant
* when TARGET_PAGE_BITS_VARY is in effect.
+ *
+ * The count, if not the placement of these bits is known
+ * to tcg/tcg-op-ldst.c, check_max_alignment().
*/
/* Zero if TLB entry is valid. */
#define TLB_INVALID_MASK (1 << (TARGET_PAGE_BITS_MIN - 1))
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 24e8cd65ef..1af6cd5ad4 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -305,10 +305,6 @@ static inline unsigned get_alignment_bits(MemOp memop)
/* A specific alignment requirement. */
a = a >> MO_ASHIFT;
}
-#if defined(CONFIG_SOFTMMU)
- /* The requested alignment cannot overlap the TLB flags. */
- tcg_debug_assert((TLB_FLAGS_MASK & ((1 << a) - 1)) == 0);
-#endif
return a;
}
diff --git a/tcg/tcg-op-ldst.c b/tcg/tcg-op-ldst.c
index 9eef859c97..c962a2aa17 100644
--- a/tcg/tcg-op-ldst.c
+++ b/tcg/tcg-op-ldst.c
@@ -32,11 +32,23 @@
#include "tcg-internal.h"
-static inline MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st)
+static void check_max_alignment(unsigned a_bits)
+{
+#if defined(CONFIG_SOFTMMU)
+ /*
+ * The requested alignment cannot overlap the TLB flags.
+ * FIXME: Must keep the count up-to-date with "exec/cpu-all.h".
+ */
+ tcg_debug_assert(a_bits + 6 <= tcg_ctx->page_bits);
+#endif
+}
+
+static MemOp tcg_canonicalize_memop(MemOp op, bool is64, bool st)
{
- /* Trigger the asserts within as early as possible. */
unsigned a_bits = get_alignment_bits(op);
+ check_max_alignment(a_bits);
+
/* Prefer MO_ALIGN+MO_XX over MO_ALIGN_XX+MO_XX */
if (a_bits == (op & MO_SIZE)) {
op = (op & ~MO_AMASK) | MO_ALIGN;
@@ -502,6 +514,7 @@ static void tcg_gen_qemu_ld_i128_int(TCGv_i128 val, TCGTemp
*addr,
TCGv_i64 ext_addr = NULL;
TCGOpcode opc;
+ check_max_alignment(get_alignment_bits(memop));
tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD);
/* TODO: For now, force 32-bit hosts to use the helper. */
@@ -612,6 +625,7 @@ static void tcg_gen_qemu_st_i128_int(TCGv_i128 val, TCGTemp
*addr,
TCGv_i64 ext_addr = NULL;
TCGOpcode opc;
+ check_max_alignment(get_alignment_bits(memop));
tcg_gen_req_mo(TCG_MO_ST_LD | TCG_MO_ST_ST);
/* TODO: For now, force 32-bit hosts to use the helper. */
--
2.34.1
- [PATCH 62/84] tcg: Remove USE_TCG_OPTIMIZATIONS, (continued)
- [PATCH 62/84] tcg: Remove USE_TCG_OPTIMIZATIONS, Richard Henderson, 2023/05/03
- [PATCH 57/84] tcg: Split tcg/tcg-op-gvec.h, Richard Henderson, 2023/05/03
- [PATCH 68/84] target/arm: Tidy helpers for translation, Richard Henderson, 2023/05/03
- [PATCH 69/84] target/mips: Tidy helpers for translation, Richard Henderson, 2023/05/03
- [PATCH 63/84] tcg: Spit out exec/translation-block.h, Richard Henderson, 2023/05/03
- [PATCH 65/84] accel/tcg: Move most of gen-icount.h into translator.c, Richard Henderson, 2023/05/03
- [PATCH 52/84] tcg: Split helper-gen.h, Richard Henderson, 2023/05/03
- [PATCH 59/84] exec-all: Widen tb_page_addr_t for user-only, Richard Henderson, 2023/05/03
- [PATCH 67/84] accel/tcg: Move translator_fake_ldb out of line, Richard Henderson, 2023/05/03
- [PATCH 49/84] tcg: Pass TCGHelperInfo to tcg_gen_callN, Richard Henderson, 2023/05/03
- [PATCH 56/84] tcg: Move TLB_FLAGS_MASK check out of get_alignment_bits,
Richard Henderson <=
- [PATCH 64/84] include/exec: Remove CODE_GEN_AVG_BLOCK_SIZE, Richard Henderson, 2023/05/03
- [PATCH 61/84] tcg: Remove DEBUG_DISAS, Richard Henderson, 2023/05/03
- [PATCH 72/84] accel/tcg: Tidy includes for translator.[ch], Richard Henderson, 2023/05/03
- [PATCH 73/84] tcg: Define IN_TCG, Richard Henderson, 2023/05/03
- [PATCH 76/84] tcg: Remove target-specific headers from tcg.[ch], Richard Henderson, 2023/05/03
- [PATCH 70/84] *: Add missing includes of exec/translation-block.h, Richard Henderson, 2023/05/03
- [PATCH 66/84] accel/tcg: Introduce translator_io_start, Richard Henderson, 2023/05/03
- [PATCH 58/84] tcg: Remove NO_CPU_IO_DEFS, Richard Henderson, 2023/05/03
- [PATCH 60/84] exec-all: Widen TranslationBlock pc and cs_base to 64-bits, Richard Henderson, 2023/05/03
- [PATCH 71/84] *: Add missing includes of exec/exec-all.h, Richard Henderson, 2023/05/03