[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 2/8] xen/domctl: Simplify DOMCTL_CDF_ checking logic
Introduce some local variables to make the resulting logic easier to follow. Join the two IOMMU checks in sanitise_domain_config(). Tweak some of the terminology for better accuracy. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> CC: Wei Liu <wl@xxxxxxx> --- xen/arch/x86/domain.c | 7 ++++--- xen/common/domain.c | 32 ++++++++++++++++++++------------ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 7e16d49bfd..d8f9be132c 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -629,6 +629,7 @@ void arch_vcpu_destroy(struct vcpu *v) int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) { bool hvm = config->flags & XEN_DOMCTL_CDF_hvm; + bool hap = config->flags & XEN_DOMCTL_CDF_hap; unsigned int max_vcpus; if ( hvm ? !hvm_enabled : !IS_ENABLED(CONFIG_PV) ) @@ -653,13 +654,13 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } - if ( (config->flags & XEN_DOMCTL_CDF_hap) && !hvm_hap_supported() ) + if ( hap && !hvm_hap_supported() ) { - dprintk(XENLOG_INFO, "HAP requested but not supported\n"); + dprintk(XENLOG_INFO, "HAP requested but not available\n"); return -EINVAL; } - if ( !(config->flags & XEN_DOMCTL_CDF_hvm) ) + if ( !hvm ) /* * It is only meaningful for XEN_DOMCTL_CDF_oos_off to be clear * for HVM guests. diff --git a/xen/common/domain.c b/xen/common/domain.c index 8cfa2e0b6b..cb617dc5aa 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -299,6 +299,10 @@ static void _domain_destroy(struct domain *d) static int sanitise_domain_config(struct xen_domctl_createdomain *config) { + bool hvm = config->flags & XEN_DOMCTL_CDF_hvm; + bool hap = config->flags & XEN_DOMCTL_CDF_hap; + bool iommu = config->flags & XEN_DOMCTL_CDF_iommu; + if ( config->flags & ~(XEN_DOMCTL_CDF_hvm | XEN_DOMCTL_CDF_hap | XEN_DOMCTL_CDF_s3_integrity | @@ -310,30 +314,34 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } - if ( !(config->flags & XEN_DOMCTL_CDF_iommu) && config->iommu_opts ) - { - dprintk(XENLOG_INFO, - "IOMMU options specified but IOMMU not enabled\n"); - return -EINVAL; - } - if ( config->max_vcpus < 1 ) { dprintk(XENLOG_INFO, "No vCPUS\n"); return -EINVAL; } - if ( !(config->flags & XEN_DOMCTL_CDF_hvm) && - (config->flags & XEN_DOMCTL_CDF_hap) ) + if ( hap && !hvm ) { dprintk(XENLOG_INFO, "HAP requested for non-HVM guest\n"); return -EINVAL; } - if ( (config->flags & XEN_DOMCTL_CDF_iommu) && !iommu_enabled ) + if ( iommu ) { - dprintk(XENLOG_INFO, "IOMMU is not enabled\n"); - return -EINVAL; + if ( !iommu_enabled ) + { + dprintk(XENLOG_INFO, "IOMMU requested but not available\n"); + return -EINVAL; + } + } + else + { + if ( config->iommu_opts ) + { + dprintk(XENLOG_INFO, + "IOMMU options specified but IOMMU not requested\n"); + return -EINVAL; + } } return arch_sanitise_domain_config(config); -- 2.11.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |