Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Apr 2018 20:20:08 +0000 (UTC)
From:      Peter Grehan <grehan@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r332516 - stable/11/sys/amd64/vmm
Message-ID:  <201804152020.w3FKK8ea090602@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: grehan
Date: Sun Apr 15 20:20:08 2018
New Revision: 332516
URL: https://svnweb.freebsd.org/changeset/base/332516

Log:
  MFC r325261
    Emulate the "OR reg, r/m" instruction (opcode 0BH).
  
    This is needed for the HDA emulation with FreeBSD guests.

Modified:
  stable/11/sys/amd64/vmm/vmm_instruction_emul.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/amd64/vmm/vmm_instruction_emul.c
==============================================================================
--- stable/11/sys/amd64/vmm/vmm_instruction_emul.c	Sun Apr 15 19:23:37 2018	(r332515)
+++ stable/11/sys/amd64/vmm/vmm_instruction_emul.c	Sun Apr 15 20:20:08 2018	(r332516)
@@ -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 
 	    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:
 		/*



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201804152020.w3FKK8ea090602>