From patchwork Mon Jul 18 14:30:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mihai_Don=C8=9Bu?= X-Patchwork-Id: 9234741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B9D760756 for ; Mon, 18 Jul 2016 14:45:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1DCA26C2F for ; Mon, 18 Jul 2016 14:45:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6A9826CF9; Mon, 18 Jul 2016 14:45:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 64CD726C2F for ; Mon, 18 Jul 2016 14:45:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bP9lF-0003CS-ER; Mon, 18 Jul 2016 14:43:09 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bP9lE-0003C9-5R for xen-devel@lists.xen.org; Mon, 18 Jul 2016 14:43:08 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id 67/38-31810-708EC875; Mon, 18 Jul 2016 14:30:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKIsWRWlGSWpSXmKPExsUSfTxjoS7bi55 wg/VvlSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1owX614yFmySr9hyfAJrA2OrWBcjJ4eQgIfE y6sdrF2MXED2WkaJ8/M/MkEkTjJKXJ4jDWG7SzzbsRkqvpNRYsXjgC5GDg42AVuJ/js+IGERA WmJa58vM4LYzAL+EssO9YKVCwt4Ssz7cpgdpJxFQFVi7R9xkDCvgLXEvHdvWEBsCQE5iZevfz JDxAUlTs58wgJSziygLrF+nhDERHmJ5q2zmSHKcyT+PJ3MBFIiISAl8b9VCeR4CYEJLBK/e3q hamQkHk28yTaBUXgWkqmzEKbOQjJ1ASPzKkb14tSistQiXUu9pKLM9IyS3MTMHF1DA2O93NTi 4sT01JzEpGK95PzcTYzA4K5nYGDcwfj6p9MhRkkOJiVRXqsFPeFCfEn5KZUZicUZ8UWlOanFh xhlODiUJHilnwPlBItS01Mr0jJzgHEGk5bg4FES4Q15BpTmLS5IzC3OTIdInWJUlBLnvQuSEA BJZJTmwbXBYvsSo6yUMC8jAwODEE9BalFuZgmq/CtGcQ5GJWFeX5DtPJl5JXDTXwEtZgJabKD aDbK4JBEhJdXAmLVoddvzWqkKpd6s3X+Mfh35WMlX5Dn3it5s6/fHk7IbCo7GiLInyRkHWgZ7 dqfEfvN1tF5oqMHcNOdveD9vfuu0+DUMKVxPd09Rrj246r2xe6uG2n2ZgPQ7Mw3ME++a19z6n dz+uTPz/Xfr/kLhjeWvXJxWrs86ndG85WOrY2Px/d2t6yYrsRRnJBpqMRcVJwIAyqOSsegCAA A= X-Env-Sender: mdontu@bitdefender.com X-Msg-Ref: server-5.tower-31.messagelabs.com!1468852228!48018287!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.77; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47249 invoked from network); 18 Jul 2016 14:30:30 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-5.tower-31.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 18 Jul 2016 14:30:30 -0000 Received: (qmail 13957 invoked from network); 18 Jul 2016 17:30:28 +0300 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.bbu.dsd.mx.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 18 Jul 2016 17:30:28 +0300 Received: from smtp02.buh.bitdefender.net (unknown [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 4BBD17FC2A for ; Mon, 18 Jul 2016 17:30:28 +0300 (EEST) Received: (qmail 5033 invoked from network); 18 Jul 2016 17:30:28 +0300 Received: from unknown (HELO mdontu-l.bitdefender.biz) (mdontu@bitdefender.com@10.20.65.10) by smtp02.buh.bitdefender.net with AES128-SHA256 encrypted SMTP; 18 Jul 2016 17:30:27 +0300 From: =?UTF-8?q?Mihai=20Don=C8=9Bu?= To: xen-devel@lists.xen.org Date: Mon, 18 Jul 2016 17:30:18 +0300 Message-Id: <20160718143020.14828-1-mdontu@bitdefender.com> X-Mailer: git-send-email 2.9.2 MIME-Version: 1.0 X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp02.buh.bitdefender.net, sigver: 7.66383 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 427057, Stamp: 3], Multi: [Enabled, t: (0.000009, 0.003909)], BW: [Enabled, t: (0.000008,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.003322), Flags: 85D2ED72; NN_LEGIT_SUMM_400_WORDS; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.012543)], URL: [Enabled, t: (0.000006)], RTDA: [Enabled, t: (0.018194), Hit: No, Details: v2.3.10; Id: 2m1ghhh.1anqe7pio.6asa], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Andrew Cooper , Jan Beulich Subject: [Xen-devel] [PATCH v2 1/3] x86/emulate: add support for {, v}movq xmm, xmm/m64 X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Mihai Donțu --- Changed since v1: * added a test for vmovq * made the tests depend on SSE and AVX, respectively * added emulator support for vmovq (0xd6 forces the operand size to 64bit) --- tools/tests/x86_emulator/test_x86_emulator.c | 44 ++++++++++++++++++++++++++++ xen/arch/x86/x86_emulate/x86_emulate.c | 9 +++--- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/tools/tests/x86_emulator/test_x86_emulator.c b/tools/tests/x86_emulator/test_x86_emulator.c index c7f572a..8994149 100644 --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -697,6 +697,50 @@ int main(int argc, char **argv) else printf("skipped\n"); + printf("%-40s", "Testing movq %%xmm0,32(%%eax)..."); + if ( stack_exec && cpu_has_sse ) + { + decl_insn(movq_to_mem2); + + asm volatile ( "pcmpgtb %%xmm0, %%xmm0\n" + put_insn(movq_to_mem2, "movq %%xmm0, 32(%%eax)") + :: ); + + *((unsigned long *)res + 4) = 0xbdbdbdbdbdbdbdbd; + set_insn(movq_to_mem2); + regs.eax = (unsigned long)res; + rc = x86_emulate(&ctxt, &emulops); + if ( rc != X86EMUL_OKAY || !check_eip(movq_to_mem2) ) + goto fail; + if ( *((unsigned long *)res + 4) ) + goto fail; + printf("okay\n"); + } + else + printf("skipped\n"); + + printf("%-40s", "Testing vmovq %%xmm1,32(%%eax)..."); + if ( stack_exec && cpu_has_avx ) + { + decl_insn(vmovq_to_mem); + + asm volatile ( "pcmpgtb %%xmm1, %%xmm1\n" + put_insn(vmovq_to_mem, "vmovq %%xmm1, 32(%%eax)") + :: ); + + *((unsigned long *)res + 4) = 0xbdbdbdbdbdbdbdbd; + set_insn(vmovq_to_mem); + regs.eax = (unsigned long)res; + rc = x86_emulate(&ctxt, &emulops); + if ( rc != X86EMUL_OKAY || !check_eip(vmovq_to_mem) ) + goto fail; + if ( *((unsigned long *)res + 4) ) + goto fail; + printf("okay\n"); + } + else + printf("skipped\n"); + printf("%-40s", "Testing movdqu %xmm2,(%ecx)..."); if ( stack_exec && cpu_has_sse2 ) { diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c index fe594ba..0301235 100644 --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -245,7 +245,7 @@ static uint8_t twobyte_table[256] = { ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, /* 0xD0 - 0xDF */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, ImplicitOps|ModRM, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xE0 - 0xEF */ 0, 0, 0, 0, 0, 0, 0, ImplicitOps|ModRM, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xF0 - 0xFF */ @@ -4412,6 +4412,7 @@ x86_emulate( case 0x7f: /* movq mm,mm/m64 */ /* {,v}movdq{a,u} xmm,xmm/m128 */ /* vmovdq{a,u} ymm,ymm/m256 */ + case 0xd6: /* {,v}movq xmm,xmm/m64 */ { uint8_t *buf = get_stub(stub); struct fpu_insn_ctxt fic = { .insn_bytes = 5 }; @@ -4429,9 +4430,9 @@ x86_emulate( case vex_66: case vex_f3: host_and_vcpu_must_have(sse2); - buf[0] = 0x66; /* movdqa */ + buf[0] = 0x66; /* SSE */ get_fpu(X86EMUL_FPU_xmm, &fic); - ea.bytes = 16; + ea.bytes = (b == 0xd6 ? 8 : 16); break; case vex_none: if ( b != 0xe7 ) @@ -4451,7 +4452,7 @@ x86_emulate( ((vex.pfx != vex_66) && (vex.pfx != vex_f3))); host_and_vcpu_must_have(avx); get_fpu(X86EMUL_FPU_ymm, &fic); - ea.bytes = 16 << vex.l; + ea.bytes = (b == 0xd6 ? 8 : 16 << vex.l); } if ( ea.type == OP_MEM ) {