x86/hvm/domain: remove the 'hap_enabled' flag

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>
This commit is contained in:
Paul Durrant authored and Jan Beulich committed 2019-08-28 16:58:45 +02:00
1 parent b806c91275
commit d0c0ba7d3d
7 files changed
+24 -18

No files matched your search

+7 -6
View 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;
+2 -2
View 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;
}
+7
View 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);
}
-2
View 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.
-7
View 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__ */
/*
+1 -1
View 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
+7
View 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) &&
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.