From mboxrd@z Thu Jan 1 00:00:00 1970 From: Izik Eidus Subject: Re: What happens if I use get_user_pages() Date: Tue, 08 Jul 2008 23:40:16 -0500 Message-ID: <48744130.4000903@qumranet.com> References: <896ae46a0807072346o3240d1b4y91918491e9056837@mail.gmail.com> <20080708194120.GB8478@il.ibm.com> <896ae46a0807081404p32cf4e22wc9aaab6f111b42a@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Muli Ben-Yehuda , kvm@vger.kernel.org To: Arn Return-path: Received: from mis011-2.exch011.intermedia.net ([64.78.21.129]:49266 "EHLO mis011-2.exch011.intermedia.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750833AbYGIEkc (ORCPT ); Wed, 9 Jul 2008 00:40:32 -0400 In-Reply-To: <896ae46a0807081404p32cf4e22wc9aaab6f111b42a@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: =D7=A6=D7=99=D7=98=D7=95=D7=98 Arn: >>> If I use the kernel function "get_user_pages()" within a guest >>> kernel module, will this ensure that the guests pages are never >>> swapped out by the host ? Will it lock these pages in memory ? >>> (Has anyone tried this ? ) >>> =20 >> As Izik said, the answer is no. Is this the desirable outcome, or ar= e >> you trying to find a way for the guest to force the host to pin page= s >> in memory? If so, why? >> >> =20 > > Izik, Muli, thanks, > > Actually I don't want the guests pages to be pinned at all. My aim is > to do a timing check from within guest (guest kernel) to see if we ca= n > detect that the host has swapped out any of the guests pages. Without > the guest knowing. Its proving to be more difficult than I had > thought. Probably due to my lack of experience with kvm/linux > internals. > > My idea is to get the guest kernel to read byte from each of its page= s > (either all or a random set of pages) and do a timing check at each > read. A read from a page that has been swapped out by host should tak= e > much longer than a read done directly from memory. > > From previous emails on this list it seems that if I map a guest's > page into its kernelspace then that page will never be swapped out > (due to shadow pagetables). So now I'm stuck, any advice will be > appreciated. > =20 pages that will be inside the shadow page tables wont be swappable, you= =20 have to use mmu notifiers patch in order to have reible swapping. > thanks > Arn > =20