]> xenbits.xensource.com Git - xen.git/commitdiff
x86/paging: Package up the log dirty function pointers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 16 Feb 2017 16:42:16 +0000 (16:42 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 27 Feb 2017 10:07:54 +0000 (10:07 +0000)
They depend soley on paging mode, so don't need to be repeated per domain, and
can live in .rodata.  While making this change, drop the redundant log_dirty
from the function pointer names.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Tim Deegan <tim@xen.org>
Acked-by: George Dunlap <george.dunlap@citrix.com>
xen/arch/x86/mm/hap/hap.c
xen/arch/x86/mm/paging.c
xen/arch/x86/mm/shadow/common.c
xen/include/asm-x86/domain.h
xen/include/asm-x86/paging.h

index 4a17b130a4bcbc8a79d023ffd8caf5c2a0afb397..a57b38552322a42b94ddf6fa76de8ba8fcadd698 100644 (file)
@@ -442,12 +442,16 @@ static void hap_destroy_monitor_table(struct vcpu* v, mfn_t mmfn)
 /************************************************/
 void hap_domain_init(struct domain *d)
 {
+    static const struct log_dirty_ops hap_ops = {
+        .enable  = hap_enable_log_dirty,
+        .disable = hap_disable_log_dirty,
+        .clean   = hap_clean_dirty_bitmap,
+    };
+
     INIT_PAGE_LIST_HEAD(&d->arch.paging.hap.freelist);
 
     /* Use HAP logdirty mechanism. */
-    paging_log_dirty_init(d, hap_enable_log_dirty,
-                          hap_disable_log_dirty,
-                          hap_clean_dirty_bitmap);
+    paging_log_dirty_init(d, &hap_ops);
 }
 
 /* return 0 for success, -errno for failure */
index 97e2780c6db7af444fdb8de39aecf8593501bccc..632763163a0eedeb32b0aa74c157a6e1c803410d 100644 (file)
@@ -232,7 +232,7 @@ int paging_log_dirty_enable(struct domain *d, bool_t log_global)
         return -EINVAL;
 
     domain_pause(d);
-    ret = d->arch.paging.log_dirty.enable_log_dirty(d, log_global);
+    ret = d->arch.paging.log_dirty.ops->enable(d, log_global);
     domain_unpause(d);
 
     return ret;
@@ -248,7 +248,7 @@ static int paging_log_dirty_disable(struct domain *d, bool_t resuming)
         /* Safe because the domain is paused. */
         if ( paging_mode_log_dirty(d) )
         {
-            ret = d->arch.paging.log_dirty.disable_log_dirty(d);
+            ret = d->arch.paging.log_dirty.ops->disable(d);
             ASSERT(ret <= 0);
         }
     }
@@ -570,7 +570,7 @@ static int paging_log_dirty_op(struct domain *d,
     {
         /* We need to further call clean_dirty_bitmap() functions of specific
          * paging modes (shadow or hap).  Safe because the domain is paused. */
-        d->arch.paging.log_dirty.clean_dirty_bitmap(d);
+        d->arch.paging.log_dirty.ops->clean(d);
     }
     domain_unpause(d);
     return rv;
@@ -622,22 +622,16 @@ void paging_log_dirty_range(struct domain *d,
     flush_tlb_mask(d->domain_dirty_cpumask);
 }
 
-/* Note that this function takes three function pointers. Callers must supply
- * these functions for log dirty code to call. This function usually is
- * invoked when paging is enabled. Check shadow_enable() and hap_enable() for
- * reference.
+/*
+ * Callers must supply log_dirty_ops for the log dirty code to call. This
+ * function usually is invoked when paging is enabled. Check shadow_enable()
+ * and hap_enable() for reference.
  *
  * These function pointers must not be followed with the log-dirty lock held.
  */
-void paging_log_dirty_init(struct domain *d,
-                           int    (*enable_log_dirty)(struct domain *d,
-                                                      bool_t log_global),
-                           int    (*disable_log_dirty)(struct domain *d),
-                           void   (*clean_dirty_bitmap)(struct domain *d))
+void paging_log_dirty_init(struct domain *d, const struct log_dirty_ops *ops)
 {
-    d->arch.paging.log_dirty.enable_log_dirty = enable_log_dirty;
-    d->arch.paging.log_dirty.disable_log_dirty = disable_log_dirty;
-    d->arch.paging.log_dirty.clean_dirty_bitmap = clean_dirty_bitmap;
+    d->arch.paging.log_dirty.ops = ops;
 }
 
 /************************************************/
index 560a7fde54e41ce7f52fd14a0c28c515fb97298b..d078d783964c6b2e98b20c9336a003fa7f68599e 100644 (file)
@@ -48,12 +48,17 @@ static void sh_clean_dirty_bitmap(struct domain *);
  * Called for every domain from arch_domain_create() */
 int shadow_domain_init(struct domain *d, unsigned int domcr_flags)
 {
+    static const struct log_dirty_ops sh_ops = {
+        .enable  = sh_enable_log_dirty,
+        .disable = sh_disable_log_dirty,
+        .clean   = sh_clean_dirty_bitmap,
+    };
+
     INIT_PAGE_LIST_HEAD(&d->arch.paging.shadow.freelist);
     INIT_PAGE_LIST_HEAD(&d->arch.paging.shadow.pinned_shadows);
 
     /* Use shadow pagetables for log-dirty support */
-    paging_log_dirty_init(d, sh_enable_log_dirty,
-                          sh_disable_log_dirty, sh_clean_dirty_bitmap);
+    paging_log_dirty_init(d, &sh_ops);
 
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
     d->arch.paging.shadow.oos_active = 0;
index d8749df4eba94569e7ea6618aba1ebfe5ad6c57f..1beef2f5203877a201b716fcf62f8daa03ead009 100644 (file)
@@ -175,9 +175,11 @@ struct log_dirty_domain {
     unsigned int   dirty_count;
 
     /* functions which are paging mode specific */
-    int            (*enable_log_dirty   )(struct domain *d, bool_t log_global);
-    int            (*disable_log_dirty  )(struct domain *d);
-    void           (*clean_dirty_bitmap )(struct domain *d);
+    const struct log_dirty_ops {
+        int        (*enable  )(struct domain *d, bool log_global);
+        int        (*disable )(struct domain *d);
+        void       (*clean   )(struct domain *d);
+    } *ops;
 };
 
 struct paging_domain {
index 51808fc08a5640ab8e5cd8b50aea2f4242ec28f9..2f5befcc81657fff73905b8cc92d67bb6baaf995 100644 (file)
@@ -150,11 +150,7 @@ void paging_log_dirty_range(struct domain *d,
 int paging_log_dirty_enable(struct domain *d, bool_t log_global);
 
 /* log dirty initialization */
-void paging_log_dirty_init(struct domain *d,
-                           int  (*enable_log_dirty)(struct domain *d,
-                                                    bool_t log_global),
-                           int  (*disable_log_dirty)(struct domain *d),
-                           void (*clean_dirty_bitmap)(struct domain *d));
+void paging_log_dirty_init(struct domain *d, const struct log_dirty_ops *ops);
 
 /* mark a page as dirty */
 void paging_mark_dirty(struct domain *d, mfn_t gmfn);