diff mbox

test: Add emulator test for iret instruction

Message ID 1280271811-1350-1-git-send-email-m.gamal005@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mohammed Gamal July 27, 2010, 11:03 p.m. UTC
None
diff mbox

Patch

diff --git a/kvm/test/x86/realmode.c b/kvm/test/x86/realmode.c
index bd79348..564116a 100644
--- a/kvm/test/x86/realmode.c
+++ b/kvm/test/x86/realmode.c
@@ -865,6 +865,28 @@  void test_pusha_popa()
 		print_serial("Pusha/Popa Test2: PASS\n");
 }
 
+void test_iret()
+{
+	struct regs inregs = { 0 }, outregs;
+
+	MK_INSN(iret, "pushf\n\t"
+		      "pushl %cs\n\t"
+		      "call 1f\n\t" /* a near call will push eip onto the stack */
+		      "jmp 2f\n\t"
+		      "1:iret\n\t"
+		      "2:\n\t"
+		     );
+
+	exec_in_big_real_mode(&inregs, &outregs,
+			      insn_iret,
+			      insn_iret_end - insn_iret);
+
+	if (!regs_equal(&inregs, &outregs, R_AX))
+		print_serial("iret Test 1: FAIL\n");
+	else
+		print_serial("iret Test 1: PASS\n");
+}
+
 void realmode_start(void)
 {
 	test_null();
@@ -886,6 +908,7 @@  void realmode_start(void)
 	/* long jmp test uses call near so test it after testing call */
 	test_long_jmp();
 	test_xchg();
+	test_iret();
 
 	exit(0);
 }