From: Avi Kivity Subject: [PATCH 4/6] Add test for cwd/cdq/cqo instruction Date: Sun, 22 Aug 2010 15:18:42 +0300 Message-ID: <1282479524-3791-5-git-send-email-avi@redhat.com> References: <1282479524-3791-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:35699 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752331Ab0HVMSp (ORCPT ); Sun, 22 Aug 2010 08:18:45 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7MCIjso014091 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 22 Aug 2010 08:18:45 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7MCIiiG025637 for ; Sun, 22 Aug 2010 08:18:45 -0400 In-Reply-To: <1282479524-3791-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Mohammed Gamal Signed-off-by: Mohammed Gamal Signed-off-by: Avi Kivity --- x86/realmode.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) diff --git a/x86/realmode.c b/x86/realmode.c index 7c358f9..77fc1e1 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -1546,6 +1546,63 @@ static void test_das(void) print_serial("DAS Test: PASS\n"); } +void test_cwd_cdq() +{ + struct regs inregs = { 0 }, outregs; + + /* Sign-bit set */ + MK_INSN(cwd_1, "mov $0x8000, %ax\n\t" + "cwd\n\t"); + + /* Sign-bit not set */ + MK_INSN(cwd_2, "mov $0x1000, %ax\n\t" + "cwd\n\t"); + + /* Sign-bit set */ + MK_INSN(cdq_1, "mov $0x80000000, %eax\n\t" + "cdq\n\t"); + + /* Sign-bit not set */ + MK_INSN(cdq_2, "mov $0x10000000, %eax\n\t" + "cdq\n\t"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_cwd_1, + insn_cwd_1_end - insn_cwd_1); + + if (!regs_equal(&inregs, &outregs, R_AX | R_DX) || outregs.eax != 0x8000 || outregs.edx != 0xffff) + print_serial("cwd Test 1: FAIL\n"); + else + print_serial("cwd Test 1: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_cwd_2, + insn_cwd_2_end - insn_cwd_2); + + if (!regs_equal(&inregs, &outregs, R_AX | R_DX) || outregs.eax != 0x1000 || outregs.edx != 0) + print_serial("cwd Test 2: FAIL\n"); + else + print_serial("cwd Test 2: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_cdq_1, + insn_cdq_1_end - insn_cdq_1); + + if (!regs_equal(&inregs, &outregs, R_AX | R_DX) || outregs.eax != 0x80000000 || outregs.edx != 0xffffffff) + print_serial("cdq Test 1: FAIL\n"); + else + print_serial("cdq Test 1: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_cdq_2, + insn_cdq_2_end - insn_cdq_2); + + if (!regs_equal(&inregs, &outregs, R_AX | R_DX) || outregs.eax != 0x10000000 || outregs.edx != 0) + print_serial("cdq Test 2: FAIL\n"); + else + print_serial("cdq Test 2: PASS\n"); +} + void realmode_start(void) { test_null(); @@ -1575,6 +1632,7 @@ void realmode_start(void) test_idiv(); test_loopcc(); test_cbw(); + test_cwd_cdq(); test_das(); exit(0); -- 1.7.1