From: Gleb Natapov <gleb@redhat.com>
To: avi@redhat.com, mtosatti@redhat.com
Cc: kvm@vger.kernel.org
Subject: [PATCH] add "xchg ax, reg" emulator test
Date: Tue, 16 Mar 2010 14:42:52 +0200 [thread overview]
Message-ID: <20100316124252.GD1365@redhat.com> (raw)
Add test for opcodes 0x90-0x9f emulation
Signed-off-by: Gleb Natapov <gleb@redhat.com>
diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c
index bc6b27f..bfc2942 100644
--- a/kvm/user/test/x86/realmode.c
+++ b/kvm/user/test/x86/realmode.c
@@ -141,6 +141,90 @@ int regs_equal(const struct regs *r1, const struct regs *r2, int ignore)
); \
extern u8 insn_##name[], insn_##name##_end[]
+void test_xchg(void)
+{
+ struct regs inregs = { .eax = 0, .ebx = 1, .ecx = 2, .edx = 3, .esi = 4, .edi = 5, .ebp = 6, .esp = 7}, outregs;
+
+ MK_INSN(xchg_test1, "xchg %eax,%eax\n\t");
+ MK_INSN(xchg_test2, "xchg %eax,%ebx\n\t");
+ MK_INSN(xchg_test3, "xchg %eax,%ecx\n\t");
+ MK_INSN(xchg_test4, "xchg %eax,%edx\n\t");
+ MK_INSN(xchg_test5, "xchg %eax,%esi\n\t");
+ MK_INSN(xchg_test6, "xchg %eax,%edi\n\t");
+ MK_INSN(xchg_test7, "xchg %eax,%ebp\n\t");
+ MK_INSN(xchg_test8, "xchg %eax,%esp\n\t");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_xchg_test1,
+ insn_xchg_test1_end - insn_xchg_test1);
+
+ if (!regs_equal(&inregs, &outregs, 0))
+ print_serial("xchg test 1: FAIL\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_xchg_test2,
+ insn_xchg_test2_end - insn_xchg_test2);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_BX) ||
+ outregs.eax != inregs.ebx ||
+ outregs.ebx != inregs.eax)
+ print_serial("xchg test 2: FAIL\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_xchg_test3,
+ insn_xchg_test3_end - insn_xchg_test3);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_CX) ||
+ outregs.eax != inregs.ecx ||
+ outregs.ecx != inregs.eax)
+ print_serial("xchg test 3: FAIL\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_xchg_test4,
+ insn_xchg_test4_end - insn_xchg_test4);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_DX) ||
+ outregs.eax != inregs.edx ||
+ outregs.edx != inregs.eax)
+ print_serial("xchg test 4: FAIL\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_xchg_test5,
+ insn_xchg_test5_end - insn_xchg_test5);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_SI) ||
+ outregs.eax != inregs.esi ||
+ outregs.esi != inregs.eax)
+ print_serial("xchg test 5: FAIL\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_xchg_test6,
+ insn_xchg_test6_end - insn_xchg_test6);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_DI) ||
+ outregs.eax != inregs.edi ||
+ outregs.edi != inregs.eax)
+ print_serial("xchg test 6: FAIL\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_xchg_test7,
+ insn_xchg_test7_end - insn_xchg_test7);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_BP) ||
+ outregs.eax != inregs.ebp ||
+ outregs.ebp != inregs.eax)
+ print_serial("xchg test 7: FAIL\n");
+
+ exec_in_big_real_mode(&inregs, &outregs,
+ insn_xchg_test8,
+ insn_xchg_test8_end - insn_xchg_test8);
+
+ if (!regs_equal(&inregs, &outregs, R_AX | R_SP) ||
+ outregs.eax != inregs.esp ||
+ outregs.esp != inregs.eax)
+ print_serial("xchg test 8: FAIL\n");
+}
+
void test_shld(void)
{
struct regs inregs = { .eax = 0xbe, .edx = 0xef000000 }, outregs;
@@ -572,6 +656,7 @@ void realmode_start(void)
test_call();
/* long jmp test uses call near so test it after testing call */
test_long_jmp();
+ test_xchg();
exit(0);
}
--
Gleb.
next reply other threads:[~2010-03-16 12:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 12:42 Gleb Natapov [this message]
2010-03-16 12:50 ` [PATCH] add "xchg ax, reg" emulator test Avi Kivity
2010-03-16 12:52 ` Gleb Natapov
2010-03-16 12:56 ` Avi Kivity
2010-03-17 19:10 ` 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=20100316124252.GD1365@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 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.