From patchwork Sun Aug 8 18:13:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Gamal X-Patchwork-Id: 118289 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 o78IDiF6017208 for ; Sun, 8 Aug 2010 18:13:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753887Ab0HHSNm (ORCPT ); Sun, 8 Aug 2010 14:13:42 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:50760 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753641Ab0HHSNl (ORCPT ); Sun, 8 Aug 2010 14:13:41 -0400 Received: by wyb39 with SMTP id 39so9256364wyb.19 for ; Sun, 08 Aug 2010 11:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=53p4uAiaEbnhKcgOeDZPUHnPoNal6l2WHowCMVcCNLo=; b=dRj1kqjSM8bdCpt2FFA/p0cs9VF5CQkYebYToxnzqihNgkrmIwYwM8m77XvxwTrszm ckuDwh/r9qlTJz88vqyLnq+ozMi57kJFmN0mL0td6cf89PkQ+hXG1yM0Y6XdgpuFy7JS 0eBK7bgfwJf8yap32aufUQEgTLb+rSwR8FE3c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=Klc0kJmnnzTtWzMBIWYglvlsiFGe0PQhiW9e5LDSygmtw/o764Ro5tmHg+/6eHBGzx AHCPNnif7gCXz7OBZQJzwuY17Uw/VQ630gCKguXeYCDKXbOjRB9PjIyK6MgspLz9/+XW L08URPR8BUF3vtaQ8uAa/4JQinnP+DzuTohO8= Received: by 10.227.137.81 with SMTP id v17mr13031073wbt.10.1281291220137; Sun, 08 Aug 2010 11:13:40 -0700 (PDT) Received: from localhost.localdomain ([188.48.101.98]) by mx.google.com with ESMTPS id w14sm2096726weq.9.2010.08.08.11.13.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 08 Aug 2010 11:13:39 -0700 (PDT) From: Mohammed Gamal To: avi@redhat.com Cc: mtosatti@redhat.com, kvm@vger.kernel.org, Mohammed Gamal Subject: [PATCH v2 1/3] test: Add imul real mode test Date: Sun, 8 Aug 2010 21:13:31 +0300 Message-Id: <1281291213-4691-1-git-send-email-m.gamal005@gmail.com> X-Mailer: git-send-email 1.7.0.4 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]); Sun, 08 Aug 2010 18:13:44 +0000 (UTC) diff --git a/x86/realmode.c b/x86/realmode.c index 3bbd630..5878396 100644 --- a/x86/realmode.c +++ b/x86/realmode.c @@ -733,6 +733,7 @@ void test_long_jmp() else print_serial("Long JMP Test: PASS\n"); } + void test_push_pop() { struct regs inregs = { 0 }, outregs; @@ -975,6 +976,90 @@ void test_int() print_serial("int Test 1: PASS\n"); } +void test_imul() +{ + struct regs inregs = { 0 }, outregs; + + MK_INSN(imul8_1, "mov $2, %al\n\t" + "mov $-4, %cx\n\t" + "imul %cl\n\t"); + + MK_INSN(imul16_1, "mov $2, %ax\n\t" + "mov $-4, %cx\n\t" + "imul %cx\n\t"); + + MK_INSN(imul32_1, "mov $2, %eax\n\t" + "mov $-4, %ecx\n\t" + "imul %ecx\n\t"); + + MK_INSN(imul8_2, "mov $0x12340002, %eax\n\t" + "mov $4, %cx\n\t" + "imul %cl\n\t"); + + MK_INSN(imul16_2, "mov $2, %ax\n\t" + "mov $4, %cx\n\t" + "imul %cx\n\t"); + + MK_INSN(imul32_2, "mov $2, %eax\n\t" + "mov $4, %ecx\n\t" + "imul %ecx\n\t"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_imul8_1, + insn_imul8_1_end - insn_imul8_1); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || (outregs.eax & 0xff) != (u8)-8) + print_serial("imul Test 1: FAIL\n"); + else + print_serial("imul Test 1: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_imul16_1, + insn_imul16_1_end - insn_imul16_1); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != (u16)-8) + print_serial("imul Test 2: FAIL\n"); + else + print_serial("imul Test 2: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_imul32_1, + insn_imul32_1_end - insn_imul32_1); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != (u32)-8) + print_serial("imul Test 3: FAIL\n"); + else + print_serial("imul Test 3: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_imul8_2, + insn_imul8_2_end - insn_imul8_2); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || (outregs.eax & 0xffff) != 8 || + (outregs.eax & 0xffff0000) != 0x12340000) + print_serial("imul Test 4: FAIL\n"); + else + print_serial("imul Test 4: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_imul16_2, + insn_imul16_2_end - insn_imul16_2); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 8) + print_serial("imul Test 5: FAIL\n"); + else + print_serial("imul Test 5: PASS\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_imul32_2, + insn_imul32_2_end - insn_imul32_2); + + if (!regs_equal(&inregs, &outregs, R_AX | R_CX | R_DX) || outregs.eax != 8) + print_serial("imul Test 6: FAIL\n"); + else + print_serial("imul Test 6: PASS\n"); +} + void realmode_start(void) { test_null(); @@ -998,6 +1083,7 @@ void realmode_start(void) test_xchg(); test_iret(); test_int(); + test_imul(); exit(0); }