x86: make mem-paging configurable and default it to off
authorJan Beulich <jbeulich@suse.com>
Mon, 3 May 2021 13:28:53 +0000 (15:28 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 3 May 2021 13:28:53 +0000 (15:28 +0200)
... for being unsupported.

While doing so, make the option dependent upon HVM, which really is the
main purpose of the change.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Alexandru Isaila <aisaila@bitdefender.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
17 files changed:
xen/arch/x86/Kconfig
xen/arch/x86/hvm/hvm.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/memory.c
xen/common/vm_event.c
xen/drivers/passthrough/x86/iommu.c
xen/include/asm-x86/mem_paging.h
xen/include/asm-x86/p2m.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 32b9f23a20ecfed201d81b680d1fa0e1019f85dc..271b098fb56bab879ce1003aa4c99881e7925eb1 100644 (file)
@@ -16,7 +16,6 @@ config X86
        select HAS_FAST_MULTIPLY
        select HAS_IOPORTS
        select HAS_KEXEC
-       select HAS_MEM_PAGING
        select HAS_NS16550
        select HAS_PASSTHROUGH
        select HAS_PCI
@@ -255,6 +254,10 @@ config HYPERV_GUEST
 
 endif
 
+config MEM_PAGING
+       bool "Xen memory paging support (UNSUPPORTED)" if UNSUPPORTED
+       depends on HVM
+
 config MEM_SHARING
        bool "Xen memory sharing support (UNSUPPORTED)" if UNSUPPORTED
        depends on HVM
index 28beacc45b993bcc186a48ed4358025a7b41354f..5086773e5c8b89eaa0dafe389e2e2acf527b3c15 100644 (file)
@@ -1934,9 +1934,11 @@ int hvm_hap_nested_page_fault(paddr_t gpa, unsigned long gla,
         goto out_put_gfn;
     }
 
+#ifdef CONFIG_MEM_PAGING
     /* Check if the page has been paged out */
     if ( p2m_is_paged(p2mt) || (p2mt == p2m_ram_paging_out) )
         paged = 1;
+#endif
 
 #ifdef CONFIG_MEM_SHARING
     /* Mem sharing: if still shared on write access then its enomem */
index 24f4ec40e08401560a9f5439629fcd3f2bbc5f42..5cc70005c95fd18f45f04b0c1df754144f25a9fa 100644 (file)
@@ -5,7 +5,7 @@ obj-$(CONFIG_HVM) += altp2m.o
 obj-$(CONFIG_HVM) += guest_walk_2.o guest_walk_3.o guest_walk_4.o
 obj-$(CONFIG_SHADOW_PAGING) += guest_walk_4.o
 obj-$(CONFIG_MEM_ACCESS) += mem_access.o
-obj-y += mem_paging.o
+obj-$(CONFIG_MEM_PAGING) += mem_paging.o
 obj-$(CONFIG_MEM_SHARING) += mem_sharing.o
 obj-y += p2m.o p2m-pt.o
 obj-$(CONFIG_HVM) += p2m-ept.o p2m-pod.o
index febdaa1977e4252c01580f5ce1e142aec30dc90c..215e96aba0322970c39adb09a5b0bf0fd826b52a 100644 (file)
@@ -155,8 +155,10 @@ int compat_arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     case XENMEM_get_sharing_shared_pages:
         return mem_sharing_get_nr_shared_mfns();
 
+#ifdef CONFIG_MEM_PAGING
     case XENMEM_paging_op:
         return mem_paging_memop(guest_handle_cast(arg, xen_mem_paging_op_t));
+#endif
 
 #ifdef CONFIG_MEM_SHARING
     case XENMEM_sharing_op:
index c41ce847b36e40b70e6693ada74d09cefcb83ac1..4f225da81e9f5ab86b23a29362e0e9076934a0e5 100644 (file)
@@ -1008,8 +1008,10 @@ long subarch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     case XENMEM_get_sharing_shared_pages:
         return mem_sharing_get_nr_shared_mfns();
 
+#ifdef CONFIG_MEM_PAGING
     case XENMEM_paging_op:
         return mem_paging_memop(guest_handle_cast(arg, xen_mem_paging_op_t));
+#endif
 
 #ifdef CONFIG_MEM_SHARING
     case XENMEM_sharing_op:
index b6c9827a7b4d67ed5bb35c3db21b6a356fee8e8d..0ddd18e11af3c877333d59ed992db8614f4a7fce 100644 (file)
@@ -43,9 +43,6 @@ config HAS_IOPORTS
 config HAS_KEXEC
        bool
 
-config HAS_MEM_PAGING
-       bool
-
 config HAS_PDX
        bool
 
index cdda0d1f29aeed19a1ddacb7416d7938f295c1af..6b71c6d6a9773980c411a741ac1971698cf2fa76 100644 (file)
@@ -1096,7 +1096,7 @@ static void complete_domain_destroy(struct rcu_head *head)
     free_xenoprof_pages(d);
 #endif
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
     xfree(d->vm_event_paging);
 #endif
     xfree(d->vm_event_monitor);
index 76b9f584785b096fa7605cf30c299e3091113538..b5c70c4b85d6dd05329bf98b85c205d7c321b689 100644 (file)
@@ -1856,7 +1856,7 @@ int check_get_page_from_gfn(struct domain *d, gfn_t gfn, bool readonly,
 
     page = get_page_from_gfn(d, gfn_x(gfn), &p2mt, q);
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
     if ( p2m_is_paging(p2mt) )
     {
         if ( page )
index 44d542f23e0eadc12acb1814aef970a70690764d..70ab3ba406ff0c30846f6ddbec996fe990719c64 100644 (file)
@@ -390,7 +390,7 @@ static int vm_event_resume(struct domain *d, struct vm_event_domain *ved)
         /* Check flags which apply only when the vCPU is paused */
         if ( atomic_read(&v->vm_event_pause_count) )
         {
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
             if ( rsp.reason == VM_EVENT_REASON_MEM_PAGING )
                 p2m_mem_paging_resume(d, &rsp);
 #endif
@@ -521,7 +521,7 @@ int __vm_event_claim_slot(struct domain *d, struct vm_event_domain *ved,
         return vm_event_grab_slot(ved, current->domain != d);
 }
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
 /* Registered with Xen-bound event channel for incoming notifications. */
 static void mem_paging_notification(struct vcpu *v, unsigned int port)
 {
@@ -546,7 +546,7 @@ static void mem_sharing_notification(struct vcpu *v, unsigned int port)
 /* Clean up on domain destruction */
 void vm_event_cleanup(struct domain *d)
 {
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
     if ( vm_event_check_ring(d->vm_event_paging) )
     {
         /* Destroying the wait queue head means waking up all
@@ -613,7 +613,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec)
 
     switch ( vec->mode )
     {
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
     case XEN_DOMCTL_VM_EVENT_OP_PAGING:
     {
         rc = -EINVAL;
index b90bb31bfeeab08f65075ccb52144d8cb7672b41..593cc4d6aed8fa374804bead8d074aecb5e0c3b2 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <asm/hvm/io.h>
 #include <asm/io_apic.h>
+#include <asm/mem_paging.h>
 #include <asm/setup.h>
 
 const struct iommu_init_ops *__initdata iommu_init_ops;
@@ -336,7 +337,7 @@ bool arch_iommu_use_permitted(const struct domain *d)
      */
     return d == dom_io ||
            (likely(!mem_sharing_enabled(d)) &&
-            likely(!vm_event_check_ring(d->vm_event_paging)) &&
+            likely(!mem_paging_enabled(d)) &&
             likely(!p2m_get_hostp2m(d)->global_logdirty));
 }
 
index 176acafc75f071e3e16f7de94cedba89103c3c48..d3635e96cffc0bb18efe2b865b3fee03bf537dad 100644 (file)
 
 int mem_paging_memop(XEN_GUEST_HANDLE_PARAM(xen_mem_paging_op_t) arg);
 
+#ifdef CONFIG_MEM_PAGING
+# define mem_paging_enabled(d) vm_event_check_ring((d)->vm_event_paging)
+#else
+# define mem_paging_enabled(d) false
+#endif
+
 #endif /*__ASM_X86_MEM_PAGING_H__ */
 
 /*
index 979fc83d02bd5550f95c01e82aa4856eb2296057..b7da310f706cd4026a86acd1eaf3f12e3b1ab057 100644 (file)
@@ -136,11 +136,16 @@ typedef unsigned int p2m_query_t;
 #define P2M_PAGEABLE_TYPES (p2m_to_mask(p2m_ram_rw) \
                             | p2m_to_mask(p2m_ram_logdirty) )
 
+#ifdef CONFIG_MEM_PAGING
 #define P2M_PAGING_TYPES (p2m_to_mask(p2m_ram_paging_out)        \
                           | p2m_to_mask(p2m_ram_paged)           \
                           | p2m_to_mask(p2m_ram_paging_in))
 
 #define P2M_PAGED_TYPES (p2m_to_mask(p2m_ram_paged))
+#else
+#define P2M_PAGING_TYPES 0
+#define P2M_PAGED_TYPES 0
+#endif
 
 /* Shared types */
 /* XXX: Sharable types could include p2m_ram_ro too, but we would need to
index cc633fdc073be30f8f56cdc82c5567231e26a9bd..3982167144c6d7a6a9c5ed4222b7553874fc9550 100644 (file)
@@ -530,7 +530,7 @@ struct domain
     struct domain *parent; /* VM fork parent */
 #endif
     /* Memory paging support */
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
     struct vm_event_domain *vm_event_paging;
 #endif
     /* VM event monitor support */
index a6dab0c809b34fe4b29520f22a0954cd542f785b..363c6d7798d9e99ff79512902750b21d8188d42a 100644 (file)
@@ -592,7 +592,7 @@ static XSM_INLINE int xsm_mem_access(XSM_DEFAULT_ARG struct domain *d)
 }
 #endif
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
 static XSM_INLINE int xsm_mem_paging(XSM_DEFAULT_ARG struct domain *d)
 {
     XSM_ASSERT_ACTION(XSM_DM_PRIV);
index 7bdd254420fac5b16aeedc8b8313ec49cd6b3166..ad3cddbf7da0bef68a58d667873ccb7b84d230e7 100644 (file)
@@ -146,7 +146,7 @@ struct xsm_operations {
     int (*mem_access) (struct domain *d);
 #endif
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
     int (*mem_paging) (struct domain *d);
 #endif
 
@@ -592,7 +592,7 @@ static inline int xsm_mem_access (xsm_default_t def, struct domain *d)
 }
 #endif
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
 static inline int xsm_mem_paging (xsm_default_t def, struct domain *d)
 {
     return xsm_ops->mem_paging(d);
index 627f12dbff8ab4fe1f995e73b3a1d689be6527a5..de44b101308b5abfe505ac16494982f8385fbaf2 100644 (file)
@@ -124,7 +124,7 @@ void __init xsm_fixup_ops (struct xsm_operations *ops)
     set_to_dummy_if_null(ops, mem_access);
 #endif
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
     set_to_dummy_if_null(ops, mem_paging);
 #endif
 
index 5a24d01f045e9ba62465fa4d439257b70b705704..f1a1217c989ace61b28e3879e29fa23f520a007c 100644 (file)
@@ -1256,7 +1256,7 @@ static int flask_mem_access(struct domain *d)
 }
 #endif
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
 static int flask_mem_paging(struct domain *d)
 {
     return current_has_perm(d, SECCLASS_DOMAIN2, DOMAIN2__MEM_PAGING);
@@ -1829,7 +1829,7 @@ static struct xsm_operations flask_ops = {
     .mem_access = flask_mem_access,
 #endif
 
-#ifdef CONFIG_HAS_MEM_PAGING
+#ifdef CONFIG_MEM_PAGING
     .mem_paging = flask_mem_paging,
 #endif