From: Mohammed Gamal Subject: [PATCH] kvm: testsuite: Add test for in/out instructions Date: Sat, 6 Sep 2008 17:18:53 +0300 Message-ID: <20080906141853.GA8095@mohd-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@qumranet.com To: kvm@vger.kernel.org Return-path: Received: from an-out-0708.google.com ([209.85.132.243]:3148 "EHLO an-out-0708.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736AbYIFOTI (ORCPT ); Sat, 6 Sep 2008 10:19:08 -0400 Received: by an-out-0708.google.com with SMTP id d40so148589and.103 for ; Sat, 06 Sep 2008 07:19:05 -0700 (PDT) Content-Disposition: inline Sender: kvm-owner@vger.kernel.org List-ID: Add in/out instruction test in real mode test harness Signed-off-by: Mohammed Gamal --- user/test/x86/realmode.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 69 insertions(+), 0 deletions(-) diff --git a/user/test/x86/realmode.c b/user/test/x86/realmode.c index 4627529..5f0ca0f 100644 --- a/user/test/x86/realmode.c +++ b/user/test/x86/realmode.c @@ -211,6 +211,74 @@ void test_eflags_insn(struct regs *inregs, struct regs *outregs) print_serial("std test: FAIL\n"); } +void test_io(struct regs *inregs, struct regs *outregs) +{ + MK_INSN(io_test1, "mov $0xff, %al \n\t" + "out %al, $0x10 \n\t" + "in $0x10, %al \n\t"); + MK_INSN(io_test2, "mov $0xffff, %ax \n\t" + "out %ax, $0x10 \n\t" + "in $0x10, %ax \n\t"); + MK_INSN(io_test3, "mov $0xffffffff, %eax \n\t" + "out %eax, $0x10 \n\t" + "in $0x10, %eax \n\t"); + MK_INSN(io_test4, "mov $0x10, %dx \n\t" + "mov $0xff, %al \n\t" + "out %al, %dx \n\t" + "in %dx, %al \n\t"); + MK_INSN(io_test5, "mov $0x10, %dx \n\t" + "mov $0xffff, %ax \n\t" + "out %ax, %dx \n\t" + "in %dx, %ax \n\t"); + MK_INSN(io_test6, "mov $0x10, %dx \n\t" + "mov $0xffffffff, %eax \n\t" + "out %eax, %dx \n\t" + "in %dx, %eax \n\t"); + + exec_in_big_real_mode(inregs, outregs, + insn_io_test1, + insn_io_test1_end - insn_io_test1); + + if (!regs_equal(inregs, outregs, R_AX) || outregs->eax != 0xff) + print_serial("I/O test 1: FAIL\n"); + + exec_in_big_real_mode(inregs, outregs, + insn_io_test2, + insn_io_test2_end - insn_io_test2); + + if (!regs_equal(inregs, outregs, R_AX) || outregs->eax != 0xffff) + print_serial("I/O test 2: FAIL\n"); + + exec_in_big_real_mode(inregs, outregs, + insn_io_test3, + insn_io_test3_end - insn_io_test3); + + if (!regs_equal(inregs, outregs, R_AX) || outregs->eax != 0xffffffff) + print_serial("I/O test 3: FAIL\n"); + + exec_in_big_real_mode(inregs, outregs, + insn_io_test4, + insn_io_test4_end - insn_io_test4); + + if (!regs_equal(inregs, outregs, R_AX|R_DX) || outregs->eax != 0xff) + print_serial("I/O test 4: FAIL\n"); + + exec_in_big_real_mode(inregs, outregs, + insn_io_test5, + insn_io_test5_end - insn_io_test5); + + if (!regs_equal(inregs, outregs, R_AX|R_DX) || outregs->eax != 0xffff) + print_serial("I/O test 5: FAIL\n"); + + exec_in_big_real_mode(inregs, outregs, + insn_io_test6, + insn_io_test6_end - insn_io_test6); + + if (!regs_equal(inregs, outregs, R_AX|R_DX) || outregs->eax != 0xffffffff) + print_serial("I/O test 6: FAIL\n"); + +} + void start(void) { struct regs inregs = { 0 }, outregs; @@ -220,6 +288,7 @@ void start(void) if (!regs_equal(&inregs, &outregs, 0)) print_serial("null test: FAIL\n"); test_mov_imm(&inregs, &outregs); + test_io(&inregs, &outregs); test_eflags_insn(&inregs, &outregs); exit(0); } -- 1.5.4.3