target/mips: Introduce ase_mt_available() helper
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Wed, 2 Dec 2020 17:49:00 +0000 (18:49 +0100)
committerPhilippe Mathieu-Daudé <f4bug@amsat.org>
Sun, 13 Dec 2020 19:26:02 +0000 (20:26 +0100)
Instead of accessing CP0_Config3 directly and checking
the 'Multi-Threading Present' bit, introduce an helper
to simplify code review.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20201204222622.2743175-3-f4bug@amsat.org>

hw/mips/cps.c
target/mips/cp0_helper.c
target/mips/cpu.c
target/mips/cpu.h
target/mips/helper.c
target/mips/translate.c

index 962b1b0b87cc0480a30f5b7e7ea18a39caf34d0a..7a0d289efaf9de0927768e1cffd51d26c08f7747 100644 (file)
@@ -58,8 +58,7 @@ static void main_cpu_reset(void *opaque)
 
 static bool cpu_mips_itu_supported(CPUMIPSState *env)
 {
-    bool is_mt = (env->CP0_Config5 & (1 << CP0C5_VP)) ||
-                 (env->CP0_Config3 & (1 << CP0C3_MT));
+    bool is_mt = (env->CP0_Config5 & (1 << CP0C5_VP)) || ase_mt_available(env);
 
     return is_mt && !kvm_enabled();
 }
index cb899fe3d7382bb73edecb04a013794cac13e633..36a92857bfb299f5a338077d460d4913d498ccf2 100644 (file)
@@ -1164,7 +1164,7 @@ void helper_mtc0_entryhi(CPUMIPSState *env, target_ulong arg1)
     old = env->CP0_EntryHi;
     val = (arg1 & mask) | (old & ~mask);
     env->CP0_EntryHi = val;
-    if (env->CP0_Config3 & (1 << CP0C3_MT)) {
+    if (ase_mt_available(env)) {
         sync_c0_entryhi(env, env->current_tc);
     }
     /* If the ASID changes, flush qemu's TLB.  */
index 687e2680dd1209e8a45fc0056ac8d3e2d64176d6..9d7edc1ca2134012bdd1c714dbb1c58427e78a08 100644 (file)
@@ -74,7 +74,7 @@ static bool mips_cpu_has_work(CPUState *cs)
     }
 
     /* MIPS-MT has the ability to halt the CPU.  */
-    if (env->CP0_Config3 & (1 << CP0C3_MT)) {
+    if (ase_mt_available(env)) {
         /*
          * The QEMU model will issue an _WAKE request whenever the CPUs
          * should be woken up.
index 5d3b2a01c0188d2127a5761c18b7c0ad00cef25d..3ac21d0e9c07a79152248ea31c55b631df37de42 100644 (file)
@@ -1289,6 +1289,13 @@ int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc);
 bool cpu_type_supports_cps_smp(const char *cpu_type);
 bool cpu_supports_isa(const CPUMIPSState *env, uint64_t isa_mask);
 bool cpu_type_supports_isa(const char *cpu_type, uint64_t isa);
+
+/* Check presence of multi-threading ASE implementation */
+static inline bool ase_mt_available(CPUMIPSState *env)
+{
+    return env->CP0_Config3 & (1 << CP0C3_MT);
+}
+
 void cpu_set_exception_base(int vp_index, target_ulong address);
 
 /* addr.c */
index 59de58fcbc9d7348ca70fe71d5a30a95c4758f31..0c6578657931e7d31c3808078fde779172596287 100644 (file)
@@ -419,7 +419,7 @@ void cpu_mips_store_status(CPUMIPSState *env, target_ulong val)
         tlb_flush(env_cpu(env));
     }
 #endif
-    if (env->CP0_Config3 & (1 << CP0C3_MT)) {
+    if (ase_mt_available(env)) {
         sync_c0_status(env, env, env->current_tc);
     } else {
         compute_hflags(env);
index f218997f049a6fb5c5abc80211523e503bb85fc2..ccc82abce04a207facbcdd9f270159ddcec0aed7 100644 (file)
@@ -31917,7 +31917,7 @@ void cpu_state_reset(CPUMIPSState *env)
 
     cpu_mips_store_count(env, 1);
 
-    if (env->CP0_Config3 & (1 << CP0C3_MT)) {
+    if (ase_mt_available(env)) {
         int i;
 
         /* Only TC0 on VPE 0 starts as active.  */