From owner-svn-src-projects@FreeBSD.ORG Thu Nov 29 06:26:43 2012 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 6BE65FA1; Thu, 29 Nov 2012 06:26:43 +0000 (UTC) (envelope-from grehan@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4EDBA8FC0C; Thu, 29 Nov 2012 06:26:43 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAT6QhJQ007960; Thu, 29 Nov 2012 06:26:43 GMT (envelope-from grehan@svn.freebsd.org) Received: (from grehan@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAT6QhOr007958; Thu, 29 Nov 2012 06:26:43 GMT (envelope-from grehan@svn.freebsd.org) Message-Id: <201211290626.qAT6QhOr007958@svn.freebsd.org> From: Peter Grehan Date: Thu, 29 Nov 2012 06:26:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r243667 - in projects/bhyve/sys/amd64/vmm: . intel X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Nov 2012 06:26:43 -0000 Author: grehan Date: Thu Nov 29 06:26:42 2012 New Revision: 243667 URL: http://svnweb.freebsd.org/changeset/base/243667 Log: Add support for the 0x81 AND instruction, now generated by clang in the local APIC code. 0x81 is a read-modify-write instruction - the EPT check that only allowed read or write and not both has been relaxed to allow read and write. Reviewed by: neel Obtained from: NetApp Modified: projects/bhyve/sys/amd64/vmm/intel/vmx.c projects/bhyve/sys/amd64/vmm/vmm_instruction_emul.c Modified: projects/bhyve/sys/amd64/vmm/intel/vmx.c ============================================================================== --- projects/bhyve/sys/amd64/vmm/intel/vmx.c Thu Nov 29 05:46:46 2012 (r243666) +++ projects/bhyve/sys/amd64/vmm/intel/vmx.c Thu Nov 29 06:26:42 2012 (r243667) @@ -1159,15 +1159,16 @@ vmx_ept_fault(struct vm *vm, int cpu, if (ept_qual & EPT_VIOLATION_INST_FETCH) return (UNHANDLED); - /* EPT violation must be a read fault or a write fault but not both */ + /* EPT violation must be a read fault or a write fault */ read = ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0; write = ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0; - if ((read ^ write) == 0) + if ((read | write) == 0) return (UNHANDLED); /* - * The EPT violation must have been caused by accessing a guest-physical - * address that is a translation of a guest-linear address. + * The EPT violation must have been caused by accessing a + * guest-physical address that is a translation of a guest-linear + * address. */ if ((ept_qual & EPT_VIOLATION_GLA_VALID) == 0 || (ept_qual & EPT_VIOLATION_XLAT_VALID) == 0) { Modified: projects/bhyve/sys/amd64/vmm/vmm_instruction_emul.c ============================================================================== --- projects/bhyve/sys/amd64/vmm/vmm_instruction_emul.c Thu Nov 29 05:46:46 2012 (r243666) +++ projects/bhyve/sys/amd64/vmm/vmm_instruction_emul.c Thu Nov 29 06:26:42 2012 (r243667) @@ -81,6 +81,11 @@ static const struct vie_op one_byte_opco [0x23] = { .op_byte = 0x23, .op_type = VIE_OP_TYPE_AND, + }, + [0x81] = { + .op_byte = 0x81, + .op_type = VIE_OP_TYPE_AND, + .op_flags = VIE_OP_F_IMM, } }; @@ -299,6 +304,30 @@ emulate_and(void *vm, int vcpuid, uint64 val1 &= val2; error = vie_update_register(vm, vcpuid, reg, val1, size); break; + case 0x81: + printf("0x81 AND\n"); + /* + * AND reg (ModRM:reg) with immediate and store the + * result in reg + * + * 81/ and r/m32, imm32 + * REX.W + 81/ and r/m64, imm32 sign-extended to 64 + */ + 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; }