2011/5/30 MaoXiaoyun <tinnycloud@xxxxxxxxxxx>:
> Question might be simple but really confused me a long time.
> In my assumption, during VM running, the CPU sees the guest code
> so when it want to asscess memory, it sees the guest virtual adress(GVA), so
> it need to
> first translate to guest physical adress(GPA), and then host physical
> adress(HPA), and finally
> access the real memory address.
> Since GPA are always needs to translated to HPA, and p2m table only
> accessable in Xen for
> HVM guest, does this mean every memory access will need VMExit to Xen?
How the translation happens depends on the mode you're running in:
shadow or HAP.
As you know, in non-virtualization mode, the hardware will translate a
virtual address to a physical address by walking the page tables, and
placing the resulting translation in the TLB.
For fully virtualized VMs, as you say, the guest page tables are using
guest PFNs, which need to be translated into hardware pages (MFNs)
before they can be used.
In shadow mode, the hypervisor keeps a set of "shadow" pagetables,
which are translated versions of the guest pagetables. The hardware
walks these shadow page tables in exactly the same way as it does when
not virtualized. This means that Xen has to be involved whenever the
guest's *page tables* are changed, but not on every access to guest
In HAP mode, the hypervisor tells the hardware where to find the p2m
table, and the hardware does the translation itself -- walking Xen's
p2m table just as it walks the guest's page tables.
In neither case is Xen involved on every memory access.
Does that make sense?
Xen-devel mailing list