--- /dev/null
+#ifndef __VMM_EMULATE_H
+#define __VMM_EMULATE_H
+
+
+/* JRL: Most of this was taken from the Xen sources...
+ *
+ */
+
+
+#define MAKE_INSTR(nm, ...) static const uchar_t OPCODE_##nm[] = { __VA_ARGS__ }
+
+/*
+ * Here's how it works:
+ * First byte: Length.
+ * Following bytes: Opcode bytes.
+ * Special case: Last byte, if zero, doesn't need to match.
+ */
+MAKE_INSTR(INVD, 2, 0x0f, 0x08);
+MAKE_INSTR(CPUID, 2, 0x0f, 0xa2);
+MAKE_INSTR(RDMSR, 2, 0x0f, 0x32);
+MAKE_INSTR(WRMSR, 2, 0x0f, 0x30);
+MAKE_INSTR(RDTSC, 2, 0x0f, 0x31);
+MAKE_INSTR(RDTSCP, 3, 0x0f, 0x01, 0xf9);
+MAKE_INSTR(CLI, 1, 0xfa);
+MAKE_INSTR(STI, 1, 0xfb);
+MAKE_INSTR(RDPMC, 2, 0x0f, 0x33);
+MAKE_INSTR(CLGI, 3, 0x0f, 0x01, 0xdd);
+MAKE_INSTR(STGI, 3, 0x0f, 0x01, 0xdc);
+MAKE_INSTR(VMRUN, 3, 0x0f, 0x01, 0xd8);
+MAKE_INSTR(VMLOAD, 3, 0x0f, 0x01, 0xda);
+MAKE_INSTR(VMSAVE, 3, 0x0f, 0x01, 0xdb);
+MAKE_INSTR(VMCALL, 3, 0x0f, 0x01, 0xd9);
+MAKE_INSTR(PAUSE, 2, 0xf3, 0x90);
+MAKE_INSTR(SKINIT, 3, 0x0f, 0x01, 0xde);
+MAKE_INSTR(MOV2CR, 3, 0x0f, 0x22, 0x00);
+MAKE_INSTR(MOVCR2, 3, 0x0f, 0x20, 0x00);
+MAKE_INSTR(MOV2DR, 3, 0x0f, 0x23, 0x00);
+MAKE_INSTR(MOVDR2, 3, 0x0f, 0x21, 0x00);
+MAKE_INSTR(PUSHF, 1, 0x9c);
+MAKE_INSTR(POPF, 1, 0x9d);
+MAKE_INSTR(RSM, 2, 0x0f, 0xaa);
+MAKE_INSTR(INVLPG, 3, 0x0f, 0x01, 0x00);
+MAKE_INSTR(INVLPGA,3, 0x0f, 0x01, 0xdf);
+MAKE_INSTR(HLT, 1, 0xf4);
+MAKE_INSTR(CLTS, 2, 0x0f, 0x06);
+MAKE_INSTR(LMSW, 3, 0x0f, 0x01, 0x00);
+MAKE_INSTR(SMSW, 3, 0x0f, 0x01, 0x00);
+
+
+
+static inline int is_prefix_byte(char byte) {
+ switch (byte) {
+ case 0xF0: // lock
+ case 0xF2: // REPNE/REPNZ
+ case 0xF3: // REP or REPE/REPZ
+ case 0x2E: // CS override or Branch hint not taken (with Jcc instrs)
+ case 0x36: // SS override
+ case 0x3E: // DS override or Branch hint taken (with Jcc instrs)
+ case 0x26: // ES override
+ case 0x64: // FS override
+ case 0x65: // GS override
+ //case 0x2E: // branch not taken hint
+ // case 0x3E: // branch taken hint
+ case 0x66: // operand size override
+ case 0x67: // address size override
+ return 1;
+ break;
+ default:
+ return 0;
+ break;
+ }
+}
+
+
+
+
+
+
+#endif