From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mihai =?UTF-8?B?RG9uyJt1?= Subject: Re: [PATCH 4/5] x86/emulate: add support for {, v}movq xmm, xmm/m64 Date: Thu, 8 Sep 2016 16:56:27 +0300 Message-ID: <20160908165627.6b483536@bitdefender.com> References: <57D18589020000780010D251@prv-mh.provo.novell.com> <57D1878F020000780010D270@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4764513644849418973==" Return-path: Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhzod-0006TW-Ef for xen-devel@lists.xenproject.org; Thu, 08 Sep 2016 13:56:31 +0000 Received: from smtp01.buh.bitdefender.com (smtp.bitdefender.biz [10.17.80.75]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 0DE7E7FC2C for ; Thu, 8 Sep 2016 16:56:28 +0300 (EEST) In-Reply-To: <57D1878F020000780010D270@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: Jan Beulich Cc: xen-devel@lists.xenproject.org, Andrew Cooper List-Id: xen-devel@lists.xenproject.org --===============4764513644849418973== Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/6H=ucrAl.5+Dv9Z39_URU7X"; protocol="application/pgp-signature" --Sig_/6H=ucrAl.5+Dv9Z39_URU7X Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thursday 08 September 2016 07:45:19 Jan Beulich wrote: > From: Mihai Don=C8=9Bu >=20 > Signed-off-by: Mihai Don=C8=9Bu > Signed-off-by: Jan Beulich > --- > v4: Re-base on decoding changes. Address my own review comments (where > still applicable). #UD when vex.l is set. Various adjustments to > the test tool change. Thank you! They were in my queue for too long and I was struggling to find a window of time to get them in shape. > --- a/tools/tests/x86_emulator/test_x86_emulator.c > +++ b/tools/tests/x86_emulator/test_x86_emulator.c > @@ -713,6 +713,54 @@ int main(int argc, char **argv) > else > printf("skipped\n"); > =20 > + printf("%-40s", "Testing movq %%xmm0,32(%%ecx)..."); > + if ( stack_exec && cpu_has_sse2 ) > + { > + decl_insn(movq_to_mem2); > + > + asm volatile ( "pcmpgtb %%xmm0, %%xmm0\n" > + put_insn(movq_to_mem2, "movq %%xmm0, 32(%0)") > + :: "c" (NULL) ); > + > + memset(res, 0xbd, 64); > + set_insn(movq_to_mem2); > + regs.ecx =3D (unsigned long)res; > + regs.edx =3D 0; > + rc =3D x86_emulate(&ctxt, &emulops); > + if ( rc !=3D X86EMUL_OKAY || !check_eip(movq_to_mem2) || > + *((uint64_t *)res + 4) || > + memcmp(res, res + 10, 24) || > + memcmp(res, res + 6, 8) ) > + goto fail; > + printf("okay\n"); > + } > + else > + printf("skipped\n"); > + > + printf("%-40s", "Testing vmovq %%xmm1,32(%%edx)..."); > + 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(%0)") > + :: "d" (NULL) ); > + > + memset(res, 0xdb, 64); > + set_insn(vmovq_to_mem); > + regs.ecx =3D 0; > + regs.edx =3D (unsigned long)res; > + rc =3D x86_emulate(&ctxt, &emulops); > + if ( rc !=3D X86EMUL_OKAY || !check_eip(vmovq_to_mem) || > + *((uint64_t *)res + 4) || > + memcmp(res, res + 10, 24) || > + memcmp(res, res + 6, 8) ) > + goto fail; > + printf("okay\n"); > + } > + else > + printf("skipped\n"); > + > printf("%-40s", "Testing movdqu %xmm2,(%ecx)..."); > if ( stack_exec && cpu_has_sse2 ) > { > --- a/xen/arch/x86/x86_emulate/x86_emulate.c > +++ b/xen/arch/x86/x86_emulate/x86_emulate.c > @@ -269,7 +269,7 @@ static const opcode_desc_t twobyte_table > ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, > ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, > /* 0xD0 - 0xDF */ > - ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, > + ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, ImplicitOps|ModRM, ModRM, > ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, > /* 0xE0 - 0xEF */ > ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, ModRM, ImplicitOps|ModRM, > @@ -4779,6 +4779,8 @@ x86_emulate( > case X86EMUL_OPC_F3(0x0f, 0x7f): /* movdqu xmm,xmm/m128 */ > case X86EMUL_OPC_VEX_F3(0x0f, 0x7f): /* vmovdqu xmm,xmm/m128 */ > /* vmovdqu ymm,ymm/m256 */ > + case X86EMUL_OPC_66(0x0f, 0xd6): /* movq xmm,xmm/m64 */ > + case X86EMUL_OPC_VEX_66(0x0f, 0xd6): /* vmovq xmm,xmm/m64 */ > { > uint8_t *buf =3D get_stub(stub); > struct fpu_insn_ctxt fic =3D { .insn_bytes =3D 5 }; > @@ -4796,7 +4798,8 @@ x86_emulate( > case vex_66: > case vex_f3: > host_and_vcpu_must_have(sse2); > - buf[0] =3D 0x66; /* movdqa */ > + /* Converting movdqu to movdqa here: Our buffer is align= ed. */ > + buf[0] =3D 0x66; > get_fpu(X86EMUL_FPU_xmm, &fic); > ea.bytes =3D 16; > break; > @@ -4819,6 +4822,11 @@ x86_emulate( > get_fpu(X86EMUL_FPU_ymm, &fic); > ea.bytes =3D 16 << vex.l; > } > + if ( b =3D=3D 0xd6 ) > + { > + generate_exception_if(vex.l, EXC_UD, -1); > + ea.bytes =3D 8; > + } > if ( ea.type =3D=3D OP_MEM ) > { > generate_exception_if((vex.pfx =3D=3D vex_66) && >=20 --=20 Mihai DON=C8=9AU --Sig_/6H=ucrAl.5+Dv9Z39_URU7X Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iEYEARECAAYFAlfRbgsACgkQfOUeqrYRMKpzHwCeN7/jpAliM9RIJ8zZ8YQWdZE+ LKsAn17aB0acZiwHNutztBbGAYp37cbs =707d -----END PGP SIGNATURE----- --Sig_/6H=ucrAl.5+Dv9Z39_URU7X-- --===============4764513644849418973== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwczovL2xpc3RzLnhlbi5v cmcveGVuLWRldmVsCg== --===============4764513644849418973==--