2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu>
11 * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Jack Lange <jarusl@cs.northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <palacios/vmm_decoder.h>
27 uint8_t v3_get_prefixes(uint8_t * instr, struct x86_prefixes * prefixes) {
28 uint8_t * instr_cursor = instr;
31 switch (*instr_cursor) {
36 case 0xF2: // REPNE/REPNZ
41 case 0xF3: // REP or REPE/REPZ
47 case 0x2E: // CS override or Branch hint not taken (with Jcc instr_cursors)
48 prefixes->cs_override = 1;
49 prefixes->br_not_taken = 1;
52 case 0x36: // SS override
53 prefixes->ss_override = 1;
56 case 0x3E: // DS override or Branch hint taken (with Jcc instr_cursors)
57 prefixes->ds_override = 1;
58 prefixes->br_taken = 1;
61 case 0x26: // ES override
62 prefixes->es_override = 1;
65 case 0x64: // FS override
66 prefixes->fs_override = 1;
69 case 0x65: // GS override
70 prefixes->gs_override = 1;
73 case 0x66: // operand size override
74 prefixes->op_size = 1;
77 case 0x67: // address size override
78 prefixes->addr_size = 1;
82 return (instr_cursor - instr);
89 void v3_strip_rep_prefix(uchar_t * instr, int length) {
94 while (read_ctr < length) {
96 ( (instr[read_ctr] == 0xF2) ||
97 (instr[read_ctr] == 0xF3))) {
101 instr[write_ctr] = instr[read_ctr];