thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 6 months ago
Clone

Blame SOURCES/kvm-target-i386-fix-operand-size-of-unary-SSE-operations.patch

ed5979
From f4ddcdd2395e0944c20f6683c66068ed0ac7d757 Mon Sep 17 00:00:00 2001
ed5979
From: Paolo Bonzini <pbonzini@redhat.com>
ed5979
Date: Sat, 7 Jan 2023 18:14:20 +0100
ed5979
Subject: [PATCH 1/8] target/i386: fix operand size of unary SSE operations
ed5979
ed5979
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
ed5979
RH-MergeRequest: 154: target/i386: fix bugs in emulation of BMI instructions
ed5979
RH-Bugzilla: 2173590
ed5979
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
ed5979
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
ed5979
RH-Acked-by: Bandan Das <None>
ed5979
RH-Commit: [1/7] 7041f3e30e19add6bd8e5355d8bebf92390a5c2e (bonzini/rhel-qemu-kvm)
ed5979
ed5979
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2173590
ed5979
Upstream-Status: merged
ed5979
ed5979
VRCPSS, VRSQRTSS and VCVTSx2Sx have a 32-bit or 64-bit memory operand,
ed5979
which is represented in the decoding tables by X86_VEX_REPScalar.  Add it
ed5979
to the tables, and make validate_vex() handle the case of an instruction
ed5979
that is in exception type 4 without the REP prefix and exception type 5
ed5979
with it; this is the cas of VRCP and VRSQRT.
ed5979
ed5979
Reported-by: yongwoo <https://gitlab.com/yongwoo36>
ed5979
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1377
ed5979
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
ed5979
(cherry picked from commit 3d304620ec6c95f31db17acc132f42f243369299)
ed5979
---
ed5979
 target/i386/tcg/decode-new.c.inc | 11 ++++++-----
ed5979
 1 file changed, 6 insertions(+), 5 deletions(-)
ed5979
ed5979
diff --git a/target/i386/tcg/decode-new.c.inc b/target/i386/tcg/decode-new.c.inc
ed5979
index 80c579164f..d5fd8d965c 100644
ed5979
--- a/target/i386/tcg/decode-new.c.inc
ed5979
+++ b/target/i386/tcg/decode-new.c.inc
ed5979
@@ -105,6 +105,7 @@
ed5979
 #define vex3 .vex_class = 3,
ed5979
 #define vex4 .vex_class = 4,
ed5979
 #define vex4_unal .vex_class = 4, .vex_special = X86_VEX_SSEUnaligned,
ed5979
+#define vex4_rep5 .vex_class = 4, .vex_special = X86_VEX_REPScalar,
ed5979
 #define vex5 .vex_class = 5,
ed5979
 #define vex6 .vex_class = 6,
ed5979
 #define vex7 .vex_class = 7,
ed5979
@@ -839,8 +840,8 @@ static const X86OpEntry opcodes_0F[256] = {
ed5979
 
ed5979
     [0x50] = X86_OP_ENTRY3(MOVMSK,     G,y, None,None, U,x, vex7 p_00_66),
ed5979
     [0x51] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
ed5979
-    [0x52] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex5 p_00_f3),
ed5979
-    [0x53] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex5 p_00_f3),
ed5979
+    [0x52] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex4_rep5 p_00_f3),
ed5979
+    [0x53] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex4_rep5 p_00_f3),
ed5979
     [0x54] = X86_OP_ENTRY3(PAND,       V,x, H,x, W,x,  vex4 p_00_66), /* vand */
ed5979
     [0x55] = X86_OP_ENTRY3(PANDN,      V,x, H,x, W,x,  vex4 p_00_66), /* vandn */
ed5979
     [0x56] = X86_OP_ENTRY3(POR,        V,x, H,x, W,x,  vex4 p_00_66), /* vor */
ed5979
@@ -878,7 +879,7 @@ static const X86OpEntry opcodes_0F[256] = {
ed5979
 
ed5979
     [0x58] = X86_OP_ENTRY3(VADD,       V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
ed5979
     [0x59] = X86_OP_ENTRY3(VMUL,       V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
ed5979
-    [0x5a] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex3 p_00_66_f3_f2),
ed5979
+    [0x5a] = X86_OP_GROUP3(sse_unary,  V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
ed5979
     [0x5b] = X86_OP_GROUP0(0F5B),
ed5979
     [0x5c] = X86_OP_ENTRY3(VSUB,       V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
ed5979
     [0x5d] = X86_OP_ENTRY3(VMIN,       V,x, H,x, W,x, vex2_rep3 p_00_66_f3_f2),
ed5979
@@ -1447,9 +1448,9 @@ static bool validate_vex(DisasContext *s, X86DecodedInsn *decode)
ed5979
          * Instructions which differ between 00/66 and F2/F3 in the
ed5979
          * exception classification and the size of the memory operand.
ed5979
          */
ed5979
-        assert(e->vex_class == 1 || e->vex_class == 2);
ed5979
+        assert(e->vex_class == 1 || e->vex_class == 2 || e->vex_class == 4);
ed5979
         if (s->prefix & (PREFIX_REPZ | PREFIX_REPNZ)) {
ed5979
-            e->vex_class = 3;
ed5979
+            e->vex_class = e->vex_class < 4 ? 3 : 5;
ed5979
             if (s->vex_l) {
ed5979
                 goto illegal;
ed5979
             }
ed5979
-- 
ed5979
2.39.1
ed5979