From patchwork Wed Aug 19 04:12:17 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Gamal X-Patchwork-Id: 42515 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7J4CPlw001386 for ; Wed, 19 Aug 2009 04:12:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750775AbZHSEMV (ORCPT ); Wed, 19 Aug 2009 00:12:21 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750763AbZHSEMV (ORCPT ); Wed, 19 Aug 2009 00:12:21 -0400 Received: from ey-out-2122.google.com ([74.125.78.27]:33767 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750753AbZHSEMU (ORCPT ); Wed, 19 Aug 2009 00:12:20 -0400 Received: by ey-out-2122.google.com with SMTP id 22so906735eye.37 for ; Tue, 18 Aug 2009 21:12:21 -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=P/nF/qWtH1WGyee9DUaEUd2fGeJqMFwvV/HbV8VTfdU=; b=wrIo14eV2UV6+UYdmhhtdbMpqCJ3R20yo2ofpnO62dBCGdP/Oxyxr8mT+k2msHyEhc TvNZ2Kz47lcyxLVZ83iqn46QoPrC2RE3pNAZTi2eegCs8NWmXBVVBcfhZJ+LWyB3XrA/ QzJzWIElV3gWqOuKoaMqtKXU1slQb4y6u4dQs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=HCSqAGMIKwro6c7s5LwOEP+VS+L5fpVcd7x+7RFUfgZ5ZDgpZsH1NQKR880GGi+2/w 4FjSFkrbU797tT140Px9aG50fsfo48bW3iF/GzlXf75agdgAvGajeBtptQdCVXRjjTDt PTADY32PF/s9rvxUzsc1765AHW+P13F8TKytk= Received: by 10.210.78.16 with SMTP id a16mr5373728ebb.1.1250655141375; Tue, 18 Aug 2009 21:12:21 -0700 (PDT) Received: from localhost.localdomain ([188.50.64.39]) by mx.google.com with ESMTPS id 7sm2044035eyb.50.2009.08.18.21.12.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 18 Aug 2009 21:12:20 -0700 (PDT) From: Mohammed Gamal To: avi@redhat.com Cc: kvm@vger.kernel.org, Mohammed Gamal Subject: [PATCH] Add push/pop instructions test in test harness Date: Wed, 19 Aug 2009 07:12:17 +0300 Message-Id: <1250655137-480-1-git-send-email-m.gamal005@gmail.com> X-Mailer: git-send-email 1.6.0.4 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Signed-off-by: Mohammed Gamal --- kvm/user/test/x86/realmode.c | 78 ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 76 insertions(+), 2 deletions(-) diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c index 755b5d1..698328d 100644 --- a/kvm/user/test/x86/realmode.c +++ b/kvm/user/test/x86/realmode.c @@ -467,6 +467,79 @@ void test_long_jmp() if(!regs_equal(&inregs, &outregs, R_AX) || outregs.eax != 0x1234) print_serial("Long JMP Test: FAIL\n"); } +void test_push_pop() +{ + struct regs inregs = { 0 }, outregs; + MK_INSN(push32, "mov $0x12345678, %eax\n\t" + "push %eax\n\t" + "pop %ebx\n\t"); + MK_INSN(push16, "mov $0x1234, %ax\n\t" + "push %ax\n\t" + "pop %bx\n\t"); + + MK_INSN(push_es, "mov $0x231, %bx\n\t" //Just write a dummy value to see if it gets overwritten + "mov $0x123, %ax\n\t" + "mov %ax, %es\n\t" + "push %es\n\t" + "pop %bx \n\t" + ); + MK_INSN(pop_es, "push %ax\n\t" + "pop %es\n\t" + "mov %es, %bx\n\t" + ); + MK_INSN(push_pop_ss, "push %ss\n\t" + "pushw %ax\n\t" + "popw %ss\n\t" + "mov %ss, %bx\n\t" + "pop %ss\n\t" + ); + MK_INSN(push_pop_fs, "push %fs\n\t" + "pushl %eax\n\t" + "popl %fs\n\t" + "mov %fs, %ebx\n\t" + "pop %fs\n\t" + ); + + exec_in_big_real_mode(&inregs, &outregs, + insn_push32, + insn_push32_end - insn_push32); + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.eax != outregs.ebx || outregs.eax != 0x12345678) + print_serial("Push/Pop Test 1: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_push16, + insn_push16_end - insn_push16); + + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.eax != outregs.ebx || outregs.eax != 0x1234) + print_serial("Push/Pop Test 2: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_push_es, + insn_push_es_end - insn_push_es); + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.ebx != outregs.eax || outregs.eax != 0x123) + print_serial("Push/Pop Test 3: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_pop_es, + insn_pop_es_end - insn_pop_es); + + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.ebx != outregs.eax) + print_serial("Push/Pop Test 4: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_push_pop_ss, + insn_push_pop_ss_end - insn_push_pop_ss); + + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.ebx != outregs.eax) + print_serial("Push/Pop Test 5: FAIL\n"); + + exec_in_big_real_mode(&inregs, &outregs, + insn_push_pop_fs, + insn_push_pop_fs_end - insn_push_pop_fs); + + if (!regs_equal(&inregs, &outregs, R_AX|R_BX) || outregs.ebx != outregs.eax) + print_serial("Push/Pop Test 6: FAIL\n"); +} void test_null(void) { @@ -479,8 +552,9 @@ void test_null(void) void start(void) { test_null(); - + test_shld(); + test_push_pop(); test_mov_imm(); test_cmp_imm(); test_add_imm(); @@ -492,7 +566,7 @@ void start(void) test_call(); /* long jmp test uses call near so test it after testing call */ test_long_jmp(); - + exit(0); }