From: Jan Beulich Date: Tue, 4 Sep 2018 09:29:22 +0000 (+0200) Subject: x86emul: extend MASKMOV{Q,DQU} tests X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~3333 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d2581b7b3ddb1861b1c06993503363a5f04cf689;p=xen.git x86emul: extend MASKMOV{Q,DQU} tests While deriving the first AVX512 pieces from existing code I've got the (in the end wrong) impression that the emulation of these insns would be broken. Besides testing that the instructions act as no-ops when the controlling mask bits are all zero, add ones to also check that the data merging actually works. Signed-off-by: Jan Beulich Acked-by: Andrew Cooper --- diff --git a/tools/tests/x86_emulator/test_x86_emulator.c b/tools/tests/x86_emulator/test_x86_emulator.c index ad9a5e72b7..4458a6537b 100644 --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -2626,7 +2626,7 @@ int main(int argc, char **argv) printf("skipped\n"); #endif - printf("%-40s", "Testing maskmovq (zero mask)..."); + printf("%-40s", "Testing maskmovq %mm4,%mm4..."); if ( stack_exec && cpu_has_sse ) { decl_insn(maskmovq); @@ -2639,12 +2639,25 @@ int main(int argc, char **argv) rc = x86_emulate(&ctxt, &emulops); if ( rc != X86EMUL_OKAY || !check_eip(maskmovq) ) goto fail; + + asm volatile ( "pcmpeqb %mm3, %mm3\n\t" + "punpcklbw %mm3, %mm4\n" ); + memset(res, 0x55, 24); + + set_insn(maskmovq); + regs.edi = (unsigned long)(res + 2); + rc = x86_emulate(&ctxt, &emulops); + if ( rc != X86EMUL_OKAY || !check_eip(maskmovq) || + memcmp(res, res + 4, 8) || + res[2] != 0xff55ff55 || res[3] != 0xff55ff55 ) + goto fail; + printf("okay\n"); } else printf("skipped\n"); - printf("%-40s", "Testing maskmovdqu (zero mask)..."); + printf("%-40s", "Testing maskmovdqu %xmm3,%xmm3..."); if ( stack_exec && cpu_has_sse2 ) { decl_insn(maskmovdqu); @@ -2653,9 +2666,24 @@ int main(int argc, char **argv) put_insn(maskmovdqu, "maskmovdqu %xmm3, %xmm3") ); set_insn(maskmovdqu); + regs.edi = 0; rc = x86_emulate(&ctxt, &emulops); if ( rc != X86EMUL_OKAY || !check_eip(maskmovdqu) ) goto fail; + + asm volatile ( "pcmpeqb %xmm4, %xmm4\n\t" + "punpcklbw %xmm4, %xmm3\n" ); + memset(res, 0x55, 48); + + set_insn(maskmovdqu); + regs.edi = (unsigned long)(res + 4); + rc = x86_emulate(&ctxt, &emulops); + if ( rc != X86EMUL_OKAY || !check_eip(maskmovdqu) || + memcmp(res, res + 8, 16) || + res[4] != 0xff55ff55 || res[5] != 0xff55ff55 || + res[6] != 0xff55ff55 || res[7] != 0xff55ff55 ) + goto fail; + printf("okay\n"); } else