1 #include <linux/types.h>
5 static bool opcode_is_prefix(uint8_t b
)
9 b
== 0xf0 || b
== 0xf2 || b
== 0xf3
11 || b
== 0x2e || b
== 0x36 || b
== 0x3e || b
== 0x26
12 || b
== 0x64 || b
== 0x65
20 static bool opcode_is_rex_prefix(uint8_t b
)
22 return (b
& 0xf0) == 0x40;
25 static bool opcode_is_rex_prefix(uint8_t b
)
31 #define REX_W (1 << 3)
34 * This is a VERY crude opcode decoder. We only need to find the size of the
35 * load/store that caused our #PF and this should work for all the opcodes
36 * that we care about. Moreover, the ones who invented this instruction set
39 void kmemcheck_opcode_decode(const uint8_t *op
, unsigned int *size
)
41 /* Default operand size */
42 int operand_size_override
= 4;
45 for (; opcode_is_prefix(*op
); ++op
) {
47 operand_size_override
= 2;
51 if (opcode_is_rex_prefix(*op
)) {
87 * This is move with zero-extend and sign-extend, respectively;
88 * we don't have to think about 0xb6/0xbe, because this is
89 * already handled in the conditional below.
91 if (*op
== 0xb7 || *op
== 0xbf)
92 operand_size_override
= 2;
95 *size
= (*op
& 1) ? operand_size_override
: 1;
98 const uint8_t *kmemcheck_opcode_get_primary(const uint8_t *op
)
101 while (opcode_is_prefix(*op
))
103 if (opcode_is_rex_prefix(*op
))