diff mbox series

[RFC,v4,13/75] target/i386: decode the 0F38/0F3A prefix in gen_sse_ng

Message ID 20190821172951.15333-14-jan.bobek@gmail.com (mailing list archive)
State New, archived
Headers show
Series rewrite MMX/SSE*/AVX/AVX2 vector instruction translation | expand

Commit Message

Jan Bobek Aug. 21, 2019, 5:28 p.m. UTC
In order to decode 0F38/0F3A-prefixed instructions, we need to load an
additional byte. This poses a problem if the instruction is not
implemented yet; implement a rewind in this (default) case.

Signed-off-by: Jan Bobek <jan.bobek@gmail.com>
---
 target/i386/translate.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/target/i386/translate.c b/target/i386/translate.c
index 661010973b..bd9c62dc54 100644
--- a/target/i386/translate.c
+++ b/target/i386/translate.c
@@ -4545,7 +4545,23 @@  static void gen_sse_ng(CPUX86State *env, DisasContext *s, int b)
 #define CASES_VEX_LIG(e, N, ...)  CASES_VEX_L128(e, N, ## __VA_ARGS__)  \
                                   CASES_VEX_L256(e, N, ## __VA_ARGS__)
 
+        CASES(0x38, 3, W, IG, M, 0F, P, IG)
+        CASES(0x38, 4, W, IG, M, 0F, P, IG, VEX_L, IG) {
+            m = M_0F38;
+            op = x86_ldub_code(env, s);
+        } break;
+
+        CASES(0x3a, 3, W, IG, M, 0F, P, IG)
+        CASES(0x3a, 4, W, IG, M, 0F, P, IG, VEX_L, IG) {
+            m = M_0F3A;
+            op = x86_ldub_code(env, s);
+        } break;
+
         default: {
+            if (m == M_0F38 || m == M_0F3A) {
+                /* rewind the advance_pc() x86_ldub_code() did */
+                advance_pc(env, s, -1);
+            }
             gen_sse(env, s, b);
         } return;