From: "Jan Beulich" Subject: [PATCH] test_x86_emulator: add missing EIP checks Date: Thu, 07 Aug 2014 16:46:06 +0100 Message-ID: <53E3BB5E020000780002A313@mail.emea.novell.com> References: <1407411514-19749-1-git-send-email-rcojocaru@bitdefender.com> <53E38424020000780002A1F7@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part695BD42E.3__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XFPtK-0006z7-FT for xen-devel@lists.xenproject.org; Thu, 07 Aug 2014 15:46:10 +0000 In-Reply-To: <53E38424020000780002A1F7@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser , ian.campbell@citrix.com, Razvan Cojocaru , stefano.stabellini@eu.citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part695BD42E.3__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The MMX, SSE, and AVX instruction tests didn't validate that EIP got properly updated by the emulator (which indeed it failed to do). At once macroize the resepctive code quite a bit, hopefully making it easier to add further tests when the need arises. Signed-off-by: Jan Beulich --- I guess I'll append this to the actual emulator fix. --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -599,23 +599,32 @@ int main(int argc, char **argv) printf("skipped\n"); #endif =20 +#define decl_insn(which) extern const unsigned char which[], which##_len[]= +#define put_insn(which, insn) ".pushsection .test, \"ax\", @progbits\n" \ + #which ": " insn "\n" \ + ".equ " #which "_len, .-" #which "\n" \ + ".popsection" +#define set_insn(which) (regs.eip =3D (unsigned long)memcpy(instr, which, = \ + (unsigned long)which##_len)) +#define check_eip(which) (regs.eip =3D=3D (unsigned long)instr + \ + (unsigned long)which##_len) + printf("%-40s", "Testing movq %mm3,(%ecx)..."); if ( stack_exec && cpu_has_mmx ) { - extern const unsigned char movq_to_mem[]; + decl_insn(movq_to_mem); =20 asm volatile ( "pcmpeqb %%mm3, %%mm3\n" - ".pushsection .test, \"a\", @progbits\n" - "movq_to_mem: movq %%mm3, (%0)\n" - ".popsection" :: "c" (NULL) ); + put_insn(movq_to_mem, "movq %%mm3, (%0)") + :: "c" (NULL) ); =20 - memcpy(instr, movq_to_mem, 15); + set_insn(movq_to_mem); memset(res, 0x33, 64); memset(res + 8, 0xff, 8); - regs.eip =3D (unsigned long)&instr[0]; regs.ecx =3D (unsigned long)res; rc =3D x86_emulate(&ctxt, &emulops); - if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) ) + if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) || + !check_eip(movq_to_mem) ) goto fail; printf("okay\n"); } @@ -625,19 +634,17 @@ int main(int argc, char **argv) printf("%-40s", "Testing movq (%edx),%mm5..."); if ( stack_exec && cpu_has_mmx ) { - extern const unsigned char movq_from_mem[]; + decl_insn(movq_from_mem); =20 asm volatile ( "pcmpgtb %%mm5, %%mm5\n" - ".pushsection .test, \"a\", @progbits\n" - "movq_from_mem: movq (%0), %%mm5\n" - ".popsection" :: "d" (NULL) ); + put_insn(movq_from_mem, "movq (%0), %%mm5") + :: "d" (NULL) ); =20 - memcpy(instr, movq_from_mem, 15); - regs.eip =3D (unsigned long)&instr[0]; + set_insn(movq_from_mem); regs.ecx =3D 0; regs.edx =3D (unsigned long)res; rc =3D x86_emulate(&ctxt, &emulops); - if ( rc !=3D X86EMUL_OKAY ) + if ( rc !=3D X86EMUL_OKAY || !check_eip(movq_from_mem) ) goto fail; asm ( "pcmpeqb %%mm3, %%mm3\n\t" "pcmpeqb %%mm5, %%mm3\n\t" @@ -652,20 +659,19 @@ int main(int argc, char **argv) printf("%-40s", "Testing movdqu %xmm2,(%ecx)..."); if ( stack_exec && cpu_has_sse2 ) { - extern const unsigned char movdqu_to_mem[]; + decl_insn(movdqu_to_mem); =20 asm volatile ( "pcmpeqb %%xmm2, %%xmm2\n" - ".pushsection .test, \"a\", @progbits\n" - "movdqu_to_mem: movdqu %%xmm2, (%0)\n" - ".popsection" :: "c" (NULL) ); + put_insn(movdqu_to_mem, "movdqu %%xmm2, (%0)") + :: "c" (NULL) ); =20 - memcpy(instr, movdqu_to_mem, 15); + set_insn(movdqu_to_mem); memset(res, 0x55, 64); memset(res + 8, 0xff, 16); - regs.eip =3D (unsigned long)&instr[0]; regs.ecx =3D (unsigned long)res; rc =3D x86_emulate(&ctxt, &emulops); - if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) ) + if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) || + !check_eip(movdqu_to_mem) ) goto fail; printf("okay\n"); } @@ -675,19 +681,17 @@ int main(int argc, char **argv) printf("%-40s", "Testing movdqu (%edx),%xmm4..."); if ( stack_exec && cpu_has_sse2 ) { - extern const unsigned char movdqu_from_mem[]; + decl_insn(movdqu_from_mem); =20 asm volatile ( "pcmpgtb %%xmm4, %%xmm4\n" - ".pushsection .test, \"a\", @progbits\n" - "movdqu_from_mem: movdqu (%0), %%xmm4\n" - ".popsection" :: "d" (NULL) ); + put_insn(movdqu_from_mem, "movdqu (%0), %%xmm4") + :: "d" (NULL) ); =20 - memcpy(instr, movdqu_from_mem, 15); - regs.eip =3D (unsigned long)&instr[0]; + set_insn(movdqu_from_mem); regs.ecx =3D 0; regs.edx =3D (unsigned long)res; rc =3D x86_emulate(&ctxt, &emulops); - if ( rc !=3D X86EMUL_OKAY ) + if ( rc !=3D X86EMUL_OKAY || !check_eip(movdqu_from_mem) ) goto fail; asm ( "pcmpeqb %%xmm2, %%xmm2\n\t" "pcmpeqb %%xmm4, %%xmm2\n\t" @@ -702,21 +706,20 @@ int main(int argc, char **argv) printf("%-40s", "Testing vmovdqu %ymm2,(%ecx)..."); if ( stack_exec && cpu_has_avx ) { - extern const unsigned char vmovdqu_to_mem[]; + decl_insn(vmovdqu_to_mem); =20 asm volatile ( "vpcmpeqb %%xmm2, %%xmm2, %%xmm2\n" - ".pushsection .test, \"a\", @progbits\n" - "vmovdqu_to_mem: vmovdqu %%ymm2, (%0)\n" - ".popsection" :: "c" (NULL) ); + put_insn(vmovdqu_to_mem, "vmovdqu %%ymm2, (%0)") + :: "c" (NULL) ); =20 - memcpy(instr, vmovdqu_to_mem, 15); + set_insn(vmovdqu_to_mem); memset(res, 0x55, 128); memset(res + 16, 0xff, 16); memset(res + 20, 0x00, 16); - regs.eip =3D (unsigned long)&instr[0]; regs.ecx =3D (unsigned long)res; rc =3D x86_emulate(&ctxt, &emulops); - if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 16, 64) ) + if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 16, 64) || + !check_eip(vmovdqu_to_mem) ) goto fail; printf("okay\n"); } @@ -726,7 +729,7 @@ int main(int argc, char **argv) printf("%-40s", "Testing vmovdqu (%edx),%ymm4..."); if ( stack_exec && cpu_has_avx ) { - extern const unsigned char vmovdqu_from_mem[]; + decl_insn(vmovdqu_from_mem); =20 #if 0 /* Don't use AVX2 instructions for now */ asm volatile ( "vpcmpgtb %%ymm4, %%ymm4, %%ymm4\n" @@ -734,17 +737,15 @@ int main(int argc, char **argv) asm volatile ( "vpcmpgtb %%xmm4, %%xmm4, %%xmm4\n\t" "vinsertf128 $1, %%xmm4, %%ymm4, %%ymm4\n" #endif - ".pushsection .test, \"a\", @progbits\n" - "vmovdqu_from_mem: vmovdqu (%0), %%ymm4\n" - ".popsection" :: "d" (NULL) ); + put_insn(vmovdqu_from_mem, "vmovdqu (%0), %%ymm4") + :: "d" (NULL) ); =20 - memcpy(instr, vmovdqu_from_mem, 15); + set_insn(vmovdqu_from_mem); memset(res + 4, 0xff, 16); - regs.eip =3D (unsigned long)&instr[0]; regs.ecx =3D 0; regs.edx =3D (unsigned long)res; rc =3D x86_emulate(&ctxt, &emulops); - if ( rc !=3D X86EMUL_OKAY ) + if ( rc !=3D X86EMUL_OKAY || !check_eip(vmovdqu_from_mem) ) goto fail; #if 0 /* Don't use AVX2 instructions for now */ asm ( "vpcmpeqb %%ymm2, %%ymm2, %%ymm2\n\t" @@ -771,20 +772,19 @@ int main(int argc, char **argv) memset(res + 10, 0x66, 8); if ( stack_exec && cpu_has_sse2 ) { - extern const unsigned char movsd_to_mem[]; + decl_insn(movsd_to_mem); =20 asm volatile ( "movlpd %0, %%xmm5\n\t" "movhpd %0, %%xmm5\n" - ".pushsection .test, \"a\", @progbits\n" - "movsd_to_mem: movsd %%xmm5, (%1)\n" - ".popsection" :: "m" (res[10]), "c" (NULL) ); + put_insn(movsd_to_mem, "movsd %%xmm5, (%1)") + :: "m" (res[10]), "c" (NULL) ); =20 - memcpy(instr, movsd_to_mem, 15); - regs.eip =3D (unsigned long)&instr[0]; + set_insn(movsd_to_mem); regs.ecx =3D (unsigned long)(res + 2); regs.edx =3D 0; rc =3D x86_emulate(&ctxt, &emulops); - if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) ) + if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) || + !check_eip(movsd_to_mem) ) goto fail; printf("okay\n"); } @@ -797,19 +797,17 @@ int main(int argc, char **argv) printf("%-40s", "Testing movaps (%edx),%xmm7..."); if ( stack_exec && cpu_has_sse ) { - extern const unsigned char movaps_from_mem[]; + decl_insn(movaps_from_mem); =20 asm volatile ( "xorps %%xmm7, %%xmm7\n" - ".pushsection .test, \"a\", @progbits\n" - "movaps_from_mem: movaps (%0), %%xmm7\n" - ".popsection" :: "d" (NULL) ); + put_insn(movaps_from_mem, "movaps (%0), %%xmm7") + :: "d" (NULL) ); =20 - memcpy(instr, movaps_from_mem, 15); - regs.eip =3D (unsigned long)&instr[0]; + set_insn(movaps_from_mem); regs.ecx =3D 0; regs.edx =3D (unsigned long)res; rc =3D x86_emulate(&ctxt, &emulops); - if ( rc !=3D X86EMUL_OKAY ) + if ( rc !=3D X86EMUL_OKAY || !check_eip(movaps_from_mem) ) goto fail; asm ( "cmpeqps %1, %%xmm7\n\t" "movmskps %%xmm7, %0" : "=3Dr" (rc) : "m" (res[8]) ); @@ -825,19 +823,18 @@ int main(int argc, char **argv) memset(res + 10, 0x77, 8); if ( stack_exec && cpu_has_avx ) { - extern const unsigned char vmovsd_to_mem[]; + decl_insn(vmovsd_to_mem); =20 asm volatile ( "vbroadcastsd %0, %%ymm5\n" - ".pushsection .test, \"a\", @progbits\n" - "vmovsd_to_mem: vmovsd %%xmm5, (%1)\n" - ".popsection" :: "m" (res[10]), "c" (NULL) ); + put_insn(vmovsd_to_mem, "vmovsd %%xmm5, (%1)") + :: "m" (res[10]), "c" (NULL) ); =20 - memcpy(instr, vmovsd_to_mem, 15); - regs.eip =3D (unsigned long)&instr[0]; + set_insn(vmovsd_to_mem); regs.ecx =3D (unsigned long)(res + 2); regs.edx =3D 0; rc =3D x86_emulate(&ctxt, &emulops); - if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) ) + if ( (rc !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) || + !check_eip(vmovsd_to_mem) ) goto fail; printf("okay\n"); } @@ -850,19 +847,17 @@ int main(int argc, char **argv) printf("%-40s", "Testing vmovaps (%edx),%ymm7..."); if ( stack_exec && cpu_has_avx ) { - extern const unsigned char vmovaps_from_mem[]; + decl_insn(vmovaps_from_mem); =20 asm volatile ( "vxorps %%ymm7, %%ymm7, %%ymm7\n" - ".pushsection .test, \"a\", @progbits\n" - "vmovaps_from_mem: vmovaps (%0), %%ymm7\n" - ".popsection" :: "d" (NULL) ); + put_insn(vmovaps_from_mem, "vmovaps (%0), %%ymm7") + :: "d" (NULL) ); =20 - memcpy(instr, vmovaps_from_mem, 15); - regs.eip =3D (unsigned long)&instr[0]; + set_insn(vmovaps_from_mem); regs.ecx =3D 0; regs.edx =3D (unsigned long)res; rc =3D x86_emulate(&ctxt, &emulops); - if ( rc !=3D X86EMUL_OKAY ) + if ( rc !=3D X86EMUL_OKAY || !check_eip(vmovaps_from_mem) ) goto fail; asm ( "vcmpeqps %1, %%ymm7, %%ymm0\n\t" "vmovmskps %%ymm0, %0" : "=3Dr" (rc) : "m" (res[8]) ); @@ -873,6 +868,11 @@ int main(int argc, char **argv) else printf("skipped\n"); =20 +#undef decl_insn +#undef put_insn +#undef set_insn +#undef check_eip + for ( j =3D 1; j <=3D 2; j++ ) { #if defined(__i386__) --=__Part695BD42E.3__= Content-Type: text/plain; name="x86emul-test-IP-updates.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86emul-test-IP-updates.patch" test_x86_emulator: add missing EIP checks=0A=0AThe MMX, SSE, and AVX = instruction tests didn't validate that EIP got=0Aproperly updated by the = emulator (which indeed it failed to do).=0A=0AAt once macroize the = resepctive code quite a bit, hopefully making it=0Aeasier to add further = tests when the need arises.=0A=0ASigned-off-by: Jan Beulich =0A---=0AI guess I'll append this to the actual emulator fix.=0A=0A--- = a/tools/tests/x86_emulator/test_x86_emulator.c=0A+++ b/tools/tests/x86_emul= ator/test_x86_emulator.c=0A@@ -599,23 +599,32 @@ int main(int argc, char = **argv)=0A printf("skipped\n");=0A #endif=0A =0A+#define decl_insn(whic= h) extern const unsigned char which[], which##_len[]=0A+#define put_insn(wh= ich, insn) ".pushsection .test, \"ax\", @progbits\n" \=0A+ = #which ": " insn "\n" \=0A+ = ".equ " #which "_len, .-" #which "\n" \=0A+ = ".popsection"=0A+#define set_insn(which) (regs.eip =3D = (unsigned long)memcpy(instr, which, \=0A+ = (unsigned long)which##_len))=0A+#define check_eip(which) = (regs.eip =3D=3D (unsigned long)instr + \=0A+ = (unsigned long)which##_len)=0A+=0A printf("%-40s", "Testing = movq %mm3,(%ecx)...");=0A if ( stack_exec && cpu_has_mmx )=0A = {=0A- extern const unsigned char movq_to_mem[];=0A+ = decl_insn(movq_to_mem);=0A =0A asm volatile ( "pcmpeqb %%mm3, = %%mm3\n"=0A- ".pushsection .test, \"a\", @progbits\n"= =0A- "movq_to_mem: movq %%mm3, (%0)\n"=0A- = ".popsection" :: "c" (NULL) );=0A+ = put_insn(movq_to_mem, "movq %%mm3, (%0)")=0A+ :: "c" = (NULL) );=0A =0A- memcpy(instr, movq_to_mem, 15);=0A+ = set_insn(movq_to_mem);=0A memset(res, 0x33, 64);=0A = memset(res + 8, 0xff, 8);=0A- regs.eip =3D (unsigned long)&instr[= 0];=0A regs.ecx =3D (unsigned long)res;=0A rc =3D = x86_emulate(&ctxt, &emulops);=0A- if ( (rc !=3D X86EMUL_OKAY) || = memcmp(res, res + 8, 32) )=0A+ if ( (rc !=3D X86EMUL_OKAY) || = memcmp(res, res + 8, 32) ||=0A+ !check_eip(movq_to_mem) )=0A = goto fail;=0A printf("okay\n");=0A }=0A@@ -625,19 = +634,17 @@ int main(int argc, char **argv)=0A printf("%-40s", "Testing = movq (%edx),%mm5...");=0A if ( stack_exec && cpu_has_mmx )=0A = {=0A- extern const unsigned char movq_from_mem[];=0A+ = decl_insn(movq_from_mem);=0A =0A asm volatile ( "pcmpgtb %%mm5, = %%mm5\n"=0A- ".pushsection .test, \"a\", @progbits\n"= =0A- "movq_from_mem: movq (%0), %%mm5\n"=0A- = ".popsection" :: "d" (NULL) );=0A+ = put_insn(movq_from_mem, "movq (%0), %%mm5")=0A+ :: = "d" (NULL) );=0A =0A- memcpy(instr, movq_from_mem, 15);=0A- = regs.eip =3D (unsigned long)&instr[0];=0A+ set_insn(movq_from_mem= );=0A regs.ecx =3D 0;=0A regs.edx =3D (unsigned = long)res;=0A rc =3D x86_emulate(&ctxt, &emulops);=0A- if ( = rc !=3D X86EMUL_OKAY )=0A+ if ( rc !=3D X86EMUL_OKAY || !check_eip(m= ovq_from_mem) )=0A goto fail;=0A asm ( "pcmpeqb %%mm3, = %%mm3\n\t"=0A "pcmpeqb %%mm5, %%mm3\n\t"=0A@@ -652,20 = +659,19 @@ int main(int argc, char **argv)=0A printf("%-40s", "Testing = movdqu %xmm2,(%ecx)...");=0A if ( stack_exec && cpu_has_sse2 )=0A = {=0A- extern const unsigned char movdqu_to_mem[];=0A+ = decl_insn(movdqu_to_mem);=0A =0A asm volatile ( "pcmpeqb %%xmm2, = %%xmm2\n"=0A- ".pushsection .test, \"a\", @progbits\n= "=0A- "movdqu_to_mem: movdqu %%xmm2, (%0)\n"=0A- = ".popsection" :: "c" (NULL) );=0A+ = put_insn(movdqu_to_mem, "movdqu %%xmm2, (%0)")=0A+ = :: "c" (NULL) );=0A =0A- memcpy(instr, movdqu_to_mem, 15);=0A+ = set_insn(movdqu_to_mem);=0A memset(res, 0x55, 64);=0A = memset(res + 8, 0xff, 16);=0A- regs.eip =3D (unsigned long)&instr= [0];=0A regs.ecx =3D (unsigned long)res;=0A rc =3D = x86_emulate(&ctxt, &emulops);=0A- if ( (rc !=3D X86EMUL_OKAY) || = memcmp(res, res + 8, 32) )=0A+ if ( (rc !=3D X86EMUL_OKAY) || = memcmp(res, res + 8, 32) ||=0A+ !check_eip(movdqu_to_mem) )=0A = goto fail;=0A printf("okay\n");=0A }=0A@@ -675,19 = +681,17 @@ int main(int argc, char **argv)=0A printf("%-40s", "Testing = movdqu (%edx),%xmm4...");=0A if ( stack_exec && cpu_has_sse2 )=0A = {=0A- extern const unsigned char movdqu_from_mem[];=0A+ = decl_insn(movdqu_from_mem);=0A =0A asm volatile ( "pcmpgtb %%xmm4, = %%xmm4\n"=0A- ".pushsection .test, \"a\", @progbits\n= "=0A- "movdqu_from_mem: movdqu (%0), %%xmm4\n"=0A- = ".popsection" :: "d" (NULL) );=0A+ = put_insn(movdqu_from_mem, "movdqu (%0), %%xmm4")=0A+ = :: "d" (NULL) );=0A =0A- memcpy(instr, movdqu_from_mem, 15);=0A- = regs.eip =3D (unsigned long)&instr[0];=0A+ set_insn(movdqu_= from_mem);=0A regs.ecx =3D 0;=0A regs.edx =3D = (unsigned long)res;=0A rc =3D x86_emulate(&ctxt, &emulops);=0A- = if ( rc !=3D X86EMUL_OKAY )=0A+ if ( rc !=3D X86EMUL_OKAY || = !check_eip(movdqu_from_mem) )=0A goto fail;=0A asm ( = "pcmpeqb %%xmm2, %%xmm2\n\t"=0A "pcmpeqb %%xmm4, %%xmm2\n\t"= =0A@@ -702,21 +706,20 @@ int main(int argc, char **argv)=0A printf("%-4= 0s", "Testing vmovdqu %ymm2,(%ecx)...");=0A if ( stack_exec && = cpu_has_avx )=0A {=0A- extern const unsigned char vmovdqu_to_mem= [];=0A+ decl_insn(vmovdqu_to_mem);=0A =0A asm volatile ( = "vpcmpeqb %%xmm2, %%xmm2, %%xmm2\n"=0A- ".pushsection= .test, \"a\", @progbits\n"=0A- "vmovdqu_to_mem: = vmovdqu %%ymm2, (%0)\n"=0A- ".popsection" :: "c" = (NULL) );=0A+ put_insn(vmovdqu_to_mem, "vmovdqu = %%ymm2, (%0)")=0A+ :: "c" (NULL) );=0A =0A- = memcpy(instr, vmovdqu_to_mem, 15);=0A+ set_insn(vmovdqu_to_mem);=0A = memset(res, 0x55, 128);=0A memset(res + 16, 0xff, 16);=0A = memset(res + 20, 0x00, 16);=0A- regs.eip =3D (unsigned = long)&instr[0];=0A regs.ecx =3D (unsigned long)res;=0A = rc =3D x86_emulate(&ctxt, &emulops);=0A- if ( (rc !=3D X86EMUL_OKAY)= || memcmp(res, res + 16, 64) )=0A+ if ( (rc !=3D X86EMUL_OKAY) || = memcmp(res, res + 16, 64) ||=0A+ !check_eip(vmovdqu_to_mem) = )=0A goto fail;=0A printf("okay\n");=0A }=0A@@ = -726,7 +729,7 @@ int main(int argc, char **argv)=0A printf("%-40s", = "Testing vmovdqu (%edx),%ymm4...");=0A if ( stack_exec && cpu_has_avx = )=0A {=0A- extern const unsigned char vmovdqu_from_mem[];=0A+ = decl_insn(vmovdqu_from_mem);=0A =0A #if 0 /* Don't use AVX2 instructio= ns for now */=0A asm volatile ( "vpcmpgtb %%ymm4, %%ymm4, = %%ymm4\n"=0A@@ -734,17 +737,15 @@ int main(int argc, char **argv)=0A = asm volatile ( "vpcmpgtb %%xmm4, %%xmm4, %%xmm4\n\t"=0A = "vinsertf128 $1, %%xmm4, %%ymm4, %%ymm4\n"=0A #endif=0A- = ".pushsection .test, \"a\", @progbits\n"=0A- = "vmovdqu_from_mem: vmovdqu (%0), %%ymm4\n"=0A- = ".popsection" :: "d" (NULL) );=0A+ put_insn(vmovdqu_f= rom_mem, "vmovdqu (%0), %%ymm4")=0A+ :: "d" (NULL) = );=0A =0A- memcpy(instr, vmovdqu_from_mem, 15);=0A+ = set_insn(vmovdqu_from_mem);=0A memset(res + 4, 0xff, 16);=0A- = regs.eip =3D (unsigned long)&instr[0];=0A regs.ecx =3D = 0;=0A regs.edx =3D (unsigned long)res;=0A rc =3D = x86_emulate(&ctxt, &emulops);=0A- if ( rc !=3D X86EMUL_OKAY )=0A+ = if ( rc !=3D X86EMUL_OKAY || !check_eip(vmovdqu_from_mem) )=0A = goto fail;=0A #if 0 /* Don't use AVX2 instructions for now */=0A = asm ( "vpcmpeqb %%ymm2, %%ymm2, %%ymm2\n\t"=0A@@ -771,20 +772,19 @@ int = main(int argc, char **argv)=0A memset(res + 10, 0x66, 8);=0A if ( = stack_exec && cpu_has_sse2 )=0A {=0A- extern const unsigned = char movsd_to_mem[];=0A+ decl_insn(movsd_to_mem);=0A =0A = asm volatile ( "movlpd %0, %%xmm5\n\t"=0A "movhpd = %0, %%xmm5\n"=0A- ".pushsection .test, \"a\", = @progbits\n"=0A- "movsd_to_mem: movsd %%xmm5, = (%1)\n"=0A- ".popsection" :: "m" (res[10]), "c" = (NULL) );=0A+ put_insn(movsd_to_mem, "movsd %%xmm5, = (%1)")=0A+ :: "m" (res[10]), "c" (NULL) );=0A =0A- = memcpy(instr, movsd_to_mem, 15);=0A- regs.eip =3D (unsigned = long)&instr[0];=0A+ set_insn(movsd_to_mem);=0A regs.ecx = =3D (unsigned long)(res + 2);=0A regs.edx =3D 0;=0A rc = =3D x86_emulate(&ctxt, &emulops);=0A- if ( (rc !=3D X86EMUL_OKAY) = || memcmp(res, res + 8, 32) )=0A+ if ( (rc !=3D X86EMUL_OKAY) || = memcmp(res, res + 8, 32) ||=0A+ !check_eip(movsd_to_mem) )=0A = goto fail;=0A printf("okay\n");=0A }=0A@@ -797,19 = +797,17 @@ int main(int argc, char **argv)=0A printf("%-40s", "Testing = movaps (%edx),%xmm7...");=0A if ( stack_exec && cpu_has_sse )=0A = {=0A- extern const unsigned char movaps_from_mem[];=0A+ = decl_insn(movaps_from_mem);=0A =0A asm volatile ( "xorps %%xmm7, = %%xmm7\n"=0A- ".pushsection .test, \"a\", @progbits\n= "=0A- "movaps_from_mem: movaps (%0), %%xmm7\n"=0A- = ".popsection" :: "d" (NULL) );=0A+ = put_insn(movaps_from_mem, "movaps (%0), %%xmm7")=0A+ = :: "d" (NULL) );=0A =0A- memcpy(instr, movaps_from_mem, 15);=0A- = regs.eip =3D (unsigned long)&instr[0];=0A+ set_insn(movaps_= from_mem);=0A regs.ecx =3D 0;=0A regs.edx =3D = (unsigned long)res;=0A rc =3D x86_emulate(&ctxt, &emulops);=0A- = if ( rc !=3D X86EMUL_OKAY )=0A+ if ( rc !=3D X86EMUL_OKAY || = !check_eip(movaps_from_mem) )=0A goto fail;=0A asm ( = "cmpeqps %1, %%xmm7\n\t"=0A "movmskps %%xmm7, %0" : "=3Dr" = (rc) : "m" (res[8]) );=0A@@ -825,19 +823,18 @@ int main(int argc, char = **argv)=0A memset(res + 10, 0x77, 8);=0A if ( stack_exec && = cpu_has_avx )=0A {=0A- extern const unsigned char vmovsd_to_mem[= ];=0A+ decl_insn(vmovsd_to_mem);=0A =0A asm volatile ( = "vbroadcastsd %0, %%ymm5\n"=0A- ".pushsection .test, = \"a\", @progbits\n"=0A- "vmovsd_to_mem: vmovsd = %%xmm5, (%1)\n"=0A- ".popsection" :: "m" (res[10]), = "c" (NULL) );=0A+ put_insn(vmovsd_to_mem, "vmovsd = %%xmm5, (%1)")=0A+ :: "m" (res[10]), "c" (NULL) = );=0A =0A- memcpy(instr, vmovsd_to_mem, 15);=0A- regs.eip = =3D (unsigned long)&instr[0];=0A+ set_insn(vmovsd_to_mem);=0A = regs.ecx =3D (unsigned long)(res + 2);=0A regs.edx =3D = 0;=0A rc =3D x86_emulate(&ctxt, &emulops);=0A- if ( (rc = !=3D X86EMUL_OKAY) || memcmp(res, res + 8, 32) )=0A+ if ( (rc !=3D = X86EMUL_OKAY) || memcmp(res, res + 8, 32) ||=0A+ !check_eip(vmo= vsd_to_mem) )=0A goto fail;=0A printf("okay\n");=0A = }=0A@@ -850,19 +847,17 @@ int main(int argc, char **argv)=0A = printf("%-40s", "Testing vmovaps (%edx),%ymm7...");=0A if ( stack_exec = && cpu_has_avx )=0A {=0A- extern const unsigned char vmovaps_fro= m_mem[];=0A+ decl_insn(vmovaps_from_mem);=0A =0A asm = volatile ( "vxorps %%ymm7, %%ymm7, %%ymm7\n"=0A- = ".pushsection .test, \"a\", @progbits\n"=0A- = "vmovaps_from_mem: vmovaps (%0), %%ymm7\n"=0A- = ".popsection" :: "d" (NULL) );=0A+ put_insn(vmovaps_f= rom_mem, "vmovaps (%0), %%ymm7")=0A+ :: "d" (NULL) = );=0A =0A- memcpy(instr, vmovaps_from_mem, 15);=0A- regs.eip = =3D (unsigned long)&instr[0];=0A+ set_insn(vmovaps_from_mem);=0A = regs.ecx =3D 0;=0A regs.edx =3D (unsigned = long)res;=0A rc =3D x86_emulate(&ctxt, &emulops);=0A- if ( = rc !=3D X86EMUL_OKAY )=0A+ if ( rc !=3D X86EMUL_OKAY || !check_eip(v= movaps_from_mem) )=0A goto fail;=0A asm ( "vcmpeqps = %1, %%ymm7, %%ymm0\n\t"=0A "vmovmskps %%ymm0, %0" : "=3Dr" = (rc) : "m" (res[8]) );=0A@@ -873,6 +868,11 @@ int main(int argc, char = **argv)=0A else=0A printf("skipped\n");=0A =0A+#undef = decl_insn=0A+#undef put_insn=0A+#undef set_insn=0A+#undef check_eip=0A+=0A = for ( j =3D 1; j <=3D 2; j++ )=0A {=0A #if defined(__i386__)=0A --=__Part695BD42E.3__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__Part695BD42E.3__=--