Eduardo José Gómez Hernández has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/49990 )

Change subject: arch-x86: Fixed M5InternalError when decoding certain bytes
......................................................................

arch-x86: Fixed M5InternalError when decoding certain bytes

0F 38 is the two bytes prefixes to decode a three-byte opcode.
To prevent errors, the two_bytes_opcode decoder will complain
if it tries to decode 38 as the opcode, because it is a prefix.
The decoder, will treat 38 as a prefix, preventing it to
end in the two_byte_opcode decoder.

However, using the VEX prefix is possible to reach this
forbidden state.

The set of bytes C4 01 01 38 00 will trigger the mentioned
M5InternalError.

The previous instruction is not valid, but it could be
decoded from an speculative path. In its place, a UD2
instructtion should be emitted if the VEX prefix is
present.

Change-Id: I6b7c4b3593dd8e6e8ac99aaf306b8feeb7784b56
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/49990
Reviewed-by: Gabe Black <gabe.bl...@gmail.com>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/arch/x86/isa/decoder/two_byte_opcodes.isa
M src/arch/x86/isa/bitfields.isa
2 files changed, 42 insertions(+), 8 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/arch/x86/isa/bitfields.isa b/src/arch/x86/isa/bitfields.isa
index 9522a8d..0404afc 100644
--- a/src/arch/x86/isa/bitfields.isa
+++ b/src/arch/x86/isa/bitfields.isa
@@ -86,5 +86,6 @@
 def bitfield MODE_MODE mode.mode;
 def bitfield MODE_SUBMODE mode.submode;

+def bitfield VEX_PRESENT vex.present;
 def bitfield VEX_V vex.v;
 def bitfield VEX_L vex.l;
diff --git a/src/arch/x86/isa/decoder/two_byte_opcodes.isa b/src/arch/x86/isa/decoder/two_byte_opcodes.isa
index 48f46d4..549db47 100644
--- a/src/arch/x86/isa/decoder/two_byte_opcodes.isa
+++ b/src/arch/x86/isa/decoder/two_byte_opcodes.isa
@@ -354,14 +354,17 @@
             0x6: Inst::UD2();
             0x7: getsec();
         }
-        0x07: decode OPCODE_OP_BOTTOM3 {
-            0x0: M5InternalError::error(
-                {{"Three byte opcode shouldn't be handled by "
-                  "two_byte_opcodes.isa!"}});
-            0x2: M5InternalError::error(
-                {{"Three byte opcode shouldn't be handled by "
-                  "two_byte_opcodes.isa!"}});
-            default: UD2();
+        0x07: decode VEX_PRESENT {
+            0x0: decode OPCODE_OP_BOTTOM3 {
+                0x0: M5InternalError::error(
+                    {{"Three byte opcode shouldn't be handled by "
+                      "two_byte_opcodes.isa!"}});
+                0x2: M5InternalError::error(
+                    {{"Three byte opcode shouldn't be handled by "
+                      "two_byte_opcodes.isa!"}});
+                default: UD2();
+            }
+            0x1: UD2();
         }
         format Inst {
             0x08: decode OPCODE_OP_BOTTOM3 {

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/49990
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I6b7c4b3593dd8e6e8ac99aaf306b8feeb7784b56
Gerrit-Change-Number: 49990
Gerrit-PatchSet: 3
Gerrit-Owner: Eduardo José Gómez Hernández <eduardojose.go...@um.es>
Gerrit-Reviewer: Eduardo José Gómez Hernández <eduardojose.go...@um.es>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to