From patchwork Mon May 3 15:39:59 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naphtali Sprei X-Patchwork-Id: 96484 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o43FeFAS031323 for ; Mon, 3 May 2010 15:40:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932847Ab0ECPkM (ORCPT ); Mon, 3 May 2010 11:40:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39007 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932827Ab0ECPkC (ORCPT ); Mon, 3 May 2010 11:40:02 -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 o43Fe2YY012888 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 3 May 2010 11:40:02 -0400 Received: from [10.35.0.60] (dhcp-0-60.tlv.redhat.com [10.35.0.60]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o43FdxVA024338 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 3 May 2010 11:40:01 -0400 Message-ID: <4BDEEE4F.7010606@redhat.com> Date: Mon, 03 May 2010 18:39:59 +0300 From: Naphtali Sprei User-Agent: Thunderbird 2.0.0.24 (X11/20100411) MIME-Version: 1.0 To: kvm@vger.kernel.org CC: Gleb Natapov Subject: [qemu-kvm tests PATCH] qemu-kvm tests: merged stringio into emulator X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 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]); Mon, 03 May 2010 15:40:16 +0000 (UTC) diff --git a/kvm/user/config-x86-common.mak b/kvm/user/config-x86-common.mak index 61cc2f0..0ff9425 100644 --- a/kvm/user/config-x86-common.mak +++ b/kvm/user/config-x86-common.mak @@ -56,8 +56,6 @@ $(TEST_DIR)/realmode.flat: $(TEST_DIR)/realmode.o $(TEST_DIR)/realmode.o: bits = 32 -$(TEST_DIR)/stringio.flat: $(cstart.o) $(TEST_DIR)/stringio.o - $(TEST_DIR)/msr.flat: $(cstart.o) $(TEST_DIR)/msr.o arch_clean: diff --git a/kvm/user/config-x86_64.mak b/kvm/user/config-x86_64.mak index 03c91f2..3403dc3 100644 --- a/kvm/user/config-x86_64.mak +++ b/kvm/user/config-x86_64.mak @@ -5,7 +5,7 @@ ldarch = elf64-x86-64 CFLAGS += -D__x86_64__ tests = $(TEST_DIR)/access.flat $(TEST_DIR)/sieve.flat \ - $(TEST_DIR)/stringio.flat $(TEST_DIR)/emulator.flat \ - $(TEST_DIR)/hypercall.flat $(TEST_DIR)/apic.flat + $(TEST_DIR)/emulator.flat $(TEST_DIR)/hypercall.flat \ + $(TEST_DIR)/apic.flat include config-x86-common.mak diff --git a/kvm/user/test/x86/README b/kvm/user/test/x86/README index e2ede5c..ab5a2ae 100644 --- a/kvm/user/test/x86/README +++ b/kvm/user/test/x86/README @@ -10,6 +10,5 @@ realmode: goes back to realmode, shld, push/pop, mov immediate, cmp immediate, a io, eflags instructions (clc, cli, etc.), jcc short, jcc near, call, long jmp, xchg sieve: heavy memory access with no paging and with paging static and with paging vmalloc'ed smptest: run smp_id() on every cpu and compares return value to number -stringio: outs forward and backward tsc: write to tsc(0) and write to tsc(100000000000) and read it back vmexit: long loops for each: cpuid, vmcall, mov_from_cr8, mov_to_cr8, inl_pmtimer, ipi, ipi+halt diff --git a/kvm/user/test/x86/emulator.c b/kvm/user/test/x86/emulator.c index 4967d1f..5406062 100644 --- a/kvm/user/test/x86/emulator.c +++ b/kvm/user/test/x86/emulator.c @@ -3,6 +3,7 @@ #include "libcflat.h" #define memset __builtin_memset +#define TESTDEV_IO_PORT 0xe0 int fails, tests; @@ -17,6 +18,29 @@ void report(const char *name, int result) } } +static char str[] = "abcdefghijklmnop"; + +void test_stringio() +{ + unsigned char r = 0; + asm volatile("cld \n\t" + "movw %0, %%dx \n\t" + "rep outsb \n\t" + : : "i"((short)TESTDEV_IO_PORT), + "S"(str), "c"(sizeof(str) - 1)); + asm volatile("inb %1, %0\n\t" : "=a"(r) : "i"((short)TESTDEV_IO_PORT)); + report("outsb up", r == str[sizeof(str) - 2]); /* last char */ + + asm volatile("std \n\t" + "movw %0, %%dx \n\t" + "rep outsb \n\t" + : : "i"((short)TESTDEV_IO_PORT), + "S"(str + sizeof(str) - 2), "c"(sizeof(str) - 1)); + asm volatile("cld \n\t" : : ); + asm volatile("in %1, %0\n\t" : "=a"(r) : "i"((short)TESTDEV_IO_PORT)); + report("outsb down", r == str[0]); +} + void test_cmps_one(unsigned char *m1, unsigned char *m3) { void *rsi, *rdi; @@ -93,8 +117,8 @@ void test_cmps(void *mem) m1[i] = m2[i] = m3[i] = i; for (int i = 100; i < 200; ++i) m1[i] = (m3[i] = m2[i] = i) + 1; - test_cmps_one(m1, m3); - test_cmps_one(m1, m2); + test_cmps_one(m1, m3); + test_cmps_one(m1, m2); } void test_cr8(void) @@ -271,7 +295,8 @@ int main() test_smsw(); test_lmsw(); - test_ljmp(mem); + test_ljmp(mem); + test_stringio(); printf("\nSUMMARY: %d tests, %d failures\n", tests, fails); return fails ? 1 : 0; diff --git a/kvm/user/test/x86/stringio.S b/kvm/user/test/x86/stringio.S deleted file mode 100644 index 461621c..0000000 --- a/kvm/user/test/x86/stringio.S +++ /dev/null @@ -1,36 +0,0 @@ - -.data - -.macro str name, value - -\name : .long 1f-2f -2: .ascii "\value" -1: -.endm - -TESTDEV_PORT = 0xf1 - - str "forward", "forward" - str "backward", "backward" - -.text - -.global main -main: - cld - movl forward, %ecx - lea 4+forward, %rsi - movw $TESTDEV_PORT, %dx - rep outsb - - std - movl backward, %ecx - lea 4+backward-1(%rcx), %rsi - movw $TESTDEV_PORT, %dx - rep outsb - - mov $0, %rsi - call exit - - -