On 18/11/26 00:07, Philippe Mathieu-Daudé wrote:
On 17/11/26 20:12, Richard Henderson wrote:
On 11/13/26 08:11, Philippe Mathieu-Daudé wrote:
CACHE and CACHEE share pseudo-code raising Reserved Instruction on
NMS cores without caches, but only CACHEE performed that check.
See MD01247 rev 01.01, "CACHE/CACHEE" (printed page 63).

Fixes: 8f1d9b6d6397 ("target/mips: Add emulation of nanoMIPS 32-bit LD/ST")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
  target/mips/tcg/nanomips_translate.c.inc | 1 +
  1 file changed, 1 insertion(+)

diff --git a/target/mips/tcg/nanomips_translate.c.inc b/target/mips/ tcg/nanomips_translate.c.inc
index c883b5514f1c..20e96f2ad9be 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -4131,6 +4131,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
                      }
                      break;
                  case NM_CACHE:
+                    check_nms_dl_il_sl_tl_l2c(ctx);
                      check_cp0_enabled(ctx);
                      if (ctx->hflags & MIPS_HFLAG_ITC_CACHE) {
                          gen_cache_operation(ctx, rt, rs, s);

Also missing check_eva.

The EVA check in the shared pseudo-code is gated by the per-format
is_eva flag -- CACHE sets is_eva = False, CACHEE sets is_eva = True
(MD01247 rev 01.01 p.63): "if is_eva and not C0.Config5.EVA: raise
exception('RI')". For plain CACHE it is dead (never raises RI), and
check_eva() would wrongly raise RI on cores without Config5.EVA.

I'll post the NM_CACHEE reorder as a follow-up.

Hmm looking further commit 84c2fdc397b6 ("target/mips: Fix CACHEE opcode
(CACHE using EVA addressing)") added the check at an invalid position;
we check EVA -> CP0 -> NMS; the spec checks NMS -> EVA -> CP0 (in
MD01247 rev 01.01 p.63 pseudo-code block). On a core with NMS=1, no
caches, EVA=1 and CP0 disabled, the spec says RI while we deliver
Coprocessor Unusable.



Reply via email to