[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 06 of 13] x86/mm/p2m: paging_p2m_ga_to_gfn() doesn't need so many arguments



# HG changeset patch
# User Tim Deegan <Tim.Deegan@xxxxxxxxxx>
# Date 1305302438 -3600
# Node ID fdcdfbf227bc11494ecdd820ba2fe6d1a4223b99
# Parent  b04da6168b3ae9de58a9fe1f4ec178479d5c6f71
x86/mm/p2m: paging_p2m_ga_to_gfn() doesn't need so many arguments

It has only one caller and is always called with p2m == hostp2m and mode
== hostmode.  Also, since it's only called from nested HAP code, remove
the check of paging_mode_hap().  Then rename it to reflect its new
interface.

Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>

diff -r b04da6168b3a -r fdcdfbf227bc xen/arch/x86/mm/hap/nested_hap.c
--- a/xen/arch/x86/mm/hap/nested_hap.c  Fri May 13 17:00:38 2011 +0100
+++ b/xen/arch/x86/mm/hap/nested_hap.c  Fri May 13 17:00:38 2011 +0100
@@ -143,17 +143,15 @@ nestedhap_walk_L0_p2m(struct p2m_domain 
  * L1_gpa. The result value tells what to do next.
  */
 static int
-nestedhap_walk_L1_p2m(struct vcpu *v, struct p2m_domain *p2m,
-    paddr_t L2_gpa, paddr_t *L1_gpa)
+nestedhap_walk_L1_p2m(struct vcpu *v, paddr_t L2_gpa, paddr_t *L1_gpa)
 {
     uint32_t pfec;
     unsigned long nested_cr3, gfn;
-    const struct paging_mode *mode = paging_get_hostmode(v);
     
     nested_cr3 = nhvm_vcpu_hostcr3(v);
 
-    /* walk the guest table */
-    gfn = paging_p2m_ga_to_gfn(v, p2m, mode, nested_cr3, L2_gpa, &pfec);
+    /* Walk the guest-supplied NPT table, just as if it were a pagetable */
+    gfn = paging_ga_to_gfn_cr3(v, nested_cr3, L2_gpa, &pfec);
 
     if ( gfn == INVALID_GFN ) 
         return NESTEDHVM_PAGEFAULT_INJECT;
@@ -178,10 +176,8 @@ nestedhvm_hap_nested_page_fault(struct v
     p2m = p2m_get_hostp2m(d); /* L0 p2m */
     nested_p2m = p2m_get_nestedp2m(v, nhvm_vcpu_hostcr3(v));
 
-    /* walk the L1 P2M table, note we have to pass p2m
-     * and not nested_p2m here or we fail the walk forever,
-     * otherwise. */
-    rv = nestedhap_walk_L1_p2m(v, p2m, L2_gpa, &L1_gpa);
+    /* walk the L1 P2M table */
+    rv = nestedhap_walk_L1_p2m(v, L2_gpa, &L1_gpa);
 
     /* let caller to handle these two cases */
     switch (rv) {
diff -r b04da6168b3a -r fdcdfbf227bc xen/include/asm-x86/paging.h
--- a/xen/include/asm-x86/paging.h      Fri May 13 17:00:38 2011 +0100
+++ b/xen/include/asm-x86/paging.h      Fri May 13 17:00:38 2011 +0100
@@ -265,26 +265,19 @@ unsigned long paging_gva_to_gfn(struct v
                                 unsigned long va,
                                 uint32_t *pfec);
 
-/* Translates a guest virtual address to guest physical address
- * where the specified cr3 is translated to host physical address
- * using the specified p2m table.
- * This allows to do page walks in the guest or even in the nested guest.
- * It returns the guest's gfn or the nested guest's gfn.
+/* Translate a guest address using a particular CR3 value.  This is used
+ * to by nested HAP code, to walk the guest-supplied NPT tables as if
+ * they were pagetables.
  * Use 'paddr_t' for the guest address so it won't overflow when
  * guest or nested guest is in 32bit PAE mode.
  */
-static inline unsigned long paging_p2m_ga_to_gfn(struct vcpu *v,
-                                                 struct p2m_domain *p2m,
-                                                 const struct paging_mode 
*mode,
+static inline unsigned long paging_ga_to_gfn_cr3(struct vcpu *v,
                                                  unsigned long cr3,
                                                  paddr_t ga,
                                                  uint32_t *pfec)
 {
-    if ( is_hvm_domain(v->domain) && paging_mode_hap(v->domain) )
-        return mode->p2m_ga_to_gfn(v, p2m, cr3, ga, pfec);
-
-    /* shadow paging */
-    return paging_gva_to_gfn(v, ga, pfec);
+    struct p2m_domain *p2m = v->domain->arch.p2m;
+    return paging_get_hostmode(v)->p2m_ga_to_gfn(v, p2m, cr3, ga, pfec);
 }
 
 /* Update all the things that are derived from the guest's CR3.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.