public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: mtosatti@redhat.com, avi@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCH] test: add inc/dec emulation testing
Date: Wed, 14 Jul 2010 15:27:29 +0300	[thread overview]
Message-ID: <20100714122729.GE4689@redhat.com> (raw)


Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/kvm/test/x86/emulator.c b/kvm/test/x86/emulator.c
index 6db1305..87ce9bc 100644
--- a/kvm/test/x86/emulator.c
+++ b/kvm/test/x86/emulator.c
@@ -220,6 +220,31 @@ jmpf:
     report("ljmp", res);
 }
 
+void test_incdec(void *mem)
+{
+    unsigned long *m = mem;
+
+    *m = 0;
+
+    asm volatile ("incl %0":"+m"(*m));
+    report("incl",  *m == 1);
+    asm volatile ("decl %0":"+m"(*m));
+    report("decl",  *m == 0);
+    asm volatile ("incb %0":"+m"(*m));
+    report("incb",  *m == 1);
+    asm volatile ("decb %0":"+m"(*m));
+    report("decb",  *m == 0);
+
+    asm volatile ("lock incl %0":"+m"(*m));
+    report("lock incl",  *m == 1);
+    asm volatile ("lock decl %0":"+m"(*m));
+    report("lock decl",  *m == 0);
+    asm volatile ("lock incb %0":"+m"(*m));
+    report("lock incb",  *m == 1);
+    asm volatile ("lock decb %0":"+m"(*m));
+    report("lock decb",  *m == 0);
+}
+
 void test_smsw(void)
 {
 	char mem[16];
@@ -298,6 +323,7 @@ int main()
 	test_lmsw();
 	test_ljmp(mem);
 	test_stringio();
+	test_incdec(mem);
 
 	printf("\nSUMMARY: %d tests, %d failures\n", tests, fails);
 	return fails ? 1 : 0;
--
			Gleb.

             reply	other threads:[~2010-07-14 12:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-14 12:27 Gleb Natapov [this message]
2010-07-14 16:43 ` [PATCH] test: add inc/dec emulation testing Marcelo Tosatti

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=20100714122729.GE4689@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox