From patchwork Tue Mar 16 12:42:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 86131 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o2GCgvII032183 for ; Tue, 16 Mar 2010 12:42:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753060Ab0CPMmz (ORCPT ); Tue, 16 Mar 2010 08:42:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25386 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652Ab0CPMmy (ORCPT ); Tue, 16 Mar 2010 08:42:54 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2GCgsRi004256 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 16 Mar 2010 08:42:54 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2GCgrDY000977; Tue, 16 Mar 2010 08:42:53 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 7D2471336CF; Tue, 16 Mar 2010 14:42:52 +0200 (IST) Date: Tue, 16 Mar 2010 14:42:52 +0200 From: Gleb Natapov To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH] add "xchg ax, reg" emulator test Message-ID: <20100316124252.GD1365@redhat.com> MIME-Version: 1.0 Content-Disposition: inline X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 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, 16 Mar 2010 12:42:58 +0000 (UTC) diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c index bc6b27f..bfc2942 100644 --- a/kvm/user/test/x86/realmode.c +++ b/kvm/user/test/x86/realmode.c @@ -141,6 +141,90 @@ int regs_equal(const struct regs *r1, const struct regs *r2, int ignore) ); \ extern u8 insn_##name[], insn_##name##_end[] +void test_xchg(void) +{ + struct regs inregs = { .eax = 0, .ebx = 1, .ecx = 2, .edx = 3, .esi = 4, .edi = 5, .ebp = 6, .esp = 7}, outregs; + + MK_INSN(xchg_test1, "xchg %eax,%eax\n\t"); + MK_INSN(xchg_test2, "xchg %eax,%ebx\n\t"); + MK_INSN(xchg_test3, "xchg %eax,%ecx\n\t"); + MK_INSN(xchg_test4, "xchg %eax,%edx\n\t"); + MK_INSN(xchg_test5, "xchg %eax,%esi\n\t"); + MK_INSN(xchg_test6, "xchg %eax,%edi\n\t"); + MK_INSN(xchg_test7, "xchg %eax,%ebp\n\t"); + MK_INSN(xchg_test8, "xchg %eax,%esp\n\t"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_xchg_test1, + insn_xchg_test1_end - insn_xchg_test1); + + if (!regs_equal(&inregs, &outregs, 0)) + print_serial("xchg test 1: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_xchg_test2, + insn_xchg_test2_end - insn_xchg_test2); + + if (!regs_equal(&inregs, &outregs, R_AX | R_BX) || + outregs.eax != inregs.ebx || + outregs.ebx != inregs.eax) + print_serial("xchg test 2: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_xchg_test3, + insn_xchg_test3_end - insn_xchg_test3); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX) || + outregs.eax != inregs.ecx || + outregs.ecx != inregs.eax) + print_serial("xchg test 3: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_xchg_test4, + insn_xchg_test4_end - insn_xchg_test4); + + if (!regs_equal(&inregs, &outregs, R_AX | R_DX) || + outregs.eax != inregs.edx || + outregs.edx != inregs.eax) + print_serial("xchg test 4: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_xchg_test5, + insn_xchg_test5_end - insn_xchg_test5); + + if (!regs_equal(&inregs, &outregs, R_AX | R_SI) || + outregs.eax != inregs.esi || + outregs.esi != inregs.eax) + print_serial("xchg test 5: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_xchg_test6, + insn_xchg_test6_end - insn_xchg_test6); + + if (!regs_equal(&inregs, &outregs, R_AX | R_DI) || + outregs.eax != inregs.edi || + outregs.edi != inregs.eax) + print_serial("xchg test 6: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_xchg_test7, + insn_xchg_test7_end - insn_xchg_test7); + + if (!regs_equal(&inregs, &outregs, R_AX | R_BP) || + outregs.eax != inregs.ebp || + outregs.ebp != inregs.eax) + print_serial("xchg test 7: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_xchg_test8, + insn_xchg_test8_end - insn_xchg_test8); + + if (!regs_equal(&inregs, &outregs, R_AX | R_SP) || + outregs.eax != inregs.esp || + outregs.esp != inregs.eax) + print_serial("xchg test 8: FAIL\n"); +} + void test_shld(void) { struct regs inregs = { .eax = 0xbe, .edx = 0xef000000 }, outregs; @@ -572,6 +656,7 @@ void realmode_start(void) test_call(); /* long jmp test uses call near so test it after testing call */ test_long_jmp(); + test_xchg(); exit(0); }