Add support for decoding rdrand and rdseed.

This commit is contained in:
John Baldwin 2014-05-17 21:10:03 +00:00
parent 888fc9f245
commit 8b3949c344

View File

@ -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;