diff mbox

[v2,3/3] x86/emulate: added tests for {, v}movd mm, m32

Message ID 20160718143020.14828-3-mdontu@bitdefender.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mihai Donțu July 18, 2016, 2:30 p.m. UTC
Signed-off-by: Mihai Donțu <mdontu@bitdefender.com>
---
 tools/tests/x86_emulator/test_x86_emulator.c | 42 ++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

Comments

Andrew Cooper July 18, 2016, 2:57 p.m. UTC | #1
On 18/07/16 15:30, Mihai Donțu wrote:
> Signed-off-by: Mihai Donțu <mdontu@bitdefender.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox

Patch

diff --git a/tools/tests/x86_emulator/test_x86_emulator.c b/tools/tests/x86_emulator/test_x86_emulator.c
index 8994149..e2bd7ce 100644
--- a/tools/tests/x86_emulator/test_x86_emulator.c
+++ b/tools/tests/x86_emulator/test_x86_emulator.c
@@ -650,6 +650,48 @@  int main(int argc, char **argv)
 #define check_eip(which) (regs.eip == (unsigned long)instr + \
                                       (unsigned long)which##_len)
 
+    printf("%-40s", "Testing movd %%mm3,32(%%eax)...");
+    if ( stack_exec && cpu_has_mmx )
+    {
+        decl_insn(movd_to_mem32);
+
+        asm volatile ( "pcmpeqb %%mm3, %%mm3\n"
+                       put_insn(movd_to_mem32, "movd %%mm3, 32(%%eax)")
+                       :: );
+
+        *(res + 8) = 0xbdbdbdbd;
+        set_insn(movd_to_mem32);
+        regs.eax = (unsigned long)res;
+        rc = x86_emulate(&ctxt, &emulops);
+        if ( (rc != X86EMUL_OKAY) || *(res + 8) != 0xffffffff ||
+             !check_eip(movd_to_mem32) )
+            goto fail;
+        printf("okay\n");
+    }
+    else
+        printf("skipped\n");
+
+    printf("%-40s", "Testing vmovd %%xmm1,32(%%eax)...");
+    if ( stack_exec && cpu_has_avx )
+    {
+        decl_insn(vmovd_to_mem32);
+
+        asm volatile ( "pcmpeqb %%xmm1, %%xmm1\n"
+                       put_insn(vmovd_to_mem32, "vmovd %%xmm1, 32(%%eax)")
+                       :: );
+
+        *(res + 8) = 0xbdbdbdbd;
+        set_insn(vmovd_to_mem32);
+        regs.eax = (unsigned long)res;
+        rc = x86_emulate(&ctxt, &emulops);
+        if ( (rc != X86EMUL_OKAY) || *(res + 8) != 0xffffffff ||
+             !check_eip(vmovd_to_mem32) )
+            goto fail;
+        printf("okay\n");
+    }
+    else
+        printf("skipped\n");
+
     printf("%-40s", "Testing movq %mm3,(%ecx)...");
     if ( stack_exec && cpu_has_mmx )
     {