From patchwork Wed Mar 24 21:24:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 88068 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 o2OLUIwr014470 for ; Wed, 24 Mar 2010 21:30:18 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753276Ab0CXV3V (ORCPT ); Wed, 24 Mar 2010 17:29:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59505 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753036Ab0CXV3T (ORCPT ); Wed, 24 Mar 2010 17:29:19 -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 o2OLTJj1008071 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 24 Mar 2010 17:29:19 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2OLTJNJ022843; Wed, 24 Mar 2010 17:29:19 -0400 Received: from amt.cnet (vpn-10-46.rdu.redhat.com [10.11.10.46]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o2OLTHsG008881; Wed, 24 Mar 2010 17:29:18 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id B5A5368AC6C; Wed, 24 Mar 2010 18:28:22 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id o2OLSLJ8022419; Wed, 24 Mar 2010 18:28:21 -0300 Message-Id: <20100324212726.903978877@amt.cnet> User-Agent: quilt/0.47-1 Date: Wed, 24 Mar 2010 18:24:16 -0300 From: Marcelo Tosatti To: kvm@vger.kernel.org Cc: Marcelo Tosatti Subject: [patch 8/8] test: long rmap chains References: <20100324212408.790319364@amt.cnet> Content-Disposition: inline; filename=test-rmap-chain 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]); Wed, 24 Mar 2010 21:30:18 +0000 (UTC) Index: qemu-kvm/kvm/user/config-x86-common.mak =================================================================== --- qemu-kvm.orig/kvm/user/config-x86-common.mak +++ qemu-kvm/kvm/user/config-x86-common.mak @@ -45,6 +45,9 @@ $(TEST_DIR)/vmexit.flat: $(cstart.o) $(T $(TEST_DIR)/slot_deletion.flat: $(cstart.o) $(TEST_DIR)/slot_deletion.o \ $(TEST_DIR)/print.o $(TEST_DIR)/vm.o + +$(TEST_DIR)/rmap_chain.flat: $(cstart.o) $(TEST_DIR)/rmap_chain.o \ + $(TEST_DIR)/print.o $(TEST_DIR)/vm.o $(TEST_DIR)/test32.flat: $(TEST_DIR)/test32.o Index: qemu-kvm/kvm/user/config-x86_64.mak =================================================================== --- qemu-kvm.orig/kvm/user/config-x86_64.mak +++ qemu-kvm/kvm/user/config-x86_64.mak @@ -8,6 +8,6 @@ tests = $(TEST_DIR)/access.flat $(TEST_D $(TEST_DIR)/simple.flat $(TEST_DIR)/stringio.flat \ $(TEST_DIR)/memtest1.flat $(TEST_DIR)/emulator.flat \ $(TEST_DIR)/hypercall.flat $(TEST_DIR)/apic.flat \ - $(TEST_DIR)/slot_deletion.flat + $(TEST_DIR)/slot_deletion.flat $(TEST_DIR)/rmap_chain.flat include config-x86-common.mak Index: qemu-kvm/kvm/user/test/x86/rmap_chain.c =================================================================== --- /dev/null +++ qemu-kvm/kvm/user/test/x86/rmap_chain.c @@ -0,0 +1,53 @@ +/* test long rmap chains */ + +#include "libcflat.h" +#include "vm.h" +#include "smp.h" + +void print(const char *s); + +static unsigned int inl(unsigned short port) +{ + unsigned int val; + asm volatile ("inl %w1, %0":"=a" (val):"Nd" (port)); + return val; +} + +int main (void) +{ + int i; + int nr_pages; + void *target_page, *virt_addr; + + setup_vm(); + + nr_pages = inl(0xd1) / PAGE_SIZE; + nr_pages -= 1000; + target_page = alloc_page(); + + virt_addr = (void *) 0xfffffa000; + for (i = 0; i < nr_pages; i++) { + install_page(phys_to_virt(read_cr3()), virt_to_phys(target_page), + virt_addr); + virt_addr += PAGE_SIZE; + } + printf("created %d mappings\n", nr_pages); + + virt_addr = (void *) 0xfffffa000; + for (i = 0; i < nr_pages; i++) { + unsigned long *touch = virt_addr; + + *touch = 0; + virt_addr += PAGE_SIZE; + } + printf("instantiated mappings\n"); + + virt_addr += PAGE_SIZE; + install_pte(phys_to_virt(read_cr3()), 1, virt_addr, + 0 | PTE_PRESENT | PTE_WRITE, target_page); + + *(unsigned long *)virt_addr = 0; + printf("SUCCESS\n"); + + return 0; +}