Skip to contentSkip to conversation

target/i386: tcg: high bits SSE cmp operation must be ignored

PATCH In review Paolo Bonzini 2 participants 2 messages Mar 24, 2022 – Mar 25, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/i386: tcg: high bits SSE cmp operation must be ignored

High bits in the immediate operand of SSE comparisons are ignored, they do not result in an undefined opcode exception. This is mentioned explicitly in the Intel documentation.

---
 target/i386/tcg/translate.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
target/i386/tcg/translate.c +2 -4
index 2a94d33742..c393913fe0 100644
@@ -4509,10 +4509,8 @@ static void gen_sse(CPUX86State *env, DisasContext *s, int b,
             sse_fn_ppi(s->ptr0, s->ptr1, tcg_const_i32(val));
             break;
         case 0xc2:
-            /* compare insns */
-            val = x86_ldub_code(env, s);
-            if (val >= 8)
-                goto unknown_op;
+            /* compare insns, bits 7:3 (7:5 for AVX) are ignored */
+            val = x86_ldub_code(env, s) & 7;
             sse_fn_epp = sse_op_table4[val][b1];
 
             tcg_gen_addi_ptr(s->ptr0, cpu_env, op1_offset);
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Paolo Bonzini

High bits in the immediate operand of SSE comparisons are ignored, they do not result in an undefined opcode exception. This is mentioned explicitly in the Intel documentation.

---
  target/i386/tcg/translate.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)

r~