mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nadav Amit <namit@cs.technion.ac.il>
To: pbonzini@redhat.com
Cc: gleb@kernel.org, tglx@linutronix.de, mingo@redhat.com,
	hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, Nadav Amit <namit@cs.technion.ac.il>
Subject: [PATCH kvm-unit-tests 2/5] x86: test xadd with two identical operands
Date: Wed, 18 Jun 2014 17:19:51 +0300	[thread overview]
Message-ID: <1403101194-23707-3-git-send-email-namit@cs.technion.ac.il> (raw)
In-Reply-To: <1403101194-23707-1-git-send-email-namit@cs.technion.ac.il>

Previously, KVM emulated xadd incorrectly when the source and destination
operands were identical.  The expected result is that the register would hold
the sum (2x) and not the previous value (x).  This test checks this behavior.
It should be executed with a disabled unrestricted mode.

Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
 x86/realmode.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/x86/realmode.c b/x86/realmode.c
index dc4a1d3..10c3e03 100644
--- a/x86/realmode.c
+++ b/x86/realmode.c
@@ -1663,6 +1663,14 @@ void test_smsw(void)
 	report("smsw", R_AX | R_BX | R_CX, outregs.eax == outregs.ebx);
 }
 
+void test_xadd(void)
+{
+	MK_INSN(xadd, "xaddl %eax, %eax\n\t");
+	inregs.eax = 0x12345678;
+	exec_in_big_real_mode(&insn_xadd);
+	report("xadd", R_AX, outregs.eax == inregs.eax * 2);
+}
+
 
 void realmode_start(void)
 {
@@ -1712,6 +1720,7 @@ void realmode_start(void)
 	test_dr_mod();
 	test_smsw();
 	test_nopl();
+	test_xadd();
 	test_perf_loop();
 	test_perf_mov();
 	test_perf_arith();
-- 
1.9.1


  parent reply	other threads:[~2014-06-18 14:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 14:19 [PATCH kvm-unit-tests 0/5] x86: Tests for recent emulator bugs Nadav Amit
2014-06-18 14:19 ` [PATCH kvm-unit-tests 1/5] x86: Testing nop instruction on 64-bit Nadav Amit
2014-06-18 14:19 ` Nadav Amit [this message]
2014-06-18 14:19 ` [PATCH kvm-unit-tests 3/5] x86: Test btcq with operand larger than 64 Nadav Amit
2014-06-18 14:19 ` [PATCH kvm-unit-tests 4/5] x86: check cmov instruction on 64-bit Nadav Amit
2014-06-18 14:19 ` [PATCH kvm-unit-tests 5/5] x86: Test monitor and mwait on real-mode Nadav Amit

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=1403101194-23707-3-git-send-email-namit@cs.technion.ac.il \
    --to=namit@cs.technion.ac.il \
    --cc=gleb@kernel.org \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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

all inboxes | Powered by JetHome®