]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86/hvm/domain: remove the 'hap_enabled' flag
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 28 Aug 2019 14:58:45 +0000 (16:58 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 28 Aug 2019 14:58:45 +0000 (16:58 +0200)
The hap_enabled() macro can determine whether the feature is available
using the domain 'options'; there is no need for a separate flag.

NOTE: Furthermore, by extending sanitizing of the domain 'options', the
      macro can be transformed into an inline function and re-located to
      xen/sched.h. This also makes hap_enabled() common, thus allowing
      removal of an ugly ifdef CONFIG_X86 from the common iommu code.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/domain.c
xen/arch/x86/mm/paging.c
xen/common/domain.c
xen/drivers/passthrough/iommu.c
xen/include/asm-x86/hvm/domain.h
xen/include/asm-x86/paging.h
xen/include/xen/sched.h

index bc082ed82743957b5af32aa584fca06d1687b99b..2df312332dbbc172b39c13cc350e9260c85ad536 100644 (file)
@@ -467,6 +467,12 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config)
         return -EINVAL;
     }
 
+    if ( (config->flags & XEN_DOMCTL_CDF_hap) && !hvm_hap_supported() )
+    {
+        dprintk(XENLOG_INFO, "HAP requested but not supported\n");
+        return -EINVAL;
+    }
+
     return 0;
 }
 
@@ -569,12 +575,7 @@ int arch_domain_create(struct domain *d,
     HYPERVISOR_COMPAT_VIRT_START(d) =
         is_pv_domain(d) ? __HYPERVISOR_COMPAT_VIRT_START : ~0u;
 
-    /* Need to determine if HAP is enabled before initialising paging */
-    if ( is_hvm_domain(d) )
-        d->arch.hvm.hap_enabled =
-            hvm_hap_supported() && (config->flags & XEN_DOMCTL_CDF_hap);
-
-    if ( (rc = paging_domain_init(d, config->flags)) != 0 )
+    if ( (rc = paging_domain_init(d)) != 0 )
         goto fail;
     paging_initialised = true;
 
index 011089368a4d309434ef499f8fa7b6af065e207e..097a27f6081cd1651ac2458dfdc4655046c23f03 100644 (file)
@@ -632,7 +632,7 @@ void paging_log_dirty_init(struct domain *d, const struct log_dirty_ops *ops)
 /*           CODE FOR PAGING SUPPORT            */
 /************************************************/
 /* Domain paging struct initialization. */
-int paging_domain_init(struct domain *d, unsigned int domcr_flags)
+int paging_domain_init(struct domain *d)
 {
     int rc;
 
@@ -653,7 +653,7 @@ int paging_domain_init(struct domain *d, unsigned int domcr_flags)
     if ( hap_enabled(d) )
         hap_domain_init(d);
     else
-        rc = shadow_domain_init(d, domcr_flags);
+        rc = shadow_domain_init(d, d->options);
 
     return rc;
 }
index 1f7a449f14085f5503f2df342b573eb252d5e167..e9d2c613e0f846747649a56c79bb1e615a899e6e 100644 (file)
@@ -313,6 +313,13 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config)
         return -EINVAL;
     }
 
+    if ( !(config->flags & XEN_DOMCTL_CDF_hvm_guest) &&
+         (config->flags & XEN_DOMCTL_CDF_hap) )
+    {
+        dprintk(XENLOG_INFO, "HAP requested for non-HVM guest\n");
+        return -EINVAL;
+    }
+
     return arch_sanitise_domain_config(config);
 }
 
index f8c3bf53bd1793df93d7ddea6564dc929f40c156..37eb0f7d01d6aac715ddc087cd2462339745e982 100644 (file)
@@ -573,9 +573,7 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_table(struct domain* d)
 {
-#ifdef CONFIG_X86
     ASSERT(hap_enabled(d));
-#endif
     /*
      * iommu_use_hap_pt(d) cannot be used here because during domain
      * construction need_iommu(d) will always return false here.
index 6c7c4f5aa61a09cd278bd8269ad2235c4087ce6e..bcc5621797df2a4ed75be894a2525638bfde35cf 100644 (file)
@@ -156,7 +156,6 @@ struct hvm_domain {
 
     struct viridian_domain *viridian;
 
-    bool_t                 hap_enabled;
     bool_t                 mem_sharing_enabled;
     bool_t                 qemu_mapcache_invalidate;
     bool_t                 is_s3_suspended;
@@ -195,12 +194,6 @@ struct hvm_domain {
     };
 };
 
-#ifdef CONFIG_HVM
-#define hap_enabled(d)  (is_hvm_domain(d) && (d)->arch.hvm.hap_enabled)
-#else
-#define hap_enabled(d)  ({(void)(d); false;})
-#endif
-
 #endif /* __ASM_X86_HVM_DOMAIN_H__ */
 
 /*
index cf57ca708dfddedd2aa014f87a9c7d6daf119ef6..ab7887f23c33a3441838ed79cfea67e25d2d2ec4 100644 (file)
@@ -207,7 +207,7 @@ void paging_vcpu_init(struct vcpu *v);
 
 /* Set up the paging-assistance-specific parts of a domain struct at
  * start of day.  Called for every domain from arch_domain_create() */
-int paging_domain_init(struct domain *d, unsigned int domcr_flags);
+int paging_domain_init(struct domain *d);
 
 /* Handler for paging-control ops: operations from user-space to enable
  * and disable ephemeral shadow modes (test mode and log-dirty mode) and
index 1101992b9f697dc64cc8978ffb68a70615ef3fbc..d2bbe03bd94a672d9e8f0a92fa8cfea17cb60ec8 100644 (file)
@@ -952,6 +952,13 @@ static inline bool is_hvm_vcpu(const struct vcpu *v)
     return is_hvm_domain(v->domain);
 }
 
+static inline bool hap_enabled(const struct domain *d)
+{
+    /* sanitise_domain_config() rejects HAP && !HVM */
+    return IS_ENABLED(CONFIG_HVM) &&
+        evaluate_nospec(d->options & XEN_DOMCTL_CDF_hap);
+}
+
 static inline bool is_hwdom_pinned_vcpu(const struct vcpu *v)
 {
     return (is_hardware_domain(v->domain) &&