Why guest physical addresses are not the same as the corresponding host virtual addresses in QEMU/KVM? Thanks!

Paolo Bonzini pbonzini at redhat.com
Wed Oct 14 08:27:22 UTC 2020

On 13/10/20 22:36, harry harry wrote:
> Hi Paolo and Sean,
> Thanks much for your prompt replies and clear explanations.
> On Tue, Oct 13, 2020 at 2:43 AM Paolo Bonzini <pbonzini at redhat.com> wrote:
>> No, the logic to find the HPA with a given HVA is the same as the
>> hardware logic to translate HVA -> HPA.  That is it uses the host
>> "regular" page tables, not the nested page tables.
>> In order to translate GPA to HPA, instead, KVM does not use the nested
>> page tables.
> I am curious why KVM does not directly use GPAs as HVAs and leverage
> nested page tables to translate HVAs (i.e., GPAs) to HPAs?

GPAs and HVAs are different things.  In fact I'm not aware of any
hypervisor that uses HVA==GPA.  On 32-bit x86 systems HVAs are 32-bit
(obviously) but GPAs are 36-bit.

In the case of KVM, HVAs are controlled by the rest of Linux; for
example, when you do "mmap" to allocate guest memory you cannot ask the
OS to return the guest memory at the exact HVA that is needed by the
guest.  There could be something else at that HVA (or you don't want
anything at that HVA: GPA 0 is valid, but HVA 0 is the NULL pointer!).
There's also cases where the same memory appears in multiple places in
the guest memory map (aliasing).


More information about the libvir-list mailing list