2 #include <linux/kernel.h>
7 struct selftest_opcode
{
8 unsigned int expected_size
;
13 static const struct selftest_opcode selftest_opcodes
[] = {
15 {1, "\xf3\xa4", "rep movsb <mem8>, <mem8>"},
16 {4, "\xf3\xa5", "rep movsl <mem32>, <mem32>"},
19 {1, "\x66\x0f\xb6\x51\xf8", "movzwq <mem8>, <reg16>"},
20 {1, "\x0f\xb6\x51\xf8", "movzwq <mem8>, <reg32>"},
23 {1, "\x66\x0f\xbe\x51\xf8", "movswq <mem8>, <reg16>"},
24 {1, "\x0f\xbe\x51\xf8", "movswq <mem8>, <reg32>"},
28 {1, "\x49\x0f\xb6\x51\xf8", "movzbq <mem8>, <reg64>"},
29 {2, "\x49\x0f\xb7\x51\xf8", "movzbq <mem16>, <reg64>"},
32 {1, "\x49\x0f\xbe\x51\xf8", "movsbq <mem8>, <reg64>"},
33 {2, "\x49\x0f\xbf\x51\xf8", "movsbq <mem16>, <reg64>"},
34 {4, "\x49\x63\x51\xf8", "movslq <mem32>, <reg64>"},
38 static bool selftest_opcode_one(const struct selftest_opcode
*op
)
42 kmemcheck_opcode_decode(op
->insn
, &size
);
44 if (size
== op
->expected_size
)
47 printk(KERN_WARNING
"kmemcheck: opcode %s: expected size %d, got %d\n",
48 op
->desc
, op
->expected_size
, size
);
52 static bool selftest_opcodes_all(void)
57 for (i
= 0; i
< ARRAY_SIZE(selftest_opcodes
); ++i
)
58 pass
= pass
&& selftest_opcode_one(&selftest_opcodes
[i
]);
63 bool kmemcheck_selftest(void)
67 pass
= pass
&& selftest_opcodes_all();