kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: "\"陳韋任 (Wei-Ren Chen)\"" <chenwj@iis.sinica.edu.tw>
Cc: kvm@vger.kernel.org
Subject: Re: How KVM sync guest page table with corresponding shadow page table?
Date: Tue, 14 Aug 2012 17:23:01 +0800	[thread overview]
Message-ID: <502A18F5.1050609@linux.vnet.ibm.com> (raw)
In-Reply-To: <20120814035457.GB57133@cs.nctu.edu.tw>

On 08/14/2012 11:54 AM, 陳韋任 (Wei-Ren Chen) wrote:
> Hi all,
> 
>   If guest modify its guest page table entry, KVM should trap that event,
> emulate what guest trying to do, and sync with the corresponding shadow
> page table entry. Is my understanding correct? If so, does KVM use
> something like mprotect to make guest page table read-only, or there is
> another way? 

It is controlled by shadow page table, guest-page-tables are write-protected
on shadow pages (the W bit on PTE is cleared).

There has a special case, called unsync shadow page, if the page only used
as guest page structure on the lowest level (level = 1), we allow it to be
writable, it will be sync-ed when the guest flush the tlb (e.g: CR3 reload,
invlpg...) because according to x86 TLB rules, it needs to flush tlb to apply
the change.

> Besides, how KVM know what guest try to write into the
> guest page table entry?

In the normal case, guest writes its page table will generate #PF since the
page is write-protected as we mention above.

For the special case (unsync shadow page), we can happily write its page
table without #PF.


  reply	other threads:[~2012-08-14  9:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-14  3:54 How KVM sync guest page table with corresponding shadow page table? 陳韋任 (Wei-Ren Chen)
2012-08-14  9:23 ` Xiao Guangrong [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-08-24  7:29 陳韋任 (Wei-Ren Chen)
2012-08-30 10:44 ` Xiao Guangrong

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=502A18F5.1050609@linux.vnet.ibm.com \
    --to=xiaoguangrong@linux.vnet.ibm.com \
    --cc=chenwj@iis.sinica.edu.tw \
    --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;
as well as URLs for NNTP newsgroup(s).