Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 May 2014 21:10:03 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266354 - head/sys/amd64/amd64
Message-ID:  <201405172110.s4HLA3Xg097292@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Sat May 17 21:10:03 2014
New Revision: 266354
URL: http://svnweb.freebsd.org/changeset/base/266354

Log:
  Add support for decoding rdrand and rdseed.

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

Modified: head/sys/amd64/amd64/db_disasm.c
==============================================================================
--- head/sys/amd64/amd64/db_disasm.c	Sat May 17 21:07:54 2014	(r266353)
+++ head/sys/amd64/amd64/db_disasm.c	Sat May 17 21:10:03 2014	(r266354)
@@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
 #define	R	5			/* register, in 'reg' field */
 #define	Rw	6			/* word register, in 'reg' field */
 #define	Rq	39			/* quad register, in 'reg' field */
+#define	Rv	40			/* register in 'r/m' field */
 #define	Ri	7			/* register in instruction */
 #define	S	8			/* segment reg, in 'reg' field */
 #define	Si	9			/* segment reg, in instruction */
@@ -628,6 +629,17 @@ static const struct inst db_Grp5[] = {
 	{ "",      TRUE, NONE, 0,	 0 }
 };
 
+static const struct inst db_Grp9b[] = {
+	{ "",      TRUE, NONE, 0,	 0 },
+	{ "",      TRUE, NONE, 0,	 0 },
+	{ "",      TRUE, NONE, 0,	 0 },
+	{ "",      TRUE, NONE, 0,	 0 },
+	{ "",      TRUE, NONE, 0,	 0 },
+	{ "",      TRUE, NONE, 0,	 0 },
+	{ "rdrand",TRUE, LONG, op1(Rv),  0 },
+	{ "rdseed",TRUE, LONG, op1(Rv),  0 }
+};
+
 static const struct inst db_inst_table[256] = {
 /*00*/	{ "add",   TRUE,  BYTE,  op2(R, E),  0 },
 /*01*/	{ "add",   TRUE,  LONG,  op2(R, E),  0 },
@@ -1300,7 +1312,13 @@ db_disasm(loc, altfmt)
 	i_size = ip->i_size;
 	i_mode = ip->i_mode;
 
-	if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||
+	if (ip->i_extra == db_Grp9 && f_mod(rex, regmodrm) == 3) {
+	    ip = &db_Grp9b[f_reg(rex, regmodrm)];
+	    i_name = ip->i_name;
+	    i_size = ip->i_size;
+	    i_mode = ip->i_mode;
+	}
+	else if (ip->i_extra == db_Grp1 || ip->i_extra == db_Grp2 ||
 	    ip->i_extra == db_Grp6 || ip->i_extra == db_Grp7 ||
 	    ip->i_extra == db_Grp8 || ip->i_extra == db_Grp9 ||
 	    ip->i_extra == db_Grp15) {
@@ -1511,6 +1529,10 @@ db_disasm(loc, altfmt)
 		    db_printf("%s", db_reg[rex != 0 ? 1 : 0][(rex & REX_R) ? QUAD : LONG][f_rm(rex, inst)]);
 		    break;
 
+	        case Rv:
+		    db_printf("%s", db_reg[rex != 0 ? 1 : 0][(size == LONG && (rex & REX_W)) ? QUAD : size][f_rm(rex, regmodrm)]);
+		    break;
+
 		case S:
 		    db_printf("%s", db_seg_reg[f_reg(rex, regmodrm)]);
 		    break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405172110.s4HLA3Xg097292>