On 30/1/24 00:30, Richard Henderson wrote:
For user-only mode, use MMU_USER_IDX.
For system mode, use CPUClass.mmu_index.
Signed-off-by: Richard Henderson <richard.hender...@linaro.org>
---
include/exec/cpu-all.h | 4 ++++
include/exec/cpu-common.h | 19 +++++++++++++++++++
target/alpha/cpu.h | 5 -----
target/arm/cpu.h | 13 -------------
target/avr/cpu.h | 5 -----
target/cris/cpu.h | 4 ----
target/hexagon/cpu.h | 9 ---------
target/hppa/cpu.h | 10 ----------
target/i386/cpu.h | 6 ------
target/loongarch/cpu.h | 10 ----------
target/m68k/cpu.h | 4 ----
target/microblaze/cpu.h | 6 ------
target/mips/cpu.h | 5 -----
target/nios2/cpu.h | 6 ------
target/openrisc/cpu.h | 6 ------
target/ppc/cpu.h | 5 -----
target/riscv/cpu.h | 2 --
target/rx/cpu.h | 5 -----
target/s390x/cpu.h | 2 --
target/sh4/cpu.h | 6 ------
target/sparc/cpu.h | 6 ------
target/tricore/cpu.h | 5 -----
target/xtensa/cpu.h | 5 -----
target/hppa/cpu.c | 2 +-
target/i386/cpu.c | 2 +-
target/loongarch/cpu.c | 2 +-
target/microblaze/cpu.c | 2 +-
target/nios2/cpu.c | 2 +-
target/openrisc/cpu.c | 2 +-
target/sh4/cpu.c | 2 +-
target/sparc/cpu.c | 2 +-
31 files changed, 31 insertions(+), 133 deletions(-)
+#ifndef CONFIG_USER_ONLY
+/**
+ * cpu_mmu_index:
+ * @env: The cpu environment
+ * @ifetch: True for code access, false for data access.
+ *
+ * Return the core mmu index for the current translation regime.
+ * This function is used by generic TCG code paths.
+ *
+ * The user-only version of this function is inline in cpu-all.h,
+ * where it always returns MMU_USER_IDX.
+ */
+static inline int cpu_mmu_index(CPUArchState *env, bool ifetch)
+{
+ CPUState *cs = env_cpu(env);
+ return cs->cc->mmu_index(cs, ifetch);
Can we add here:
[tcg_debug_]assert(index < NB_MMU_MODES);
+}
+#endif /* !CONFIG_USER_ONLY */