aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64
diff options
context:
space:
mode:
authorPeter Grehan <grehan@FreeBSD.org>2017-11-01 03:26:53 +0000
committerPeter Grehan <grehan@FreeBSD.org>2017-11-01 03:26:53 +0000
commit9d210a4a18ecf578d310d1242ba643992f8b0f7d (patch)
tree7b0718ec1b0688496a03d7f0def7b0cde37b48b5 /sys/amd64
parent7561a31ed9cdbf194f86bfc6478a4a1a21efbaa8 (diff)
downloadsrc-9d210a4a18ecf578d310d1242ba643992f8b0f7d.tar.gz
src-9d210a4a18ecf578d310d1242ba643992f8b0f7d.zip
Emulate the "OR reg, r/m" instruction (opcode 0BH).
This is needed for the HDA emulation with FreeBSD guests. Reviewed by: marcelo MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D12832
Notes
Notes: svn path=/head/; revision=325261
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/vmm/vmm_instruction_emul.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/sys/amd64/vmm/vmm_instruction_emul.c b/sys/amd64/vmm/vmm_instruction_emul.c
index 852f1d7393bf..64a0b35d3b44 100644
--- a/sys/amd64/vmm/vmm_instruction_emul.c
+++ b/sys/amd64/vmm/vmm_instruction_emul.c
@@ -109,6 +109,10 @@ static const struct vie_op one_byte_opcodes[256] = {
.op_byte = 0x0F,
.op_type = VIE_OP_TYPE_TWO_BYTE
},
+ [0x0B] = {
+ .op_byte = 0x0B,
+ .op_type = VIE_OP_TYPE_OR,
+ },
[0x2B] = {
.op_byte = 0x2B,
.op_type = VIE_OP_TYPE_SUB,
@@ -992,12 +996,38 @@ emulate_or(void *vm, int vcpuid, uint64_t gpa, struct vie *vie,
mem_region_read_t memread, mem_region_write_t memwrite, void *arg)
{
int error, size;
- uint64_t val1, result, rflags, rflags2;
+ enum vm_reg_name reg;
+ uint64_t result, rflags, rflags2, val1, val2;
size = vie->opsize;
error = EINVAL;
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 0x83:
/*