Changeset View
Changeset View
Standalone View
Standalone View
head/sys/amd64/vmm/vmm_instruction_emul.c
Show First 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | static const struct vie_op two_byte_opcodes[256] = { | ||||
}, | }, | ||||
}; | }; | ||||
static const struct vie_op one_byte_opcodes[256] = { | static const struct vie_op one_byte_opcodes[256] = { | ||||
[0x0F] = { | [0x0F] = { | ||||
.op_byte = 0x0F, | .op_byte = 0x0F, | ||||
.op_type = VIE_OP_TYPE_TWO_BYTE | .op_type = VIE_OP_TYPE_TWO_BYTE | ||||
}, | }, | ||||
[0x0B] = { | |||||
.op_byte = 0x0B, | |||||
.op_type = VIE_OP_TYPE_OR, | |||||
}, | |||||
[0x2B] = { | [0x2B] = { | ||||
.op_byte = 0x2B, | .op_byte = 0x2B, | ||||
.op_type = VIE_OP_TYPE_SUB, | .op_type = VIE_OP_TYPE_SUB, | ||||
}, | }, | ||||
[0x39] = { | [0x39] = { | ||||
.op_byte = 0x39, | .op_byte = 0x39, | ||||
.op_type = VIE_OP_TYPE_CMP, | .op_type = VIE_OP_TYPE_CMP, | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 867 Lines • ▼ Show 20 Lines | emulate_and(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, | ||||
return (error); | return (error); | ||||
} | } | ||||
static int | static int | ||||
emulate_or(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, | emulate_or(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, | ||||
mem_region_read_t memread, mem_region_write_t memwrite, void *arg) | mem_region_read_t memread, mem_region_write_t memwrite, void *arg) | ||||
{ | { | ||||
int error, size; | int error, size; | ||||
uint64_t val1, result, rflags, rflags2; | enum vm_reg_name reg; | ||||
uint64_t result, rflags, rflags2, val1, val2; | |||||
size = vie->opsize; | size = vie->opsize; | ||||
error = EINVAL; | error = EINVAL; | ||||
switch (vie->op.op_byte) { | switch (vie->op.op_byte) { | ||||
case 0x0B: | |||||
/* | |||||
* OR reg (ModRM:reg) and mem (ModRM:r/m) and store the | |||||
* result in reg. | |||||
* | |||||
* 0b/r or r16, r/m16 | |||||
* 0b/r or r32, r/m32 | |||||
* REX.W + 0b/r or r64, r/m64 | |||||
*/ | |||||
/* get the first operand */ | |||||
reg = gpr_map[vie->reg]; | |||||
error = vie_read_register(vm, vcpuid, reg, &val1); | |||||
if (error) | |||||
break; | |||||
/* get the second operand */ | |||||
error = memread(vm, vcpuid, gpa, &val2, size, arg); | |||||
if (error) | |||||
break; | |||||
/* perform the operation and write the result */ | |||||
result = val1 | val2; | |||||
error = vie_update_register(vm, vcpuid, reg, result, size); | |||||
break; | |||||
case 0x81: | case 0x81: | ||||
case 0x83: | case 0x83: | ||||
/* | /* | ||||
* OR mem (ModRM:r/m) with immediate and store the | * OR mem (ModRM:r/m) with immediate and store the | ||||
* result in mem. | * result in mem. | ||||
* | * | ||||
* 81 /1 or r/m16, imm16 | * 81 /1 or r/m16, imm16 | ||||
* 81 /1 or r/m32, imm32 | * 81 /1 or r/m32, imm32 | ||||
▲ Show 20 Lines • Show All 1,438 Lines • Show Last 20 Lines |