From nobody Mon Feb 9 16:02:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1601473578; cv=none; d=zohomail.com; s=zohoarc; b=Z/1pLiub8sJvcPJEdG+PJCYsRjneO+WNHgpdvtuGibEV6+AqKKN/3go7WGjrkc44QHwFKzv23zRaMWQl7U06kzKPsGZ/+9z41tGk2WJX/Ksfj15Vzeqx5Zr0rcEHFTuRmG2/GV7cshmUx5WuOT9vPlK6r5Zv7+oMVFPyXyaeJkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601473578; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tk4GWUmkYfn7kgyuNSuM2/s5IllFK2lSc6LK7LerNIE=; b=PYN7GTXANXPTIq9I1g6kgbYSxIWzfqgN7Dg96hdUN2zUDGf3uRz5yUtS+eg2TO/NWhxooEl9bXjYf5ZgOYwdz3F6ZHF6LDsGNl9xnDMPOYMs1c1dGeQIy5Ag2cJhR35ZzphoMJEkwU7pVS+W4Qe4afP+RP4QmwYQFlPjmVvHMcE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1601473578759540.4101002271046; Wed, 30 Sep 2020 06:46:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.721.2451 (Exim 4.92) (envelope-from ) id 1kNcQl-00056O-Pc; Wed, 30 Sep 2020 13:46:03 +0000 Received: by outflank-mailman (output) from mailman id 721.2451; Wed, 30 Sep 2020 13:46:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNcQl-00056F-MB; Wed, 30 Sep 2020 13:46:03 +0000 Received: by outflank-mailman (input) for mailman id 721; Wed, 30 Sep 2020 13:46:03 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNcQl-00052v-4d for xen-devel@lists.xenproject.org; Wed, 30 Sep 2020 13:46:03 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1206cba0-a852-4df3-b2b9-f626274909e9; Wed, 30 Sep 2020 13:45:59 +0000 (UTC) Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kNcQl-00052v-4d for xen-devel@lists.xenproject.org; Wed, 30 Sep 2020 13:46:03 +0000 Received: from esa2.hc3370-68.iphmx.com (unknown [216.71.145.153]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 1206cba0-a852-4df3-b2b9-f626274909e9; Wed, 30 Sep 2020 13:45:59 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1206cba0-a852-4df3-b2b9-f626274909e9 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1601473560; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sjwCbNEiAtCg61EY837b6G5uXXMGVuCb608FCmyhoBg=; b=SD3NlFu1lBo+YpotcdsTTujCxvM8pkS2h4Zm4xgrGYrIK28kn3bXJw/1 qZd8Lw8vN7/Gs7rvft1dRvK6HLuAyNMWkUC3vCz7WMRNRIykS6jS2YPcz kF04lGkG69Z9VqBDEBW8FBpfmeHkzF3nTl29LlOdMy81NQrfZUjfvJsp6 o=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none IronPort-SDR: TH2UcGYEphdKtwsoYvyNDdY7u52FzEHYlVlR6kZfdbEn9ZNDiF2S7wf7+L262B56OSCDaS4MVq CJQBWyspV1dN7bf1oIWYSVpW/k5DQblFq3Fr34fnw6rejh69lStgGAH44LijK04GDGCPP83DYR yP+9DqzZ4ftbvDUeQTSMCUQVohvGxzGxGiEzfVSd0fwbV5CwS021cxPSCjlpghDMzG0snLwQq5 Jm9/2JNZiAFwhkQAMn/vqVR9ESXjgWudm5rXJS03bxFa3xsPZAgyEOcEN7Zof+cR2x/L4Zqogc MgA= X-SBRS: None X-MesageID: 27971438 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.77,322,1596513600"; d="scan'208";a="27971438" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu Subject: [PATCH 2/8] xen/domctl: Simplify DOMCTL_CDF_ checking logic Date: Wed, 30 Sep 2020 14:42:42 +0100 Message-ID: <20200930134248.4918-3-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200930134248.4918-1-andrew.cooper3@citrix.com> References: <20200930134248.4918-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) 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 Reviewed-by: Roger Pau Monn=C3=A9 Reviewed-by: Wei Liu --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu --- 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 =3D config->flags & XEN_DOMCTL_CDF_hvm; + bool hap =3D config->flags & XEN_DOMCTL_CDF_hap; unsigned int max_vcpus; =20 if ( hvm ? !hvm_enabled : !IS_ENABLED(CONFIG_PV) ) @@ -653,13 +654,13 @@ int arch_sanitise_domain_config(struct xen_domctl_cre= atedomain *config) return -EINVAL; } =20 - 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; } =20 - 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) =20 static int sanitise_domain_config(struct xen_domctl_createdomain *config) { + bool hvm =3D config->flags & XEN_DOMCTL_CDF_hvm; + bool hap =3D config->flags & XEN_DOMCTL_CDF_hap; + bool iommu =3D 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_c= reatedomain *config) return -EINVAL; } =20 - 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; } =20 - 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; } =20 - 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; + } } =20 return arch_sanitise_domain_config(config); --=20 2.11.0