From: Jan Beulich <jbeulich@suse.com>
To: Kevin Negy <kevinnegy@gmail.com>
Cc: xen-devel@lists.xenproject.org
Subject: Re: How does shadow page table work during migration?
Date: Fri, 19 Feb 2021 17:36:25 +0100 [thread overview]
Message-ID: <4d3a6f57-31e3-3709-4ed1-a39b5fe55347@suse.com> (raw)
In-Reply-To: <CACZWC-qK_biKgyi+ZiXnsHRscAbK9pz=kncdBA25QYWY129HCQ@mail.gmail.com>
On 19.02.2021 17:10, Kevin Negy wrote:
> I'm trying to understand how the shadow page table works in Xen,
> specifically during live migration. My understanding is that after shadow
> paging is enabled (sh_enable_log_dirty() in
> xen/arch/x86/mm/shadow/common.c), a shadow page table is created, which is
> a complete copy of the current guest page table. Then the CR3 register is
> switched to use this shadow page table as the active table while the guest
> page table is stored elsewhere. The guest page table itself (and not the
> individual entries in the page table) is marked as read only so that any
> guest memory access that requires the page table will result in a page
> fault. These page faults happen and are trapped to the Xen hypervisor. Xen
> will then update the shadow page table to match what the guest sees on its
> page tables.
>
> Is this understanding correct?
Partly. For HVM, shadow mode (if so used) would be active already. For
PV, page tables would be read-only already. Log-dirty mode isn't after
page table modifications alone, but to notice _any_ page that gets
written to.
> If so, here is where I get confused. During the migration pre-copy phase,
> each pre-copy iteration reads the dirty bitmap (paging_log_dirty_op() in
> xen/arch/x86/mm/paging.c) and cleans it. This process seems to destroy all
> the shadow page tables of the domain with the call to shadow_blow_tables()
> in sh_clean_dirty_bitmap().
>
> How is the dirty bitmap related to shadow page tables?
Shadow page tables are the mechanism to populate the dirty bitmap.
> Why destroy the
> entire shadow page table if it is the only legitimate page table in CR3 for
> the domain?
Page tables will get re-populated again as the guest touches memory.
Blowing the tables is not the same as turning off shadow mode.
Jan
next prev parent reply other threads:[~2021-02-19 16:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-19 16:10 How does shadow page table work during migration? Kevin Negy
2021-02-19 16:36 ` Jan Beulich [this message]
2021-02-19 20:17 ` Andrew Cooper
2021-02-22 18:52 ` Kevin Negy
2021-02-23 0:23 ` Andrew Cooper
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=4d3a6f57-31e3-3709-4ed1-a39b5fe55347@suse.com \
--to=jbeulich@suse.com \
--cc=kevinnegy@gmail.com \
--cc=xen-devel@lists.xenproject.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).