From: Avi Kivity <avi@redhat.com>
To: KVM list <kvm@vger.kernel.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Subject: unit tests and get_user_pages_ptes_fast()
Date: Mon, 04 Oct 2010 11:35:28 +0200 [thread overview]
Message-ID: <4CA99FE0.7070709@redhat.com> (raw)
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
next reply other threads:[~2010-10-04 9:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-04 9:35 Avi Kivity [this message]
2010-10-04 13:40 ` unit tests and get_user_pages_ptes_fast() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CA99FE0.7070709@redhat.com \
--to=avi@redhat.com \
--cc=aarcange@redhat.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox