kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: "Nadav Har'El" <nyh@math.technion.ac.il>
Cc: kvm@vger.kernel.org, "Roedel, Joerg" <Joerg.Roedel@amd.com>,
	owasserm@redhat.com, abelg@il.ibm.com
Subject: Re: [PATCH 02/10] nEPT: MMU context for nested EPT
Date: Thu, 10 Nov 2011 17:19:01 +0200	[thread overview]
Message-ID: <4EBBEB65.8050600@redhat.com> (raw)
In-Reply-To: <20111110144027.GB3327@fermat.math.technion.ac.il>

On 11/10/2011 04:40 PM, Nadav Har'El wrote:
> On Thu, Nov 10, 2011, Avi Kivity wrote about "Re: [PATCH 02/10] nEPT: MMU context for nested EPT":
> > > +static int nested_ept_init_mmu_context(struct kvm_vcpu *vcpu)
> > > +{
> > > +	int r = kvm_init_shadow_mmu(vcpu, &vcpu->arch.mmu);
> >...
> > > +	vcpu->arch.walk_mmu              = &vcpu->arch.nested_mmu;
> >...
> > 
> > kvm_init_shadow_mmu() will cause ->page_fault to be set to something
> > like paging64_page_fault(), which is geared to reading EPT ptes.  How
> > does this work?

s/EPT/ia32/

>
> Hi,
>
> I'm afraid I didn't understand the problem.
>
> Nested EPT's merging of two EPT tables (EPT01 and EPT12) works just like
> normal shadow page tables' merging of two CR3s (host cr3 and guest cr3):
>
> When L0 receives a "page fault" from L2 (actually an EPT violation - real
> guest #PF don't cause exits), L0 first looks it up in the shadowed table,
> which is basically EPT12. If the address is there, L0 handles the fault itself
> (updating the shadow EPT table, EPT02 using the normal shadow pte building
> code). But if the address wasn't in the shadowed page table (EPT12),
> mmu->inject_page_fault() is called, which in our case actually causes L1 to
> get an EPT-violation (not #PF - see kvm_propagate_fault()).
>
> Please note that all this logic is shared with the existing nested NPT
> code (which itself shared most of the code with the preexisting shadow
> page tables code). All this code sharing makes it really difficult to
> understand at first glance why the code is really working, but once you
> understood why one of these cases works, the others work similarly.
> And it does in fact work - in typical cases which I tried, at least.
>
> If you still think I'm missing something, I won't be entirely surprised
> ( :-) ), so let me know.

This is all correct, but the code in question parses the EPT12 table
using the ia32 page table format.  They're sufficiently similar so that
it works, but it isn't correct.

Bit 0: EPT readable, ia32 present
Bit 1: Writable; ia32 meaning dependent on cr0.wp
Bit 2: EPT executable, ia32 user (so, this implementation will interpret
a non-executable EPT mapping, if someone could find a use for it, as a
L2 kernel only mapping)
Bits 3-5: EPT memory type, ia32 PWT/PCD (similar but different),
Accessed bit
Bit 6: EPT Ignore PAT, ia32 dirty
Bit 7: EPT ignored, ia32 PAT
Bit 8: EPT ignored, ia32 global
Bit 63: EPT ignored, ia32 NX

walk_addr() will also write to bits 6/7, which the L1 won't expect.

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2011-11-10 15:19 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-10  9:57 [PATCH 0/10] nEPT: Nested EPT support for Nested VMX Nadav Har'El
2011-11-10  9:58 ` [PATCH 01/10] nEPT: Module option Nadav Har'El
2011-11-10 12:23   ` Avi Kivity
2011-11-10 14:21     ` Nadav Har'El
2011-11-10 14:38       ` Avi Kivity
2011-11-10 15:14         ` Nadav Har'El
2011-11-10 15:21           ` Avi Kivity
2011-11-10  9:58 ` [PATCH 02/10] nEPT: MMU context for nested EPT Nadav Har'El
2011-11-10 10:31   ` Avi Kivity
2011-11-10 12:49   ` Avi Kivity
2011-11-10 14:40     ` Nadav Har'El
2011-11-10 15:19       ` Avi Kivity [this message]
2011-11-10 20:05         ` Nadav Har'El
2011-11-12 10:39           ` Avi Kivity
2011-11-12 21:37             ` Nadav Har'El
2011-11-13  9:10               ` Avi Kivity
2011-11-13 11:30               ` Orit Wasserman
2011-11-13 14:32                 ` Avi Kivity
2011-11-13 18:26                   ` Orit Wasserman
2011-11-14  8:25                     ` Avi Kivity
2011-12-08 15:21                       ` Nadav Har'El
2011-12-06 12:40                   ` Nadav Har'El
2011-12-06 13:07                     ` Avi Kivity
2011-11-23 15:06                 ` Nadav Har'El
2011-11-23 15:44                   ` Nadav Har'El
2011-11-24 13:36                     ` Avi Kivity
2011-12-07  9:06                 ` Nadav Har'El
2011-12-07 10:10                   ` Avi Kivity
2011-11-10  9:59 ` [PATCH 03/10] nEPT: Fix cr3 handling in nested exit and entry Nadav Har'El
2011-11-10  9:59 ` [PATCH 04/10] nEPT: Fix page table format in nested EPT Nadav Har'El
2011-11-10 10:37   ` Avi Kivity
2011-11-10 11:03     ` Nadav Har'El
2011-11-10 12:21       ` Avi Kivity
2011-11-10 12:50         ` Avi Kivity
2011-11-10 13:07   ` Orit Wasserman
2011-11-10 10:00 ` [PATCH 05/10] nEPT: Fix wrong test in kvm_set_cr3 Nadav Har'El
2011-11-10 10:00 ` [PATCH 06/10] nEPT: Some additional comments Nadav Har'El
2011-11-10 10:01 ` [PATCH 07/10] nEPT: Advertise EPT to L1 Nadav Har'El
2011-11-10 10:01 ` [PATCH 08/10] nEPT: Nested INVEPT Nadav Har'El
2011-11-10 12:17   ` Avi Kivity
2011-12-11 14:24     ` Nadav Har'El
2011-12-11 14:37       ` Avi Kivity
2011-11-10 10:02 ` [PATCH 09/10] nEPT: Documentation Nadav Har'El
2011-11-10 10:02 ` [PATCH 10/10] nEPT: Miscelleneous cleanups Nadav Har'El
2011-11-10 12:26 ` [PATCH 0/10] nEPT: Nested EPT support for Nested VMX Avi Kivity
2011-11-13  8:52   ` Nadav Har'El
2011-11-13  9:21     ` Avi Kivity
2011-12-12 11:37       ` Nadav Har'El
2011-12-12 13:04         ` Avi Kivity

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=4EBBEB65.8050600@redhat.com \
    --to=avi@redhat.com \
    --cc=Joerg.Roedel@amd.com \
    --cc=abelg@il.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=nyh@math.technion.ac.il \
    --cc=owasserm@redhat.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 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).