LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Joerg Roedel" <joerg.roedel@amd.com>
To: "Izik Eidus" <izike@qumranet.com>
Cc: "Avi Kivity" <avi@qumranet.com>,
	kvm-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [kvm-devel] [PATCH 7/8] MMU: add TDP support to the KVM MMU
Date: Thu, 7 Feb 2008 14:50:48 +0100	[thread overview]
Message-ID: <20080207135048.GF6960@amd.com> (raw)
In-Reply-To: <47AB0737.2000206@qumranet.com>

On Thu, Feb 07, 2008 at 03:27:19PM +0200, Izik Eidus wrote:
> Joerg Roedel wrote:
> >This patch contains the changes to the KVM MMU necessary for support of the
> >Nested Paging feature in AMD Barcelona and Phenom Processors.
> >  
> 
> good patch, it look like things will be very fixable with it
> 
> >Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
> >---
> > arch/x86/kvm/mmu.c |   79 ++++++++++++++++++++++++++++++++++++++++++++++++++--
> > arch/x86/kvm/mmu.h |    6 ++++
> > 2 files changed, 82 insertions(+), 3 deletions(-)
> >
> >diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> >index 5e76963..5304d55 100644
> >--- a/arch/x86/kvm/mmu.c
> >+++ b/arch/x86/kvm/mmu.c
> >@@ -1081,6 +1081,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
> > 	int i;
> > 	gfn_t root_gfn;
> > 	struct kvm_mmu_page *sp;
> >+	int metaphysical = 0;
> >  	root_gfn = vcpu->arch.cr3 >> PAGE_SHIFT;
> > @@ -1089,14 +1090,20 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
> > 		hpa_t root = vcpu->arch.mmu.root_hpa;
> >  		ASSERT(!VALID_PAGE(root));
> >+		if (tdp_enabled)
> >+			metaphysical = 1;
> > 		sp = kvm_mmu_get_page(vcpu, root_gfn, 0,
> >-				      PT64_ROOT_LEVEL, 0, ACC_ALL, NULL, NULL);
> >+				      PT64_ROOT_LEVEL, metaphysical,
> >+				      ACC_ALL, NULL, NULL);
> > 		root = __pa(sp->spt);
> > 		++sp->root_count;
> > 		vcpu->arch.mmu.root_hpa = root;
> > 		return;
> > 	}
> > #endif
> >+	metaphysical = !is_paging(vcpu);
> >+	if (tdp_enabled)
> >+		metaphysical = 1;
> > 	for (i = 0; i < 4; ++i) {
> > 		hpa_t root = vcpu->arch.mmu.pae_root[i];
> > @@ -1110,7 +1117,7 @@ static void mmu_alloc_roots(struct kvm_vcpu *vcpu)
> > 		} else if (vcpu->arch.mmu.root_level == 0)
> > 			root_gfn = 0;
> > 		sp = kvm_mmu_get_page(vcpu, root_gfn, i << 30,
> >-				      PT32_ROOT_LEVEL, !is_paging(vcpu),
> >+				      PT32_ROOT_LEVEL, metaphysical,
> > 				      ACC_ALL, NULL, NULL);
> > 		root = __pa(sp->spt);
> > 		++sp->root_count;
> >@@ -1144,6 +1151,36 @@ static int nonpaging_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
> > 			     error_code & PFERR_WRITE_MASK, gfn);
> > }
> > +static int tdp_page_fault(struct kvm_vcpu *vcpu, gva_t gpa,
> >+				u32 error_code)
> >  
> 
> you probably mean gpa_t ?

Yes. But the function is assigned to a function pointer. And the type of
that pointer expects gva_t there. So I named the parameter gpa to
describe that a guest physical address is meant there.

> >+{
> >+	struct page *page;
> >+	int r;
> >+
> >+	ASSERT(vcpu);
> >+	ASSERT(VALID_PAGE(vcpu->arch.mmu.root_hpa));
> >+
> >+	r = mmu_topup_memory_caches(vcpu);
> >+	if (r)
> >+		return r;
> >+
> >+	down_read(&current->mm->mmap_sem);
> >+	page = gfn_to_page(vcpu->kvm, gpa >> PAGE_SHIFT);
> >+	if (is_error_page(page)) {
> >+		kvm_release_page_clean(page);
> >+		up_read(&current->mm->mmap_sem);
> >+		return 1;
> >+	}
> >  
> 
> i dont know if it worth checking it here,
> in the worth case we will map the error page and the host will be safe

Looking at the nonpaging_map function it is the right place to check for
the error page.

Joerg Roedel

-- 
           |           AMD Saxony Limited Liability Company & Co. KG
 Operating |         Wilschdorfer Landstr. 101, 01109 Dresden, Germany
 System    |                  Register Court Dresden: HRA 4896
 Research  |              General Partner authorized to represent:
 Center    |             AMD Saxony LLC (Wilmington, Delaware, US)
           | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy



  reply	other threads:[~2008-02-07 13:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-07 12:47 KVM: add support for SVM Nested Paging Joerg Roedel
2008-02-07 12:47 ` [PATCH 1/8] SVM: move feature detection to hardware setup code Joerg Roedel
2008-02-07 12:47 ` [PATCH 2/8] SVM: add detection of Nested Paging feature Joerg Roedel
2008-02-07 12:47 ` [PATCH 3/8] SVM: add module parameter to disable Nested Paging Joerg Roedel
2008-02-07 12:47 ` [PATCH 4/8] X86: export information about NPT to generic x86 code Joerg Roedel
2008-02-07 12:47 ` [PATCH 5/8] MMU: make the __nonpaging_map function generic Joerg Roedel
2008-02-07 12:47 ` [PATCH 6/8] X86: export the load_pdptrs() function to modules Joerg Roedel
2008-02-07 12:47 ` [PATCH 7/8] MMU: add TDP support to the KVM MMU Joerg Roedel
2008-02-07 13:27   ` [kvm-devel] " Izik Eidus
2008-02-07 13:50     ` Joerg Roedel [this message]
2008-02-07 14:04       ` Izik Eidus
2008-02-07 12:47 ` [PATCH 8/8] SVM: add support for Nested Paging Joerg Roedel
2008-02-10 12:03 ` [kvm-devel] KVM: add support for SVM " 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=20080207135048.GF6960@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=avi@qumranet.com \
    --cc=izike@qumranet.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [kvm-devel] [PATCH 7/8] MMU: add TDP support to the KVM MMU' \
    /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

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).