From patchwork Fri Aug 20 00:52:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 120420 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 o7K0t913026510 for ; Fri, 20 Aug 2010 00:55:09 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751360Ab0HTAzF (ORCPT ); Thu, 19 Aug 2010 20:55:05 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:64467 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751311Ab0HTAzF (ORCPT ); Thu, 19 Aug 2010 20:55:05 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id 89BFE17011C; Fri, 20 Aug 2010 08:55:02 +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 o7K0pmCQ031893; Fri, 20 Aug 2010 08:51:48 +0800 Received: from [10.167.141.76] (unknown [10.167.141.76]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id CC57014C021; Fri, 20 Aug 2010 08:56:06 +0800 (CST) Message-ID: <4C6DD1E8.20902@cn.fujitsu.com> Date: Fri, 20 Aug 2010 08:52:56 +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: Avi Kivity CC: kvm@vger.kernel.org Subject: [PATCH v2] Add realmode test for jcxz instruction References: <4C6CCE6C.4010502@cn.fujitsu.com> <4C6CCEF7.9040404@cn.fujitsu.com> <4C6D2C26.7030604@redhat.com> In-Reply-To: <4C6D2C26.7030604@redhat.com> 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]); Fri, 20 Aug 2010 00:55:09 +0000 (UTC) diff --git a/x86/realmode.c b/x86/realmode.c index ce8fb18..75d77bd 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1262,6 +1262,67 @@ void test_cbw(void) print_serial("cwde test 1: PASS\n"); } +void test_jcxz(void) +{ + struct regs inregs = { 0 }, outregs; + + 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"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_jcxz1, insn_jcxz1_end - insn_jcxz1); + if(!regs_equal(&inregs, &outregs, 0)) + print_serial("JCXZ short Test 1: FAIL\n"); + else + print_serial("JCXZ short Test 1: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_jcxz2, insn_jcxz2_end - insn_jcxz2); + if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234) + print_serial("JCXZ short Test 2: FAIL\n"); + else + print_serial("JCXZ short Test 2: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_jcxz3, insn_jcxz3_end - insn_jcxz3); + if(!regs_equal(&inregs, &outregs, R_CX) || outregs.ecx != 0x10000) + print_serial("JCXZ short Test 3: FAIL\n"); + else + print_serial("JCXZ short Test 3: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_jecxz1, insn_jecxz1_end - insn_jecxz1); + if(!regs_equal(&inregs, &outregs, 0)) + print_serial("JECXZ short Test 1: FAIL\n"); + else + print_serial("JECXZ short Test 1: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_jecxz2, insn_jecxz2_end - insn_jecxz2); + if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234) + print_serial("JECXZ short Test 2: FAIL\n"); + else + print_serial("JECXZ short Test 2: PASS\n"); +} + void realmode_start(void) { test_null(); @@ -1291,6 +1352,7 @@ void realmode_start(void) test_idiv(); test_loopcc(); test_cbw(); + test_jcxz(); exit(0); }