From mboxrd@z Thu Jan 1 00:00:00 1970 From: Igor Mammedov Subject: Re: [PATCHv2] Add async page fault test Date: Wed, 09 May 2012 14:44:42 +0200 Message-ID: <4FAA66BA.5040607@redhat.com> References: <20120509103314.GU15960@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, avi@redhat.com, marcelo@redhat.com To: Gleb Natapov Return-path: Received: from mx1.redhat.com ([209.132.183.28]:47771 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752687Ab2EIMop (ORCPT ); Wed, 9 May 2012 08:44:45 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q49CiisU012029 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 May 2012 08:44:44 -0400 In-Reply-To: <20120509103314.GU15960@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 05/09/2012 12:33 PM, Gleb Natapov wrote: > The test checks that when hypervisor prefaults swapped in page it does > not generates spurious #PFs in case page was unmapped while it was > swapped out. > > diff --git a/config-x86-common.mak b/config-x86-common.mak > index c8fbda7..6976f78 100644 > --- a/config-x86-common.mak > +++ b/config-x86-common.mak > @@ -34,7 +34,7 @@ tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \ > $(TEST_DIR)/realmode.flat $(TEST_DIR)/msr.flat \ > $(TEST_DIR)/hypercall.flat $(TEST_DIR)/sieve.flat \ > $(TEST_DIR)/kvmclock_test.flat $(TEST_DIR)/eventinj.flat \ > - $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat > + $(TEST_DIR)/s3.flat $(TEST_DIR)/pmu.flat $(TEST_DIR)/asyncpf.flat > > ifdef API > tests-common += api/api-sample > @@ -90,6 +90,8 @@ $(TEST_DIR)/s3.elf: $(cstart.o) $(TEST_DIR)/s3.o > > $(TEST_DIR)/pmu.elf: $(cstart.o) $(TEST_DIR)/pmu.o > > +$(TEST_DIR)/asyncpf.elf: $(cstart.o) $(TEST_DIR)/asyncpf.o > + > arch_clean: > $(RM) $(TEST_DIR)/*.o $(TEST_DIR)/*.flat $(TEST_DIR)/*.elf \ > $(TEST_DIR)/.*.d $(TEST_DIR)/lib/.*.d $(TEST_DIR)/lib/*.o > diff --git a/lib/x86/processor.h b/lib/x86/processor.h > index c7e1afb..e46d8d0 100644 > --- a/lib/x86/processor.h > +++ b/lib/x86/processor.h > @@ -302,4 +302,9 @@ static inline void invlpg(void *va) > { > asm volatile("invlpg (%0)" ::"r" (va) : "memory"); > } > + > +static inline void safe_halt(void) > +{ > + asm volatile("sti; hlt"); > +} > #endif > diff --git a/lib/x86/vm.c b/lib/x86/vm.c > index 550ec9b..71b70fd 100644 > --- a/lib/x86/vm.c > +++ b/lib/x86/vm.c > @@ -219,6 +219,11 @@ void *vmalloc(unsigned long size) > return mem; > } > > +uint64_t virt_to_phys_cr3(void *mem) > +{ > + return (get_pte(phys_to_virt(read_cr3()), mem)& PTE_ADDR) + ((ulong)mem& (PAGE_SIZE - 1)); > +} > + > void vfree(void *mem) > { > unsigned long size = ((unsigned long *)mem)[-1]; > diff --git a/lib/x86/vm.h b/lib/x86/vm.h > index 71ab4a8..3473f8d 100644 > --- a/lib/x86/vm.h > +++ b/lib/x86/vm.h > @@ -22,6 +22,7 @@ void vfree(void *mem); > void *vmap(unsigned long long phys, unsigned long size); > void *alloc_vpage(void); > void *alloc_vpages(ulong nr); > +uint64_t virt_to_phys_cr3(void *mem); > > void install_pte(unsigned long *cr3, > int pte_level, > diff --git a/x86/asyncpf.c b/x86/asyncpf.c > new file mode 100644 > index 0000000..62c0455 > --- /dev/null > +++ b/x86/asyncpf.c > @@ -0,0 +1,113 @@ > +/* > + * Async PF test. For the test to actually do anywathing it ineeds to be started ^^^^^^^^^^^^^^^^^^^^ typo? -- ----- Igor