All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gianluca Guida <gianluca.guida@eu.citrix.com>
To: Jui-Hao Chiang <windtracekimo@gmail.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: Consult some concepts about shadow paging mechanism
Date: Fri, 24 Apr 2009 15:32:09 +0200	[thread overview]
Message-ID: <f8877f640904240632qaf5cff9v181e20d279f2cbc1@mail.gmail.com> (raw)
In-Reply-To: <52cf60ee0904232123n6e38711fjbd8fe084c464b059@mail.gmail.com>

On Fri, Apr 24, 2009 at 6:23 AM, Jui-Hao Chiang <windtracekimo@gmail.com> wrote:
> I have some additional doubts as the following:
> (1) For normal data page, in order to propagate the Dirty or Access
> bit from SPTE to GPTE, the hypervisor needs to set Read-Only in the
> SPTE. When the write page fault of this data page comes, hypervisor
> can propagate the Dirty or Access bit to GPTE and set it to R/W. My
> question is when does the hypervisor make it Read-Only again? Is there
> any place inside the source code you can point out?

What happens is this: the guest has to clear the dirty/accessed bit
and then flush the tlb (or invlpg the entry).
If the pagetable is mapped read only (as in levels > 1) the write to
the pagetable will trigger the emulator that will update the entry.
Otherwhise (if the page is out of sync, which means a writable guest
pagetable, and this happens when it's an L1) the flushtlb will do the
job of updating the shadow entry.

Look at how sh_propagate function works and when it get called. It's
what you're looking for.

> (2) How many shadow pages are maintained for each guest domain? If the
> hypervisor keep only one shadow page table for the active process in
> each guest domain, then during the guest context-switch, it might
> erase the entire shadow page table, and re-construct it for the new
> process, which seems a lot of overhead. I have checked the
> sh_update_cr3(), but not sure of the detailed mechanism.

There's a pool of shadow memory that get reused in a pseudo-LRU
manner. Across cr3 switch toplevel pagetables are kept in memory, and
unshadowed when evicted by the allocator or when other things happens,
mostly based on heuristic and reference counting.

Thanks,
Gianluca

-- 
It was a type of people I did not know, I found them very strange and
they did not inspire confidence at all. Later I learned that I had been
introduced to electronic engineers.
                                                  E. W. Dijkstra

  reply	other threads:[~2009-04-24 13:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22 13:14 Consult some concepts about shadow paging mechanism Jui-Hao Chiang
2009-04-23 15:46 ` Gianluca Guida
2009-04-24  4:23   ` Jui-Hao Chiang
2009-04-24 13:32     ` Gianluca Guida [this message]
2009-05-02  2:47       ` Jui-Hao Chiang
2009-05-03 13:39         ` Jui-Hao Chiang
2009-05-05  8:37           ` Tim Deegan
2009-05-05  9:15           ` Gianluca Guida

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=f8877f640904240632qaf5cff9v181e20d279f2cbc1@mail.gmail.com \
    --to=gianluca.guida@eu.citrix.com \
    --cc=windtracekimo@gmail.com \
    --cc=xen-devel@lists.xensource.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.