From patchwork Tue Aug 24 02:57:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 125151 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7O3ADpe002079 for ; Tue, 24 Aug 2010 03:17:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751895Ab0HXC6y (ORCPT ); Mon, 23 Aug 2010 22:58:54 -0400 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 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id C22CF17012B; Tue, 24 Aug 2010 10:58:51 +0800 (CST) Received: from fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id o7O2tXev020070; Tue, 24 Aug 2010 10:55:33 +0800 Received: from [10.167.141.76] (unknown [10.167.141.76]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id 7E92F14C026; Tue, 24 Aug 2010 11:00:00 +0800 (CST) Message-ID: <4C733508.7010608@cn.fujitsu.com> Date: Tue, 24 Aug 2010 10:57:12 +0800 From: Wei Yongjun User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.10) Gecko/20100528 Thunderbird/3.0.5 MIME-Version: 1.0 To: Marcelo Tosatti CC: Avi Kivity , kvm@vger.kernel.org Subject: [PATCH v3] Add realmode test for jcxz instruction References: <4C6CCE6C.4010502@cn.fujitsu.com> <4C6CCEF7.9040404@cn.fujitsu.com> <4C6D2C26.7030604@redhat.com> <4C6DD1E8.20902@cn.fujitsu.com> <20100824000028.GH32690@amt.cnet> In-Reply-To: <20100824000028.GH32690@amt.cnet> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 24 Aug 2010 03:17:42 +0000 (UTC) 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); }