public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* unit tests and get_user_pages_ptes_fast()
@ 2010-10-04  9:35 Avi Kivity
  2010-10-04 13:40 ` Andrea Arcangeli
  0 siblings, 1 reply; 9+ messages in thread
From: Avi Kivity @ 2010-10-04  9:35 UTC (permalink / raw)
  To: KVM list; +Cc: Andrea Arcangeli

  During the last kvm forum, I described a unit test framework that can 
help test the kvm APIs.  Briefly, it starts a process in host userspace, 
which sets up a memory slot mapping gpa 0:3G to hva 0:3G.  It then sets 
up guest registers for unpaged protected mode (or paged protected mode 
with 1:1 mapping).  The effect is that we have a 1:1 gva->hva 
translation, and can use KVM_RUN to run host code in guest mode.

There is a snag however.  kvm calls get_user_pages_fast(.write = 1), and 
the host process maps its code pages read-only.

The way I'd like to work around this is to map read-only accesses to 
read-only pages as read-only.  This also prevents ksm cow pages from 
being broken by read accesses.  It can also be used to get the page size 
for transparent huge pages (and later hugetlbfs too).

So, for a read fault we do:

   pte_t pte;
   get_user_pages_ptes_fast(..., page, &pte, 1, .write = 0)
   ...
   if (pte_transhuge(pte)) // or however it's called
       ...
   ...
   if (pte_write(pte))
         map writeable
   else
         map readonly

Any snags?  or alternatives?

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-10-05 14:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-04  9:35 unit tests and get_user_pages_ptes_fast() Avi Kivity
2010-10-04 13:40 ` Andrea Arcangeli
2010-10-04 23:59   ` Marcelo Tosatti
2010-10-05  7:36     ` Avi Kivity
2010-10-05  9:22       ` Marcelo Tosatti
2010-10-05 14:15         ` Andrea Arcangeli
2010-10-05 14:25           ` Avi Kivity
2010-10-05 14:32             ` Andrea Arcangeli
2010-10-05 14:36               ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox