From owner-svn-soc-all@FreeBSD.ORG Sun Jul 28 09:07:09 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4994BD7D for ; Sun, 28 Jul 2013 09:07:09 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1CC66261A for ; Sun, 28 Jul 2013 09:07:09 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r6S978CM051149 for ; Sun, 28 Jul 2013 09:07:08 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r6S97846051132 for svn-soc-all@FreeBSD.org; Sun, 28 Jul 2013 09:07:08 GMT (envelope-from zcore@FreeBSD.org) Date: Sun, 28 Jul 2013 09:07:08 GMT Message-Id: <201307280907.r6S97846051132@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r255257 - soc2013/zcore/head/sys/amd64/vmm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Jul 2013 09:07:09 -0000 Author: zcore Date: Sun Jul 28 09:07:08 2013 New Revision: 255257 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=255257 Log: add "or" emulation For example, orl $2, (%rdx) Modified: soc2013/zcore/head/sys/amd64/vmm/vmm_instruction_emul.c Modified: soc2013/zcore/head/sys/amd64/vmm/vmm_instruction_emul.c ============================================================================== --- soc2013/zcore/head/sys/amd64/vmm/vmm_instruction_emul.c Sun Jul 28 07:58:34 2013 (r255256) +++ soc2013/zcore/head/sys/amd64/vmm/vmm_instruction_emul.c Sun Jul 28 09:07:08 2013 (r255257) @@ -60,6 +60,7 @@ VIE_OP_TYPE_NONE = 0, VIE_OP_TYPE_MOV, VIE_OP_TYPE_AND, + VIE_OP_TYPE_OR, VIE_OP_TYPE_LAST }; @@ -94,7 +95,12 @@ .op_byte = 0x81, .op_type = VIE_OP_TYPE_AND, .op_flags = VIE_OP_F_IMM, - } + }, + [0x83] = { + .op_byte = 0x83, + .op_type = VIE_OP_TYPE_OR, + .op_flags = VIE_OP_F_IMM8, + }, }; /* struct vie.mod */ @@ -371,6 +377,52 @@ return (error); } +static int +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; + + size = 4; + error = EINVAL; + + switch (vie->op.op_byte) { + case 0x83: + /* + * OR reg (ModRM:reg) with immediate and store the + * result in reg + * + * 83/ OR r/m32, imm32 + * REX.W + 83/ OR r/m64, imm32 sign-extended to 64 + * + * Currently, only the OR operation of the 0x83 opcode + * is implemented (ModRM:reg = b100). + */ + if ((vie->reg & 7) != 4) + break; + + if (vie->rex_w) + size = 8; + + /* get the first operand */ + error = memread(vm, vcpuid, gpa, &val1, size, arg); + if (error) + break; + + /* + * perform the operation with the pre-fetched immediate + * operand and write the result + */ + val1 |= vie->immediate; + error = memwrite(vm, vcpuid, gpa, val1, size, arg); + break; + default: + break; + } + return (error); +} + int vmm_emulate_instruction(void *vm, int vcpuid, uint64_t gpa, struct vie *vie, mem_region_read_t memread, mem_region_write_t memwrite, @@ -390,6 +442,10 @@ error = emulate_and(vm, vcpuid, gpa, vie, memread, memwrite, memarg); break; + case VIE_OP_TYPE_OR: + error = emulate_or(vm, vcpuid, gpa, vie, + memread, memwrite, memarg); + break; default: error = EINVAL; break;