From patchwork Wed Aug 18 08:41:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 120112 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 o7I8iKR5020451 for ; Wed, 18 Aug 2010 08:44:20 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752432Ab0HRIoR (ORCPT ); Wed, 18 Aug 2010 04:44:17 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:51611 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752239Ab0HRIoQ (ORCPT ); Wed, 18 Aug 2010 04:44:16 -0400 Received: from tang.cn.fujitsu.com (tang.cn.fujitsu.com [10.167.250.3]) by song.cn.fujitsu.com (Postfix) with ESMTP id E79B017003F; Wed, 18 Aug 2010 16:44:13 +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 o7I8f00j019459; Wed, 18 Aug 2010 16:41:00 +0800 Received: from [10.167.141.76] (unknown [10.167.141.76]) by fnst.cn.fujitsu.com (Postfix) with ESMTPA id D3F0C14C01F; Wed, 18 Aug 2010 16:45:15 +0800 (CST) Message-ID: <4C6B9CD1.90407@cn.fujitsu.com> Date: Wed, 18 Aug 2010 16:41:53 +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] test: Add realmode test for loopcc instruction References: <4C6B9BFD.1000904@cn.fujitsu.com> In-Reply-To: <4C6B9BFD.1000904@cn.fujitsu.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]); Wed, 18 Aug 2010 08:44:20 +0000 (UTC) diff --git a/x86/realmode.c b/x86/realmode.c index 35f6a16..bedd175 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1194,6 +1194,48 @@ void test_idiv() print_serial("idiv Test 3: PASS\n"); } +void test_loopcc(void) +{ + struct regs inregs = { 0 }, outregs; + + MK_INSN(loop, "mov $10, %ecx\n\t" + "1: inc %eax\n\t" + "loop 1b\n\t"); + + MK_INSN(loope, "mov $10, %ecx\n\t" + "mov $1, %eax\n\t" + "1: dec %eax\n\t" + "loope 1b\n\t"); + + MK_INSN(loopne, "mov $10, %ecx\n\t" + "mov $5, %eax\n\t" + "1: dec %eax\n\t" + "loopne 1b\n\t"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_loop, insn_loop_end - insn_loop); + if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 10) + print_serial("LOOPcc short Test 1: FAIL\n"); + else + print_serial("LOOPcc short Test 1: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_loope, insn_loope_end - insn_loope); + if(!regs_equal(&inregs, &outregs, R_AX | R_CX) || + outregs.eax != -1 || outregs.ecx != 8) + print_serial("LOOPcc short Test 2: FAIL\n"); + else + print_serial("LOOPcc short Test 2: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_loopne, insn_loopne_end - insn_loopne); + if(!regs_equal(&inregs, &outregs, R_AX | R_CX) || + outregs.eax != 0 || outregs.ecx != 5) + print_serial("LOOPcc short Test 3: FAIL\n"); + else + print_serial("LOOPcc short Test 3: PASS\n"); +} + void realmode_start(void) { test_null(); @@ -1221,6 +1263,7 @@ void realmode_start(void) test_mul(); test_div(); test_idiv(); + test_loopcc(); exit(0); }