Author: cem
Date: Wed Oct 16 18:27:27 2019
New Revision: 353662
URL: https://svnweb.freebsd.org/changeset/base/353662

Log:
  ddb: Add support for disassembling 'crc32' on amd64

Modified:
  head/sys/amd64/amd64/db_disasm.c

Modified: head/sys/amd64/amd64/db_disasm.c
==============================================================================
--- head/sys/amd64/amd64/db_disasm.c    Wed Oct 16 18:12:22 2019        
(r353661)
+++ head/sys/amd64/amd64/db_disasm.c    Wed Oct 16 18:27:27 2019        
(r353662)
@@ -145,6 +145,26 @@ static const struct inst db_inst_0f388x[] = {
 /*8f*/ { "",      FALSE, NONE,  0,           0 },
 };
 
+static const struct inst db_inst_0f38fx[] = {
+/*f0*/ { "crc32b",TRUE,  NONE,  op2(Eb, R),  0 },
+/*f1*/ { "crc32", TRUE,  LONG,  op2(E, R),   0 },
+/*f2*/ { "",      FALSE, NONE,  0,           0 },
+/*f3*/ { "",      FALSE, NONE,  0,           0 },
+/*f4*/ { "",      FALSE, NONE,  0,           0 },
+/*f5*/ { "",      FALSE, NONE,  0,           0 },
+/*f6*/ { "",      FALSE, NONE,  0,           0 },
+/*f7*/ { "",      FALSE, NONE,  0,           0 },
+
+/*f8*/ { "",      FALSE, NONE,  0,           0 },
+/*f9*/ { "",      FALSE, NONE,  0,           0 },
+/*fa*/ { "",      FALSE, NONE,  0,           0 },
+/*fb*/ { "",      FALSE, NONE,  0,           0 },
+/*fc*/ { "",      FALSE, NONE,  0,           0 },
+/*fd*/ { "",      FALSE, NONE,  0,           0 },
+/*fe*/ { "",      FALSE, NONE,  0,           0 },
+/*ff*/ { "",      FALSE, NONE,  0,           0 },
+};
+
 static const struct inst * const db_inst_0f38[] = {
        0,
        0,
@@ -161,7 +181,7 @@ static const struct inst * const db_inst_0f38[] = {
        0,
        0,
        0,
-       0
+       db_inst_0f38fx
 };
 
 static const char * const db_Grp6[] = {
@@ -1238,7 +1258,7 @@ db_disasm(db_addr_t loc, bool altfmt)
        boolean_t       first;
        int     displ;
        int     prefix;
-       int     rep;
+       int     rep, repne;
        int     imm;
        int     imm2;
        long    imm64;
@@ -1254,6 +1274,7 @@ db_disasm(db_addr_t loc, bool altfmt)
         * Get prefixes
         */
        rep = FALSE;
+       repne = FALSE;
        prefix = TRUE;
        do {
            switch (inst) {
@@ -1284,8 +1305,12 @@ db_disasm(db_addr_t loc, bool altfmt)
                case 0xf0:
                    db_printf("lock ");
                    break;
+                   /*
+                    * XXX repne/repe are only actually valid for MOVS, CMPS,
+                    * SCAS, LODS, STOS, INS, OUTS.
+                    */
                case 0xf2:
-                   db_printf("repne ");
+                   repne = TRUE;
                    break;
                case 0xf3:
                    rep = TRUE;
@@ -1480,6 +1505,11 @@ db_disasm(db_addr_t loc, bool altfmt)
                rep = FALSE;
            }
        }
+       /* N.B., likely highly incomplete. */
+       if (repne) {
+               if (ip == &db_inst_0f38fx[0] || ip == &db_inst_0f38fx[1])
+                       repne = FALSE;
+       }
        if (size == WORD) {
            if (ip->i_extra == db_Grp9 && f_mod(rex, regmodrm) != 3 &&
                f_reg(rex, regmodrm) == 0x6) {
@@ -1495,6 +1525,8 @@ db_disasm(db_addr_t loc, bool altfmt)
 
        if (rep == TRUE)
            db_printf("repe "); /* XXX repe VS rep */
+       if (repne == TRUE)
+           db_printf("repne ");
 
        if (i_size == SDEP) {
            if (size == LONG)
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to