]> xenbits.xensource.com Git - xen.git/commitdiff
x86/mem_sharing: compile mem_sharing subsystem only when kconfig is enabled
authorTamas K Lengyel <tamas@tklengyel.com>
Fri, 19 Jul 2019 11:49:47 +0000 (13:49 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 19 Jul 2019 11:49:47 +0000 (13:49 +0200)
Disable it by default as it is only an experimental subsystem.

Signed-off-by: Tamas K Lengyel <tamas@tklengyel.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Acked-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
19 files changed:
xen/arch/x86/Kconfig
xen/arch/x86/domain.c
xen/arch/x86/domctl.c
xen/arch/x86/mm/Makefile
xen/arch/x86/x86_64/compat/mm.c
xen/arch/x86/x86_64/mm.c
xen/common/Kconfig
xen/common/domain.c
xen/common/grant_table.c
xen/common/memory.c
xen/common/vm_event.c
xen/include/asm-x86/mem_sharing.h
xen/include/asm-x86/mm.h
xen/include/xen/mm.h
xen/include/xen/sched.h
xen/include/xsm/dummy.h
xen/include/xsm/xsm.h
xen/xsm/dummy.c
xen/xsm/flask/hooks.c

index f502d765ba3d7a18d9474ee4bf66fa873dbef722..288dc6c042c9d1410c70cb49a943522c321a1991 100644 (file)
@@ -18,7 +18,6 @@ config X86
        select HAS_KEXEC
        select MEM_ACCESS_ALWAYS_ON
        select HAS_MEM_PAGING
-       select HAS_MEM_SHARING
        select HAS_NS16550
        select HAS_PASSTHROUGH
        select HAS_PCI
@@ -199,6 +198,11 @@ config PV_SHIM_EXCLUSIVE
          firmware, and will not function correctly in other scenarios.
 
          If unsure, say N.
+
+config MEM_SHARING
+       bool "Xen memory sharing support" if EXPERT = "y"
+       depends on HVM
+
 endmenu
 
 source "common/Kconfig"
index e791d86892b3833e65d6c088ceee4ad6db325b00..ea551608877b98faa41965d51e3eb0a85da238e7 100644 (file)
@@ -2095,6 +2095,7 @@ int domain_relinquish_resources(struct domain *d)
             d->arch.auto_unmask = 0;
         }
 
+#ifdef CONFIG_MEM_SHARING
     PROGRESS(shared):
 
         if ( is_hvm_domain(d) )
@@ -2105,6 +2106,7 @@ int domain_relinquish_resources(struct domain *d)
             if ( ret )
                 return ret;
         }
+#endif
 
         spin_lock(&d->page_alloc_lock);
         page_list_splice(&d->arch.relmem_list, &d->page_list);
index c82779020281808dd6c1dfe66b085305dc6e791e..2d45e5b8a83de361b180cc60946eac3c677c4170 100644 (file)
@@ -1236,9 +1236,11 @@ long arch_do_domctl(
         break;
     }
 
+#ifdef CONFIG_MEM_SHARING
     case XEN_DOMCTL_mem_sharing_op:
         ret = mem_sharing_domctl(d, &domctl->u.mem_sharing_op);
         break;
+#endif
 
 #if P2M_AUDIT && defined(CONFIG_HVM)
     case XEN_DOMCTL_audit_p2m:
index 5a17646f988c000143113215a6ee759fd39f74cd..5010a29d6cb035d46b1cf7c158fcb446fda00472 100644 (file)
@@ -6,7 +6,7 @@ obj-$(CONFIG_HVM) += guest_walk_2.o guest_walk_3.o guest_walk_4.o
 obj-$(CONFIG_SHADOW_PAGING) += guest_walk_2.o guest_walk_3.o guest_walk_4.o
 obj-$(CONFIG_MEM_ACCESS) += mem_access.o
 obj-y += mem_paging.o
-obj-y += mem_sharing.o
+obj-$(CONFIG_MEM_SHARING) += mem_sharing.o
 obj-y += p2m.o p2m-pt.o
 obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o
 obj-y += paging.o
index 32410ed2730693bdbbc2f82fcc897af53b3f0929..d4c6be3032bb43b7b1d379a4e3f509d450426f8a 100644 (file)
@@ -152,8 +152,10 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     case XENMEM_paging_op:
         return mem_paging_memop(guest_handle_cast(arg, xen_mem_paging_op_t));
 
+#ifdef CONFIG_MEM_SHARING
     case XENMEM_sharing_op:
         return mem_sharing_memop(guest_handle_cast(arg, xen_mem_sharing_op_t));
+#endif
 
     default:
         rc = -ENOSYS;
index 899b883b2d762aa43daeed61f5e22c793e0f073f..1919cae18bda23e1f070257a790ee410efae00a7 100644 (file)
@@ -993,8 +993,10 @@ long subarch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     case XENMEM_paging_op:
         return mem_paging_memop(guest_handle_cast(arg, xen_mem_paging_op_t));
 
+#ifdef CONFIG_MEM_SHARING
     case XENMEM_sharing_op:
         return mem_sharing_memop(guest_handle_cast(arg, xen_mem_sharing_op_t));
+#endif
 
     default:
         rc = -ENOSYS;
index 912630a4fba5ace8fd78fbf2dfc0bdd92d6a85af..16829f62741c738d750f4ec27f3ae1cb88f68206 100644 (file)
@@ -48,9 +48,6 @@ config MEM_ACCESS
 config HAS_MEM_PAGING
        bool
 
-config HAS_MEM_SHARING
-       bool
-
 config HAS_PDX
        bool
 
index 8a5fa8662b42c4385f6bbff585dea241e247ea2a..55aa759b7551c24feb64b7d3fc2f76684afd4749 100644 (file)
@@ -74,7 +74,7 @@ integer_param("hardware_dom", hardware_domid);
 /* Private domain structs for DOMID_XEN, DOMID_IO, etc. */
 struct domain *__read_mostly dom_xen;
 struct domain *__read_mostly dom_io;
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
 struct domain *__read_mostly dom_cow;
 #endif
 
@@ -549,7 +549,7 @@ void __init setup_system_domains(void)
     if ( IS_ERR(dom_io) )
         panic("Failed to create d[IO]: %ld\n", PTR_ERR(dom_io));
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     /*
      * Initialise our COW domain.
      * This domain owns sharable pages.
@@ -966,7 +966,7 @@ static void complete_domain_destroy(struct rcu_head *head)
     xfree(d->vm_event_paging);
 #endif
     xfree(d->vm_event_monitor);
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     xfree(d->vm_event_share);
 #endif
 
index b6b45c21e162b5f7ddd9538132b7c98bb1c6e976..97695a221a6ee84cccd82cd4db94d276a79e124e 100644 (file)
@@ -3798,7 +3798,7 @@ void grant_table_init_vcpu(struct vcpu *v)
     v->maptrack_tail = MAPTRACK_TAIL;
 }
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
 int mem_sharing_gref_to_gfn(struct grant_table *gt, grant_ref_t ref,
                             gfn_t *gfn, uint16_t *status)
 {
index 30d210fc08c25baadbea56f775b4ad2b33706e57..d9b35a608c9e4a3808b011487612039f5f304fed 100644 (file)
@@ -1676,7 +1676,7 @@ int check_get_page_from_gfn(struct domain *d, gfn_t gfn, bool readonly,
         return -EAGAIN;
     }
 #endif
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     if ( (q & P2M_UNSHARE) && p2m_is_shared(p2mt) )
     {
         if ( page )
index e8726805e792638e5a31a45a1f49fb7b90c5c882..2a1c87e44b44d35ad46e608f72ee6a1a6b851516 100644 (file)
@@ -531,7 +531,7 @@ static void monitor_notification(struct vcpu *v, unsigned int port)
     vm_event_resume(v->domain, v->domain->vm_event_monitor);
 }
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
 /* Registered with Xen-bound event channel for incoming notifications. */
 static void mem_sharing_notification(struct vcpu *v, unsigned int port)
 {
@@ -561,7 +561,7 @@ void vm_event_cleanup(struct domain *d)
         destroy_waitqueue_head(&d->vm_event_monitor->wq);
         (void)vm_event_disable(d, &d->vm_event_monitor);
     }
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     if ( vm_event_check_ring(d->vm_event_share) )
     {
         destroy_waitqueue_head(&d->vm_event_share->wq);
@@ -703,7 +703,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec)
     }
     break;
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     case XEN_DOMCTL_VM_EVENT_OP_SHARING:
     {
         rc = -EINVAL;
index afd0c172926ddf4c020f2c22bb256d7c8a8d93af..db224687443c5311b1c5bdf6a4f3bb6cc88e58c3 100644 (file)
@@ -24,6 +24,8 @@
 #include <public/domctl.h>
 #include <public/memory.h>
 
+#ifdef CONFIG_MEM_SHARING
+
 /* Auditing of memory sharing code? */
 #ifndef NDEBUG
 #define MEM_SHARING_AUDIT 1
@@ -99,4 +101,30 @@ int mem_sharing_domctl(struct domain *d,
  */
 int relinquish_shared_pages(struct domain *d);
 
+#else
+
+static inline unsigned int mem_sharing_get_nr_saved_mfns(void)
+{
+    return 0;
+}
+static inline unsigned int mem_sharing_get_nr_shared_mfns(void)
+{
+    return 0;
+}
+static inline int mem_sharing_unshare_page(struct domain *d,
+                                           unsigned long gfn,
+                                           uint16_t flags)
+{
+    ASSERT_UNREACHABLE();
+    return -EOPNOTSUPP;
+}
+static inline int mem_sharing_notify_enomem(struct domain *d, unsigned long gfn,
+                              bool allow_sleep)
+{
+    ASSERT_UNREACHABLE();
+    return -EOPNOTSUPP;
+}
+
+#endif
+
 #endif /* __MEM_SHARING_H__ */
index 087ad973515da30aa40f2cfcea9f2fe021c26380..35c2527265ffde3ed06b284716929401b70d8697 100644 (file)
@@ -127,6 +127,8 @@ struct page_info
         /* For non-pinnable single-page shadows, a higher entry that points
          * at us. */
         paddr_t up;
+
+#ifdef CONFIG_MEM_SHARING
         /* For shared/sharable pages, we use a doubly-linked list
          * of all the {pfn,domain} pairs that map this page. We also include
          * an opaque handle, which is effectively a version, so that clients
@@ -134,6 +136,7 @@ struct page_info
          * This list is allocated and freed when a page is shared/unshared.
          */
         struct page_sharing_info *sharing;
+#endif
     };
 
     /* Reference count and various PGC_xxx flags and fields. */
index 47c8412b3a30eb5c502caa8fc2a600d977d18fbf..977e45aae725c61e53dd60f4940507ed6c2122c6 100644 (file)
@@ -275,7 +275,7 @@ struct npfec {
 
 /* Private domain structs for DOMID_XEN, DOMID_IO, etc. */
 extern struct domain *dom_xen, *dom_io;
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
 extern struct domain *dom_cow;
 #else
 # define dom_cow NULL
index 97a3ab55aa37539a02f7765b42c6a526facbf89c..b40c8fd138734d128d785cf9ddede9f15013afba 100644 (file)
@@ -459,7 +459,7 @@ struct domain
     /* Various vm_events */
 
     /* Memory sharing support */
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     struct vm_event_domain *vm_event_share;
 #endif
     /* Memory paging support */
index 01d2814fedff08f69b063e4e0d3ead7b0117718b..ef52bb176444b71d7da5976c0dcae378ff06b35b 100644 (file)
@@ -597,7 +597,7 @@ static XSM_INLINE int xsm_mem_paging(XSM_DEFAULT_ARG struct domain *d)
 }
 #endif
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
 static XSM_INLINE int xsm_mem_sharing(XSM_DEFAULT_ARG struct domain *d)
 {
     XSM_ASSERT_ACTION(XSM_DM_PRIV);
index b6141f6ab11943a215feff816073c3032f0c51df..e22d6160b5fc677c5c48b4d80407566324cb0253 100644 (file)
@@ -150,7 +150,7 @@ struct xsm_operations {
     int (*mem_paging) (struct domain *d);
 #endif
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     int (*mem_sharing) (struct domain *d);
 #endif
 
@@ -597,7 +597,7 @@ static inline int xsm_mem_paging (xsm_default_t def, struct domain *d)
 }
 #endif
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
 static inline int xsm_mem_sharing (xsm_default_t def, struct domain *d)
 {
     return xsm_ops->mem_sharing(d);
index c9a566f2b5e99260a1788555c31bcc1ddc985b8f..5705e52791be86e35d723ee46d9ab6bb89a7595c 100644 (file)
@@ -128,7 +128,7 @@ void __init xsm_fixup_ops (struct xsm_operations *ops)
     set_to_dummy_if_null(ops, mem_paging);
 #endif
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     set_to_dummy_if_null(ops, mem_sharing);
 #endif
 
index a7d690ac3c2bbecb831dc019b064f265c28504d2..791c1f66afc88b7665e9e92c884a1026ba5a30a7 100644 (file)
@@ -1262,7 +1262,7 @@ static int flask_mem_paging(struct domain *d)
 }
 #endif
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
 static int flask_mem_sharing(struct domain *d)
 {
     return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__MEM_SHARING);
@@ -1829,7 +1829,7 @@ static struct xsm_operations flask_ops = {
     .mem_paging = flask_mem_paging,
 #endif
 
-#ifdef CONFIG_HAS_MEM_SHARING
+#ifdef CONFIG_MEM_SHARING
     .mem_sharing = flask_mem_sharing,
 #endif