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 4/5] x86: check cmov instruction on 64-bit
Date: Wed, 18 Jun 2014 17:19:53 +0300 [thread overview]
Message-ID: <1403101194-23707-5-git-send-email-namit@cs.technion.ac.il> (raw)
In-Reply-To: <1403101194-23707-1-git-send-email-namit@cs.technion.ac.il>
cmov instruction on 64-bit with dword destination register operand should clear
bits [63:32]. This test checks this behavior due to previous KVM bug.
Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
---
x86/emulator.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/x86/emulator.c b/x86/emulator.c
index 460949f..1fd0ca6 100644
--- a/x86/emulator.c
+++ b/x86/emulator.c
@@ -710,6 +710,18 @@ static void test_shld_shrd(u32 *mem)
report("shrd (cl)", *mem == ((0x12345678 >> 3) | (5u << 29)));
}
+static void test_cmov(u32 *mem)
+{
+ u64 val;
+ *mem = 0xabcdef12u;
+ asm ("movq $0x1234567812345678, %%rax\n\t"
+ "cmpl %%eax, %%eax\n\t"
+ "cmovnel (%[mem]), %%eax\n\t"
+ "movq %%rax, %[val]\n\t"
+ : [val]"=r"(val) : [mem]"r"(mem) : "%rax", "cc");
+ report("cmovnel", val == 0x12345678ul);
+}
+
#define INSN_XCHG_ALL \
"xchg %rax, 0+save \n\t" \
"xchg %rbx, 8+save \n\t" \
@@ -1054,12 +1066,12 @@ int main()
test_sreg(mem);
test_lldt(mem);
test_ltr(mem);
+ test_cmov(mem);
test_mmx_movq_mf(mem, insn_page, alt_insn_page, insn_ram);
test_movabs(mem, insn_page, alt_insn_page, insn_ram);
test_smsw_reg(mem, insn_page, alt_insn_page, insn_ram);
test_nop(mem, insn_page, alt_insn_page, insn_ram);
-
test_crosspage_mmio(mem);
test_string_io_mmio(mem);
--
1.9.1
next prev parent reply other threads:[~2014-06-18 14:20 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 ` [PATCH kvm-unit-tests 2/5] x86: test xadd with two identical operands Nadav Amit
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 ` Nadav Amit [this message]
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-5-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®