All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: David Matlack <dmatlack@google.com>, kvm list <kvm@vger.kernel.org>
Subject: Re: QUESTION: mmu.gva_to_gpa versus nested_mmu.gva_to_gpa
Date: Tue, 29 Dec 2015 00:25:29 +0100	[thread overview]
Message-ID: <5681C4E9.9090503@redhat.com> (raw)
In-Reply-To: <CALzav=fY9Gbv7WTeTvd4P_xLiFj=bnAQpvCUFdXMbFJ73Y5ZoA@mail.gmail.com>



On 28/12/2015 23:23, David Matlack wrote:
> I'm wondering if this comment in mmu.c:init_kvm_nested_mmu is correct (at
> least in the context of Nested EPT):
> 
> 4055         /*
> 4056          * Note that arch.mmu.gva_to_gpa translates l2_gva to l1_gpa. The
> 4057          * translation of l2_gpa to l1_gpa addresses is done using the
> 4058          * arch.nested_mmu.gva_to_gpa function. Basically the gva_to_gpa
> 4059          * functions between mmu and nested_mmu are swapped.
> 4060          */
> 
> nested_mmu.get_cr3 gets set to get_cr3, which I believe will return L2's cr3.
> In vmx.c:nested_ept_init_mmu_context, mmu.get_cr3 is set to
> nested_ept_get_cr3, which should be the root of EPT12. Given these get_cr3
> functions, shouldn't nested_mmu.gva_to_gpa translate l2_gva->l2_gpa and
> mmu.gva_to_gpa translate l2_gpa->l1_gpa?

Yes, it's correct.  It can be trivially seen by looking at
kvm_init_shadow_ept_mmu's usage of &vcpu->arch.mmu.  This is obviously a
l2_gpa to l1_gpa translation.

Whether the roles are swapped, depends on whether you think of
"nested_mmu" as "nested guest" or "nested virtualization"  nested_mmu is
the MMU for the nested guest, mmu is the MMU for the L1 guest and it's
the one that takes care of nested virtualization.

Paolo

  reply	other threads:[~2015-12-28 23:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-28 22:23 QUESTION: mmu.gva_to_gpa versus nested_mmu.gva_to_gpa David Matlack
2015-12-28 23:25 ` Paolo Bonzini [this message]
2015-12-29 16:37   ` David Matlack
2015-12-30  8:36     ` Paolo Bonzini
2015-12-30 15:31       ` David Matlack

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=5681C4E9.9090503@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=dmatlack@google.com \
    --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 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.