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

[Xen-changelog] [xen-unstable] x86/mm: remove 'p2m_guest' lookup type.



# HG changeset patch
# User Tim Deegan <tim@xxxxxxx>
# Date 1331811671 0
# Node ID 7a439281b8ee5aef0b495e191fab7c8d0e46e4be
# Parent  da72de35e4a271f1faacd8e712c284ed8cd846a8
x86/mm: remove 'p2m_guest' lookup type.

It was neither consistently used by callers nor correctly handled by the
lookup code.  Instead, treat any lookup that might allocate or unshare
memory as a 'guest' lookup for the purposes of:
 - detecting the highest pod gfn populated; and
 - crashing the guest on access to a broken page
which were the only things this was used for.

Signed-off-by: Tim Deegan <tim@xxxxxxx>
Committed-by: Tim Deegan <tim@xxxxxxx>
---


diff -r da72de35e4a2 -r 7a439281b8ee xen/arch/x86/hvm/emulate.c
--- a/xen/arch/x86/hvm/emulate.c        Thu Mar 15 11:40:51 2012 +0000
+++ b/xen/arch/x86/hvm/emulate.c        Thu Mar 15 11:41:11 2012 +0000
@@ -716,7 +716,7 @@
 
     get_two_gfns(current->domain, sgpa >> PAGE_SHIFT, &sp2mt, NULL, NULL,
                  current->domain, dgpa >> PAGE_SHIFT, &dp2mt, NULL, NULL,
-                 p2m_guest, &tg);
+                 p2m_alloc, &tg);
 
     if ( !p2m_is_ram(sp2mt) && !p2m_is_grant(sp2mt) )
     {
diff -r da72de35e4a2 -r 7a439281b8ee xen/arch/x86/hvm/hvm.c
--- a/xen/arch/x86/hvm/hvm.c    Thu Mar 15 11:40:51 2012 +0000
+++ b/xen/arch/x86/hvm/hvm.c    Thu Mar 15 11:41:11 2012 +0000
@@ -1269,7 +1269,8 @@
     }
 
     p2m = p2m_get_hostp2m(v->domain);
-    mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, p2m_guest, NULL);
+    mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, 
+                              access_w ? p2m_unshare : p2m_alloc, NULL);
 
     /* Check access permissions first, then handle faults */
     if ( mfn_x(mfn) != INVALID_MFN )
diff -r da72de35e4a2 -r 7a439281b8ee xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c        Thu Mar 15 11:40:51 2012 +0000
+++ b/xen/arch/x86/hvm/svm/svm.c        Thu Mar 15 11:41:11 2012 +0000
@@ -1287,7 +1287,7 @@
     if ( p2m == NULL )
         p2m = p2m_get_p2m(v);
     /* Everything else is an error. */
-    mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, p2m_guest, NULL);
+    mfn = get_gfn_type_access(p2m, gfn, &p2mt, &p2ma, p2m_query, NULL);
     __put_gfn(p2m, gfn);
     gdprintk(XENLOG_ERR,
          "SVM violation gpa %#"PRIpaddr", mfn %#lx, type %i\n",
diff -r da72de35e4a2 -r 7a439281b8ee xen/arch/x86/mm/p2m-pod.c
--- a/xen/arch/x86/mm/p2m-pod.c Thu Mar 15 11:40:51 2012 +0000
+++ b/xen/arch/x86/mm/p2m-pod.c Thu Mar 15 11:41:11 2012 +0000
@@ -1023,7 +1023,7 @@
     }
 
     /* Keep track of the highest gfn demand-populated by a guest fault */
-    if ( q == p2m_guest && gfn > p2m->pod.max_guest )
+    if ( gfn > p2m->pod.max_guest )
         p2m->pod.max_guest = gfn;
 
     if ( p2m->pod.count == 0 )
diff -r da72de35e4a2 -r 7a439281b8ee xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c     Thu Mar 15 11:40:51 2012 +0000
+++ b/xen/arch/x86/mm/p2m.c     Thu Mar 15 11:41:11 2012 +0000
@@ -183,7 +183,7 @@
     {
         /* Return invalid_mfn to avoid caller's access */
         mfn = _mfn(INVALID_MFN);
-        if (q == p2m_guest)
+        if (q != p2m_query)
             domain_crash(p2m->domain);
     }
 #endif
diff -r da72de35e4a2 -r 7a439281b8ee xen/arch/x86/mm/shadow/multi.c
--- a/xen/arch/x86/mm/shadow/multi.c    Thu Mar 15 11:40:51 2012 +0000
+++ b/xen/arch/x86/mm/shadow/multi.c    Thu Mar 15 11:41:11 2012 +0000
@@ -3189,7 +3189,7 @@
 
     /* What mfn is the guest trying to access? */
     gfn = guest_l1e_get_gfn(gw.l1e);
-    gmfn = get_gfn_guest(d, gfn, &p2mt);
+    gmfn = get_gfn(d, gfn, &p2mt);
 
     if ( shadow_mode_refcounts(d) && 
          ((!p2m_is_valid(p2mt) && !p2m_is_grant(p2mt)) ||
@@ -4840,7 +4840,7 @@
 
     /* Translate the GFN to an MFN */
     ASSERT(!paging_locked_by_me(v->domain));
-    mfn = get_gfn_guest(v->domain, _gfn(gfn), &p2mt);
+    mfn = get_gfn(v->domain, _gfn(gfn), &p2mt);
         
     if ( p2m_is_readonly(p2mt) )
     {
diff -r da72de35e4a2 -r 7a439281b8ee xen/arch/x86/mm/shadow/types.h
--- a/xen/arch/x86/mm/shadow/types.h    Thu Mar 15 11:40:51 2012 +0000
+++ b/xen/arch/x86/mm/shadow/types.h    Thu Mar 15 11:41:11 2012 +0000
@@ -194,8 +194,6 @@
  /* Override get_gfn to work with gfn_t */
 #undef get_gfn_query
 #define get_gfn_query(d, g, t) get_gfn_type((d), gfn_x(g), (t), p2m_query)
-#undef get_gfn_guest
-#define get_gfn_guest(d, g, t) get_gfn_type((d), gfn_x(g), (t), p2m_guest)
 
 /* The shadow types needed for the various levels. */
 
diff -r da72de35e4a2 -r 7a439281b8ee xen/include/asm-x86/p2m.h
--- a/xen/include/asm-x86/p2m.h Thu Mar 15 11:40:51 2012 +0000
+++ b/xen/include/asm-x86/p2m.h Thu Mar 15 11:41:11 2012 +0000
@@ -116,11 +116,11 @@
     /* NOTE: Assumed to be only 4 bits right now */
 } p2m_access_t;
 
+/* Modifiers to the query */
 typedef enum {
     p2m_query,              /* Do not populate a PoD entries      */
     p2m_alloc,              /* Automatically populate PoD entries */
     p2m_unshare,            /* Break c-o-w sharing; implies alloc */
-    p2m_guest,              /* Guest demand-fault; implies alloc  */
 } p2m_query_t;
 
 /* We use bitmaps and maks to handle groups of types */
@@ -334,7 +334,6 @@
  * lock held. */
 #define get_gfn(d, g, t)         get_gfn_type((d), (g), (t), p2m_alloc)
 #define get_gfn_query(d, g, t)   get_gfn_type((d), (g), (t), p2m_query)
-#define get_gfn_guest(d, g, t)   get_gfn_type((d), (g), (t), p2m_guest)
 #define get_gfn_unshare(d, g, t) get_gfn_type((d), (g), (t), p2m_unshare)
 
 /* Compatibility function exporting the old untyped interface */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

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