aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
authorNadav Har'El <nyh@il.ibm.com>2013-08-05 04:07:16 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2013-08-07 09:57:41 -0400
commit155a97a3d7c78b46cef6f1a973c831bc5a4f82bb (patch)
treeebaee41d8a4c94c06d09072490f921e4485a509d /arch/x86/kvm/mmu.c
parent25d92081ae2ff9858fa733621ef8e91d30fec9d0 (diff)
nEPT: MMU context for nested EPT
KVM's existing shadow MMU code already supports nested TDP. To use it, we need to set up a new "MMU context" for nested EPT, and create a few callbacks for it (nested_ept_*()). This context should also use the EPT versions of the page table access functions (defined in the previous patch). Then, we need to switch back and forth between this nested context and the regular MMU context when switching between L1 and L2 (when L1 runs this L2 with EPT). Reviewed-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Signed-off-by: Nadav Har'El <nyh@il.ibm.com> Signed-off-by: Jun Nakajima <jun.nakajima@intel.com> Signed-off-by: Xinhao Xu <xinhao.xu@intel.com> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com> Signed-off-by: Gleb Natapov <gleb@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index a215c41b5176..992fde984e25 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -3795,6 +3795,33 @@ int kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
3795} 3795}
3796EXPORT_SYMBOL_GPL(kvm_init_shadow_mmu); 3796EXPORT_SYMBOL_GPL(kvm_init_shadow_mmu);
3797 3797
3798int kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context,
3799 bool execonly)
3800{
3801 ASSERT(vcpu);
3802 ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
3803
3804 context->shadow_root_level = kvm_x86_ops->get_tdp_level();
3805
3806 context->nx = true;
3807 context->new_cr3 = paging_new_cr3;
3808 context->page_fault = ept_page_fault;
3809 context->gva_to_gpa = ept_gva_to_gpa;
3810 context->sync_page = ept_sync_page;
3811 context->invlpg = ept_invlpg;
3812 context->update_pte = ept_update_pte;
3813 context->free = paging_free;
3814 context->root_level = context->shadow_root_level;
3815 context->root_hpa = INVALID_PAGE;
3816 context->direct_map = false;
3817
3818 update_permission_bitmask(vcpu, context, true);
3819 reset_rsvds_bits_mask_ept(vcpu, context, execonly);
3820
3821 return 0;
3822}
3823EXPORT_SYMBOL_GPL(kvm_init_shadow_ept_mmu);
3824
3798static int init_kvm_softmmu(struct kvm_vcpu *vcpu) 3825static int init_kvm_softmmu(struct kvm_vcpu *vcpu)
3799{ 3826{
3800 int r = kvm_init_shadow_mmu(vcpu, vcpu->arch.walk_mmu); 3827 int r = kvm_init_shadow_mmu(vcpu, vcpu->arch.walk_mmu);