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

[Xen-devel] [PATCH 08/20] x86/shadow: Alter OOS functions to take a domain



Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Tim Deegan <tim@xxxxxxx>
---
 xen/arch/x86/mm/shadow/common.c  |   23 ++++++++++++-----------
 xen/arch/x86/mm/shadow/multi.c   |   19 ++++++++++++-------
 xen/arch/x86/mm/shadow/private.h |    6 +++---
 3 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index bdb19fb..6945dfe 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -603,13 +603,13 @@ static inline int oos_fixup_flush_gmfn(struct vcpu *v, 
mfn_t gmfn,
     return 1;
 }
 
-void oos_fixup_add(struct vcpu *v, mfn_t gmfn,
+void oos_fixup_add(struct domain *d, mfn_t gmfn,
                    mfn_t smfn,  unsigned long off)
 {
     int idx, next;
     mfn_t *oos;
     struct oos_fixup *oos_fixup;
-    struct domain *d = v->domain;
+    struct vcpu *v;
 
     perfc_incr(shadow_oos_fixup_add);
 
@@ -788,13 +788,13 @@ static void oos_hash_add(struct vcpu *v, mfn_t gmfn)
 }
 
 /* Remove an MFN from the list of out-of-sync guest pagetables */
-static void oos_hash_remove(struct vcpu *v, mfn_t gmfn)
+static void oos_hash_remove(struct domain *d, mfn_t gmfn)
 {
     int idx;
     mfn_t *oos;
-    struct domain *d = v->domain;
+    struct vcpu *v;
 
-    SHADOW_PRINTK("%pv gmfn %lx\n", v, mfn_x(gmfn));
+    SHADOW_PRINTK("d%d gmfn %lx\n", d->domain_id, mfn_x(gmfn));
 
     for_each_vcpu(d, v)
     {
@@ -813,12 +813,12 @@ static void oos_hash_remove(struct vcpu *v, mfn_t gmfn)
     BUG();
 }
 
-mfn_t oos_snapshot_lookup(struct vcpu *v, mfn_t gmfn)
+mfn_t oos_snapshot_lookup(struct domain *d, mfn_t gmfn)
 {
     int idx;
     mfn_t *oos;
     mfn_t *oos_snapshot;
-    struct domain *d = v->domain;
+    struct vcpu *v;
 
     for_each_vcpu(d, v)
     {
@@ -839,13 +839,13 @@ mfn_t oos_snapshot_lookup(struct vcpu *v, mfn_t gmfn)
 }
 
 /* Pull a single guest page back into sync */
-void sh_resync(struct vcpu *v, mfn_t gmfn)
+void sh_resync(struct domain *d, mfn_t gmfn)
 {
     int idx;
     mfn_t *oos;
     mfn_t *oos_snapshot;
     struct oos_fixup *oos_fixup;
-    struct domain *d = v->domain;
+    struct vcpu *v;
 
     for_each_vcpu(d, v)
     {
@@ -1000,7 +1000,7 @@ void shadow_promote(struct vcpu *v, mfn_t gmfn, unsigned 
int type)
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
     /* Is the page already shadowed and out of sync? */
     if ( page_is_out_of_sync(page) )
-        sh_resync(v, gmfn);
+        sh_resync(d, gmfn);
 #endif
 
     /* We should never try to promote a gmfn that has writeable mappings */
@@ -1019,6 +1019,7 @@ void shadow_promote(struct vcpu *v, mfn_t gmfn, unsigned 
int type)
 
 void shadow_demote(struct vcpu *v, mfn_t gmfn, u32 type)
 {
+    struct domain *d = v->domain;
     struct page_info *page = mfn_to_page(gmfn);
 
     ASSERT(test_bit(_PGC_page_table, &page->count_info));
@@ -1032,7 +1033,7 @@ void shadow_demote(struct vcpu *v, mfn_t gmfn, u32 type)
         /* Was the page out of sync? */
         if ( page_is_out_of_sync(page) )
         {
-            oos_hash_remove(v, gmfn);
+            oos_hash_remove(d, gmfn);
         }
 #endif
         clear_bit(_PGC_page_table, &page->count_info);
diff --git a/xen/arch/x86/mm/shadow/multi.c b/xen/arch/x86/mm/shadow/multi.c
index ea3b520..82759a6 100644
--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -278,6 +278,11 @@ shadow_check_gl1e(struct vcpu *v, walk_t *gw)
 static inline uint32_t
 gw_remove_write_accesses(struct vcpu *v, unsigned long va, walk_t *gw)
 {
+#if GUEST_PAGING_LEVELS >= 3 /* PAE or 64... */
+#if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
+    struct domain *d = v->domain;
+#endif
+#endif
     uint32_t rc = 0;
 
 #if GUEST_PAGING_LEVELS >= 3 /* PAE or 64... */
@@ -285,7 +290,7 @@ gw_remove_write_accesses(struct vcpu *v, unsigned long va, 
walk_t *gw)
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
     if ( mfn_is_out_of_sync(gw->l3mfn) )
     {
-        sh_resync(v, gw->l3mfn);
+        sh_resync(d, gw->l3mfn);
         rc = GW_RMWR_REWALK;
     }
     else
@@ -297,7 +302,7 @@ gw_remove_write_accesses(struct vcpu *v, unsigned long va, 
walk_t *gw)
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
     if ( mfn_is_out_of_sync(gw->l2mfn) )
     {
-        sh_resync(v, gw->l2mfn);
+        sh_resync(d, gw->l2mfn);
         rc |= GW_RMWR_REWALK;
     }
     else
@@ -1030,7 +1035,7 @@ static int shadow_set_l2e(struct vcpu *v,
                OOS. */
             if ( (sp->u.sh.type != SH_type_fl1_shadow) && mfn_valid(gl1mfn)
                  && mfn_is_out_of_sync(gl1mfn) )
-                sh_resync(v, gl1mfn);
+                sh_resync(d, gl1mfn);
         }
 #endif
 #if GUEST_PAGING_LEVELS == 2
@@ -1178,7 +1183,7 @@ static int shadow_set_l1e(struct vcpu *v,
     if ( mfn_valid(new_gmfn) && mfn_oos_may_write(new_gmfn)
          && ((shadow_l1e_get_flags(new_sl1e) & (_PAGE_RW|_PAGE_PRESENT))
              == (_PAGE_RW|_PAGE_PRESENT)) )
-        oos_fixup_add(v, new_gmfn, sl1mfn, pgentry_ptr_to_slot(sl1e));
+        oos_fixup_add(d, new_gmfn, sl1mfn, pgentry_ptr_to_slot(sl1e));
 #endif
 
     old_sl1e = *sl1e;
@@ -2291,7 +2296,7 @@ static int validate_gl1e(struct vcpu *v, void *new_ge, 
mfn_t sl1mfn, void *se)
          && mfn_is_out_of_sync(gl1mfn) )
     {
         /* Update the OOS snapshot. */
-        mfn_t snpmfn = oos_snapshot_lookup(v, gl1mfn);
+        mfn_t snpmfn = oos_snapshot_lookup(d, gl1mfn);
         guest_l1e_t *snp;
 
         ASSERT(mfn_valid(snpmfn));
@@ -2629,7 +2634,7 @@ static void sh_prefetch(struct vcpu *v, walk_t *gw,
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
         if ( mfn_is_out_of_sync(gw->l1mfn) )
         {
-            mfn_t snpmfn = oos_snapshot_lookup(v, gw->l1mfn);
+            mfn_t snpmfn = oos_snapshot_lookup(d, gw->l1mfn);
 
             ASSERT(mfn_valid(snpmfn));
             snpl1p = sh_map_domain_page(snpmfn);
@@ -3167,7 +3172,7 @@ static int sh_page_fault(struct vcpu *v,
          && mfn_is_out_of_sync(gw.l1mfn) )
     {
         /* Update the OOS snapshot. */
-        mfn_t snpmfn = oos_snapshot_lookup(v, gw.l1mfn);
+        mfn_t snpmfn = oos_snapshot_lookup(d, gw.l1mfn);
         guest_l1e_t *snp;
 
         ASSERT(mfn_valid(snpmfn));
diff --git a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h
index 8c06775..7abb0e0 100644
--- a/xen/arch/x86/mm/shadow/private.h
+++ b/xen/arch/x86/mm/shadow/private.h
@@ -401,9 +401,9 @@ void shadow_unhook_mappings(struct vcpu *v, mfn_t smfn, int 
user_only);
 int sh_unsync(struct vcpu *v, mfn_t gmfn);
 
 /* Pull an out-of-sync page back into sync. */
-void sh_resync(struct vcpu *v, mfn_t gmfn);
+void sh_resync(struct domain *d, mfn_t gmfn);
 
-void oos_fixup_add(struct vcpu *v, mfn_t gmfn, mfn_t smfn, unsigned long off);
+void oos_fixup_add(struct domain *d, mfn_t gmfn, mfn_t smfn, unsigned long 
off);
 
 int sh_remove_write_access_from_sl1p(struct vcpu *v, mfn_t gmfn,
                                      mfn_t smfn, unsigned long offset);
@@ -432,7 +432,7 @@ shadow_sync_other_vcpus(struct vcpu *v)
 }
 
 void oos_audit_hash_is_present(struct domain *d, mfn_t gmfn);
-mfn_t oos_snapshot_lookup(struct vcpu *v, mfn_t gmfn);
+mfn_t oos_snapshot_lookup(struct domain *d, mfn_t gmfn);
 
 #endif /* (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) */
 
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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