The DSP LHX, LWX and LDX loads require a naturally aligned address
and raise Address Error otherwise (MD00374 r3.01 p.130-131, MD00375
r3.02 p.145). Use the default memop alignment mask for them (strict,
except under linux-user FIXADE); LBUX is a byte access.
The Octeon LX forms share gen_lx() and are unchanged.

LDX belongs to the MIPS64 DSP module only, but was decoded on any DSP
CPU in a 64-bit build, including 32-bit ones such as the 24KE or 74K.
Call check_mips_64() after the DSP Disabled check to raise Reserved
Instruction there.

Fixes: 9b1a1d68d041 ("target-mips: Add ASE DSP load instructions")
Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
---
 target/mips/tcg/translate.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index d1be32bfd9f5..6966b7e56abb 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -13653,17 +13653,18 @@ static void decode_opc_special3_legacy(CPUMIPSState 
*env, DisasContext *ctx)
         switch (op2) {
 #if defined(TARGET_MIPS64)
         case OPC_LDX:
-            gen_lx(ctx, rd, rs, rt, MO_UQ);
+            check_mips_64(ctx);
+            gen_lx(ctx, rd, rs, rt, MO_UQ | ctx->default_tcg_memop_mask);
             break;
 #endif
         case OPC_LBUX:
             gen_lx(ctx, rd, rs, rt, MO_UB);
             break;
         case OPC_LHX:
-            gen_lx(ctx, rd, rs, rt, MO_SW);
+            gen_lx(ctx, rd, rs, rt, MO_SW | ctx->default_tcg_memop_mask);
             break;
         case OPC_LWX:
-            gen_lx(ctx, rd, rs, rt, MO_SL);
+            gen_lx(ctx, rd, rs, rt, MO_SL | ctx->default_tcg_memop_mask);
             break;
         default:            /* Invalid */
             MIPS_INVAL("MASK LX");
-- 
2.55.0


Reply via email to