From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Yongjun Subject: [PATCH v3] Add realmode test for jcxz instruction Date: Tue, 24 Aug 2010 10:57:12 +0800 Message-ID: <4C733508.7010608@cn.fujitsu.com> References: <4C6CCE6C.4010502@cn.fujitsu.com> <4C6CCEF7.9040404@cn.fujitsu.com> <4C6D2C26.7030604@redhat.com> <4C6DD1E8.20902@cn.fujitsu.com> <20100824000028.GH32690@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Avi Kivity , kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from cn.fujitsu.com ([222.73.24.84]:57010 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751692Ab0HXC6y (ORCPT ); Mon, 23 Aug 2010 22:58:54 -0400 In-Reply-To: <20100824000028.GH32690@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: Signed-off-by: Wei Yongjun --- v2 -> v3: rebased --- x86/realmode.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 42 insertions(+), 0 deletions(-) diff --git a/x86/realmode.c b/x86/realmode.c index 8c771fc..a833829 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1242,6 +1242,47 @@ void test_lds_lss() outregs.ebx == desc.sel); } +void test_jcxz(void) +{ + MK_INSN(jcxz1, "jcxz 1f\n\t" + "mov $0x1234, %eax\n\t" + "1:\n\t"); + MK_INSN(jcxz2, "mov $0x100, %ecx\n\t" + "jcxz 1f\n\t" + "mov $0x1234, %eax\n\t" + "mov $0, %ecx\n\t" + "1:\n\t"); + MK_INSN(jcxz3, "mov $0x10000, %ecx\n\t" + "jcxz 1f\n\t" + "mov $0x1234, %eax\n\t" + "1:\n\t"); + MK_INSN(jecxz1, "jecxz 1f\n\t" + "mov $0x1234, %eax\n\t" + "1:\n\t"); + MK_INSN(jecxz2, "mov $0x10000, %ecx\n\t" + "jecxz 1f\n\t" + "mov $0x1234, %eax\n\t" + "mov $0, %ecx\n\t" + "1:\n\t"); + + inregs = (struct regs){ 0 }; + + exec_in_big_real_mode(&insn_jcxz1); + report("jcxz short 1", 0, 1); + + exec_in_big_real_mode(&insn_jcxz2); + report("jcxz short 2", R_AX, outregs.eax == 0x1234); + + exec_in_big_real_mode(&insn_jcxz3); + report("jcxz short 3", R_CX, outregs.ecx == 0x10000); + + exec_in_big_real_mode(&insn_jecxz1); + report("jecxz short 1", 0, 1); + + exec_in_big_real_mode(&insn_jecxz2); + report("jecxz short 2", R_AX, outregs.eax == 0x1234); +} + void realmode_start(void) { test_null(); @@ -1274,6 +1315,7 @@ void realmode_start(void) test_cwd_cdq(); test_das(); test_lds_lss(); + test_jcxz(); exit(0); } -- 1.7.0.4