All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Xu <jacobhxu@google.com>
To: Paolo Bonzini <pbonzini@redhat.com>, Jim Mattson <jmattson@google.com>
Cc: kvm@vger.kernel.org, Jacob Xu <jacobhxu@google.com>
Subject: [kvm-unit-tests PATCH 1/2] x86: add movups/movupd sse testcases to emulator.c
Date: Wed, 21 Apr 2021 16:12:57 -0700	[thread overview]
Message-ID: <20210421231258.2583654-1-jacobhxu@google.com> (raw)

Here we add movups/movupd tests corresponding to functionality
introduced in commit 29916968c486 ("kvm: Add emulation for movups/movupd").

Signed-off-by: Jacob Xu <jacobhxu@google.com>
---
 x86/emulator.c | 44 ++++++++++++++++++++------------------------
 1 file changed, 20 insertions(+), 24 deletions(-)

diff --git a/x86/emulator.c b/x86/emulator.c
index 6100b6d..ff3c2bf 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -664,30 +664,26 @@ static bool sseeq(sse_union *v1, sse_union *v2)
 
 static __attribute__((target("sse2"))) void test_sse(sse_union *mem)
 {
-    sse_union v;
-
-    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(sseeq(&v, mem), "movdqu (read)");
-    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(sseeq(mem, &v), "movdqu (write)");
-
-    v.u[0] = 1; v.u[1] = 2; v.u[2] = 3; v.u[3] = 4;
-    asm("movaps %1, %0" : "=m"(*mem) : "x"(v.sse));
-    report(sseeq(mem, &v), "movaps (read)");
-    mem->u[0] = 5; mem->u[1] = 6; mem->u[2] = 7; mem->u[3] = 8;
-    asm("movaps %1, %0" : "=x"(v.sse) : "m"(*mem));
-    report(sseeq(&v, mem), "movaps (write)");
-
-    v.u[0] = 1; v.u[1] = 2; v.u[2] = 3; v.u[3] = 4;
-    asm("movapd %1, %0" : "=m"(*mem) : "x"(v.sse));
-    report(sseeq(mem, &v), "movapd (read)");
-    mem->u[0] = 5; mem->u[1] = 6; mem->u[2] = 7; mem->u[3] = 8;
-    asm("movapd %1, %0" : "=x"(v.sse) : "m"(*mem));
-    report(sseeq(&v, mem), "movapd (write)");
+	sse_union v;
+
+	write_cr0(read_cr0() & ~6); /* EM, TS */
+	write_cr4(read_cr4() | 0x200); /* OSFXSR */
+
+#define TEST_RW_SSE(insn) do { \
+		v.u[0] = 1; v.u[1] = 2; v.u[2] = 3; v.u[3] = 4; \
+		asm(insn " %1, %0" : "=m"(*mem) : "x"(v.sse)); \
+		report(sseeq(&v, mem), insn " (read)"); \
+		mem->u[0] = 5; mem->u[1] = 6; mem->u[2] = 7; mem->u[3] = 8; \
+		asm(insn " %1, %0" : "=x"(v.sse) : "m"(*mem)); \
+		report(sseeq(&v, mem), insn " (write)"); \
+} while (0)
+
+	TEST_RW_SSE("movdqu");
+	TEST_RW_SSE("movaps");
+	TEST_RW_SSE("movapd");
+	TEST_RW_SSE("movups");
+	TEST_RW_SSE("movupd");
+#undef TEST_RW_SSE
 }
 
 static void test_mmx(uint64_t *mem)
-- 
2.31.1.368.gbe11c130af-goog


             reply	other threads:[~2021-04-21 23:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 23:12 Jacob Xu [this message]
2021-04-21 23:12 ` [kvm-unit-tests PATCH 2/2] x86: add additional test cases for sse exceptions to emulator.c Jacob Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210421231258.2583654-1-jacobhxu@google.com \
    --to=jacobhxu@google.com \
    --cc=jmattson@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.