Index: mips_timer.c =================================================================== --- mips_timer.c (revision 6146) +++ mips_timer.c (working copy) @@ -8,9 +8,17 @@ uint32_t cpu_mips_get_random (CPUState *env) { static uint32_t seed = 0; + static uint32_t prev_idx = 0; uint32_t idx; seed = seed * 314159 + 1; idx = (seed >> 16) % (env->tlb->nb_tlb - env->CP0_Wired) + env->CP0_Wired; + if (idx == prev_idx) { + /* Don't return same value twice, so get another value */ + idx = prev_idx + 1; + if (idx == env->tlb->nb_tlb) + idx = env->CP0_Wired; + } + prev_idx = idx; return idx; }