Skip to contentSkip to conversation

target-mips: Fix Loongson multimedia instructions.

PATCH Superseded Heiher 2 participants 3 messages Oct 13, 2016 – Oct 14, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Heiher

author
#0 lore raw

PATCH 2/2 target-mips: Fix Loongson multimedia instructions.

From: Heiher <[email protected]>

Needed to emit FPU exception on Loongson multimedia instructions executing if Status:CU1 is clear. or FPR changes may be missed on Linux.

---
 target-mips/translate.c | 1 +
 1 file changed, 1 insertion(+)
target-mips/translate.c +1 -0
index 139f249..b87a09b 100644
@@ -3871,6 +3871,7 @@ static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt)
         break;
     }
 
+    check_cp1_enabled(ctx);
     gen_load_fpr64(ctx, t0, rs);
     gen_load_fpr64(ctx, t1, rt);
 
Signature · 1 line
2.10.0
#1 lore raw
Quoted 17 lines · Heiher

From: Heiher <[email protected]>

Needed to emit FPU exception on Loongson multimedia instructions executing if Status:CU1 is clear. or FPR changes may be missed on Linux.

---
 target-mips/translate.c | 1 +
 1 file changed, 1 insertion(+)
target-mips/translate.c +0 -0
index 139f249..b87a09b 100644

target-mips/translate.c static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt) · line 3874

Quoted 4 lines
target-mips/translate.c +1 -0
@@ -3871,6 +3871,7 @@ static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt)
         break;
     }
 
+    check_cp1_enabled(ctx);

Isn't it also required to check Status.CU2 bit? I guess the Loongson Multimedia instructions was implemented as the Cop2? Please correct me if I am wrong with this.

target-mips/translate.c static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt) · line 3877

Quoted 4 lines
target-mips/translate.c +0 -0
     gen_load_fpr64(ctx, t0, rs);
     gen_load_fpr64(ctx, t1, rt);
 

Regards,
Yongbok

author
#2 lore raw
Quoted 23 lines · Yongbok Kim
Quoted 20 lines · Heiher

From: Heiher <[email protected]>

Needed to emit FPU exception on Loongson multimedia instructions executing if Status:CU1 is clear. or FPR changes may be missed on Linux.

---
 target-mips/translate.c | 1 +
 1 file changed, 1 insertion(+)
target-mips/translate.c +0 -0
index 139f249..b87a09b 100644
@@ -3871,6 +3871,7 @@ static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt)
         break;
     }
 
Quoted 5 lines

target-mips/translate.c static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt) · line 3874

Quoted 1 line
target-mips/translate.c +1 -0
+    check_cp1_enabled(ctx);

Isn't it also required to check Status.CU2 bit? I guess the Loongson Multimedia instructions was implemented as the Cop2? Please correct me if I am wrong with this.

I don't think the Loongson CPUs have real coprocessor 2 although these multimedia instructions are encoding as Cp2. Similar to MSA, these instructions reusing 64-bit FPRs. In fact, The older Loongson CPUs emit Cp2 unusable exception, so a cp2 hook is needed to combine FPU and Cp2 in kernel. In new revision, Cp1 exception is emitted.

Quoted 8 lines

target-mips/translate.c static void gen_loongson_multimedia(DisasContext *ctx, int rd, int rs, int rt) · line 3877

Quoted 5 lines
target-mips/translate.c +0 -0
     gen_load_fpr64(ctx, t0, rs);
     gen_load_fpr64(ctx, t1, rt);
 

Regards,
Yongbok

Signature · 3 lines
Best regards!
Heiher
http://hev.cc