From patchwork Wed Aug 19 23:54:12 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammed Gamal X-Patchwork-Id: 42804 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 n7JNt4ZZ000931 for ; Wed, 19 Aug 2009 23:55:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753572AbZHSXy3 (ORCPT ); Wed, 19 Aug 2009 19:54:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753505AbZHSXy2 (ORCPT ); Wed, 19 Aug 2009 19:54:28 -0400 Received: from mail-fx0-f217.google.com ([209.85.220.217]:64881 "EHLO mail-fx0-f217.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753567AbZHSXy2 (ORCPT ); Wed, 19 Aug 2009 19:54:28 -0400 Received: by fxm17 with SMTP id 17so169034fxm.37 for ; Wed, 19 Aug 2009 16:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=KX5OoF+xN7KzNcVPksLRUM70spQtCGZQHan2hgfUuJ8=; b=Hwc7KqRw9xwDqHN4G2bvcO2xLOPaiWHlpALN5NJ59lcYPy9iIcL0uz/PTbQaGs7fGD qqywSFHZtE36dKrRDJY9oQ1Za3GSlqeOupnimN+KAXcG3jkbpBMYQG/GwsfSD5iwZVV9 JYaHZD+7qIvwy4XwV6Fo5ySm7WKqyO19sGz5c= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=llf32QAtrNFnppQ8106ntF35HNbH8C0JnH8p9eX9g1VQT94iGgYGSLMZuhbFqOFI5Q ptuMm6XU0MxMkx2U7Bil04ytNwuuOhvFYYXKfx+Zp/xjp8vuGO3O/nPd/5eDpa7GEUfS P+x0sZsPrlGDctT/YQCsiAKTkLPc0pq+EyOQ0= Received: by 10.103.81.14 with SMTP id i14mr2771517mul.85.1250726062186; Wed, 19 Aug 2009 16:54:22 -0700 (PDT) Received: from localhost ([188.52.15.213]) by mx.google.com with ESMTPS id t10sm2497959muh.0.2009.08.19.16.54.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 19 Aug 2009 16:54:21 -0700 (PDT) Date: Thu, 20 Aug 2009 02:54:12 +0300 From: Mohammed Gamal To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH][RESEND] Add push/pop instructions test in test harness Message-ID: <20090819235412.GA19992@mohd-laptop> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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 | 74 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 74 insertions(+), 0 deletions(-) diff --git a/kvm/user/test/x86/realmode.c b/kvm/user/test/x86/realmode.c index 755b5d1..04c1452 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) { @@ -481,6 +554,7 @@ void start(void) test_null(); test_shld(); + test_push_pop(); test_mov_imm(); test_cmp_imm(); test_add_imm();