All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] emulator: add movdqa tests
@ 2012-01-08 16:35 Stefan Hajnoczi
  2012-02-01  9:08 ` Takuya Yoshikawa
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Hajnoczi @ 2012-01-08 16:35 UTC (permalink / raw)
  To: kvm; +Cc: Avi Kivity, Stefan Hajnoczi

The movdqa instruction performs a 128-bit vector move and requires that
operands are aligned in memory.  Unlike the movdqu instruction, a #GP is
raised if operands are unaligned.

This patch does not exercise misalignment because the CPU detects
misalignment while still inside the guest and raises #GP.  The emulator
will therefore never meet unaligned movdqa instructions.

Also change "read"/"write" to "store"/"load" to make it obvious whether
the test transfers to or from memory.  Previous usage of "read" and
"write" was misleading.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
This test is expected to fail until a patch is merged that implements the
missing movdqa instruction.

 x86/emulator.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/x86/emulator.c b/x86/emulator.c
index b584122..327f871 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -598,12 +598,20 @@ static void test_sse(sse_union *mem)
 
     write_cr0(read_cr0() & ~6); /* EM, TS */
     write_cr4(read_cr4() | 0x200); /* OSFXSR */
+
     v.u[0] = 1; v.u[1] = 2; v.u[2] = 3; v.u[3] = 4;
     asm("movdqu %1, %0" : "=m"(*mem) : "x"(v.sse));
-    report("movdqu (read)", sseeq(&v, mem));
+    report("movdqu (store)", sseeq(&v, mem));
     mem->u[0] = 5; mem->u[1] = 6; mem->u[2] = 7; mem->u[3] = 8;
     asm("movdqu %1, %0" : "=x"(v.sse) : "m"(*mem));
-    report("movdqu (write)", sseeq(mem, &v));
+    report("movdqu (load)", sseeq(mem, &v));
+
+    v.u[0] = 1; v.u[1] = 2; v.u[2] = 3; v.u[3] = 4;
+    asm("movdqa %1, %0" : "=m"(*mem) : "x"(v.sse));
+    report("movdqa (store)", sseeq(&v, mem));
+    mem->u[0] = 5; mem->u[1] = 6; mem->u[2] = 7; mem->u[3] = 8;
+    asm("movdqa %1, %0" : "=x"(v.sse) : "m"(*mem));
+    report("movdqa (load)", sseeq(mem, &v));
 }
 
 static void test_rip_relative(unsigned *mem, char *insn_ram)
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-02-06 12:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-08 16:35 [PATCH] emulator: add movdqa tests Stefan Hajnoczi
2012-02-01  9:08 ` Takuya Yoshikawa
2012-02-01  9:13   ` Avi Kivity
2012-02-01  9:17     ` Takuya Yoshikawa
2012-02-01  9:21       ` Avi Kivity
2012-02-01  9:28         ` Takuya Yoshikawa
2012-02-06 12:00     ` Stefan Hajnoczi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.