From patchwork Tue Jul 30 13:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11065785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4A7EE174A for ; Tue, 30 Jul 2019 13:20:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39D87287ED for ; Tue, 30 Jul 2019 13:20:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DBA22870C; Tue, 30 Jul 2019 13:20:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A420E287F9 for ; Tue, 30 Jul 2019 13:20:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsS1w-0001yB-M2; Tue, 30 Jul 2019 13:19:04 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsS1v-0001xs-P2 for xen-devel@lists.xenproject.org; Tue, 30 Jul 2019 13:19:03 +0000 X-Inumbo-ID: 99543724-b2cc-11e9-8980-bc764e045a96 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 99543724-b2cc-11e9-8980-bc764e045a96; Tue, 30 Jul 2019 13:19:02 +0000 (UTC) Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: Y2DgLVJHEQjK9q8Ebwmxqa37BpT2xX+JbAp/3cTN3pID3cCARdoJVc7mYwV/MlLfz816qSj6HY 5bTazRzrNWJ+DZ09JB/lmCasqWF2kHqS9VezJxWkfwsdQCaT0WuQoTpMynDoKYqWGV9Wpp2RQg 3ewFs+43M9vaeqQyumno8gy0PCH/mkbSMNDxfiy3reM/jv/Jd3kVFYnRtnwNFhWSESyIZt+Uud Dp+eXcEGK30+Pqk5vJlRnpsrp1x4jMFEAbcSILvIG3kHz7Z4d2aNvn+k7crX7AL3itHkPpuOIE CZ8= X-SBRS: 2.7 X-MesageID: 3652029 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,326,1559534400"; d="scan'208";a="3652029" From: Paul Durrant To: Date: Tue, 30 Jul 2019 14:18:48 +0100 Message-ID: <20190730131852.20543-2-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20190730131852.20543-1-paul.durrant@citrix.com> References: <20190730131852.20543-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 1/5] domain: remove 'guest_type' field (and enum guest_type) X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Paul Durrant , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The enum guest_type was introduced in commit 6c6492780ea "pvh prep: introduce pv guest type and has_hvm_container macros" to allow a new guest type, distinct from either PV or HVM guest types, to be added in commit 8271d6522c6 "pvh: introduce PVH guest type". Subsequently, commit 33e5c32559e "x86: remove PVHv1 code" removed this third guest type. This patch removes the struct domain field and enumeration as the guest type can now be trivially determined from the 'options' field. Signed-off-by: Paul Durrant Reviewed-by: "Roger Pau Monné" Acked-by: George Dunlap Reviewed-by: Jan Beulich --- Cc: Andrew Cooper Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu v3: - Change !evaluate_nospec(cond) to evaluate_nospec(!cond) --- xen/common/domain.c | 4 ---- xen/common/domctl.c | 10 +--------- xen/common/kernel.c | 9 ++------- xen/include/xen/sched.h | 13 ++++--------- 4 files changed, 7 insertions(+), 29 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 9aefc2a680..df523c9ce4 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -353,10 +353,6 @@ struct domain *domain_create(domid_t domid, hardware_domain = d; } - /* Sort out our idea of is_{pv,hvm}_domain(). All system domains are PV. */ - d->guest_type = ((d->options & XEN_DOMCTL_CDF_hvm_guest) - ? guest_type_hvm : guest_type_pv); - TRACE_1D(TRC_DOM0_DOM_ADD, d->domain_id); /* diff --git a/xen/common/domctl.c b/xen/common/domctl.c index fa260ce5fb..3d937434af 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -187,17 +187,9 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info) (d->controller_pause_count > 0 ? XEN_DOMINF_paused : 0) | (d->debugger_attached ? XEN_DOMINF_debugged : 0) | (d->is_xenstore ? XEN_DOMINF_xs_domain : 0) | + (is_hvm_domain(d) ? XEN_DOMINF_hvm_guest : 0) | d->shutdown_code << XEN_DOMINF_shutdownshift; - switch ( d->guest_type ) - { - case guest_type_hvm: - info->flags |= XEN_DOMINF_hvm_guest; - break; - default: - break; - } - xsm_security_domaininfo(d, info); info->tot_pages = d->tot_pages; diff --git a/xen/common/kernel.c b/xen/common/kernel.c index 612575430f..f7628d73ce 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -474,19 +474,14 @@ DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) fi.submap |= (1U << XENFEAT_ARM_SMCCC_supported); #endif #ifdef CONFIG_X86 - switch ( d->guest_type ) - { - case guest_type_pv: + if ( is_pv_domain(d) ) fi.submap |= (1U << XENFEAT_mmu_pt_update_preserve_ad) | (1U << XENFEAT_highmem_assist) | (1U << XENFEAT_gnttab_map_avail_bits); - break; - case guest_type_hvm: + else fi.submap |= (1U << XENFEAT_hvm_safe_pvclock) | (1U << XENFEAT_hvm_callback_vector) | (has_pirq(d) ? (1U << XENFEAT_hvm_pirqs) : 0); - break; - } #endif break; default: diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 7f4747e154..2e6e0d3488 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -302,10 +302,6 @@ struct vm_event_domain struct evtchn_port_ops; -enum guest_type { - guest_type_pv, guest_type_hvm -}; - struct domain { domid_t domain_id; @@ -356,7 +352,6 @@ struct domain struct radix_tree_root pirq_tree; unsigned int nr_pirqs; - enum guest_type guest_type; unsigned int options; /* copy of createdomain flags */ /* Is this guest dying (i.e., a zombie)? */ @@ -918,8 +913,8 @@ void watchdog_domain_destroy(struct domain *d); static inline bool is_pv_domain(const struct domain *d) { - return IS_ENABLED(CONFIG_PV) - ? evaluate_nospec(d->guest_type == guest_type_pv) : false; + return IS_ENABLED(CONFIG_PV) && + evaluate_nospec(!(d->options & XEN_DOMCTL_CDF_hvm_guest)); } static inline bool is_pv_vcpu(const struct vcpu *v) @@ -950,8 +945,8 @@ static inline bool is_pv_64bit_vcpu(const struct vcpu *v) #endif static inline bool is_hvm_domain(const struct domain *d) { - return IS_ENABLED(CONFIG_HVM) - ? evaluate_nospec(d->guest_type == guest_type_hvm) : false; + return IS_ENABLED(CONFIG_HVM) && + evaluate_nospec(d->options & XEN_DOMCTL_CDF_hvm_guest); } static inline bool is_hvm_vcpu(const struct vcpu *v) From patchwork Tue Jul 30 13:18:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11065781 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C744D13A4 for ; Tue, 30 Jul 2019 13:20:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B659F287EF for ; Tue, 30 Jul 2019 13:20:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA2B028806; Tue, 30 Jul 2019 13:20:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 16EA3287EF for ; Tue, 30 Jul 2019 13:20:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsS1z-0001zz-QZ; Tue, 30 Jul 2019 13:19:07 +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.89) (envelope-from ) id 1hsS1y-0001z6-M5 for xen-devel@lists.xenproject.org; Tue, 30 Jul 2019 13:19:06 +0000 X-Inumbo-ID: 9852adf2-b2cc-11e9-97b7-734ebec6b223 Received: from esa4.hc3370-68.iphmx.com (unknown [216.71.155.144]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9852adf2-b2cc-11e9-97b7-734ebec6b223; Tue, 30 Jul 2019 13:19:01 +0000 (UTC) Authentication-Results: esa4.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa4.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa4.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa4.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: ZWNvrwK0n+ADvwe5haZ1I8Bfs0pBONrm3Fm1twEKIG8hjdVFDaqbQyc9hoyJDp3v0JnaZUr2gG JbaE5q5XLSGU/MGxvLP2I7djDZ3edfnsAqfHHX6QaguxLCtp9MxzYnhS0yBws7J/ovaiirFFL6 HC/xgVYliG0LbUfuWFasYd5FKFiw1UNHWmhnfBBrO26F7Ols80ciJf1n2kE+Lvxuml3DhfPxui c9qi+i5uPmGdnN6rbQuE6hBFWJ35GOlmwtME0zqMlbXLKJspXRSD5LyCEwWNR99e4+hZup2d5E wY8= X-SBRS: 2.7 X-MesageID: 3758281 X-Ironport-Server: esa4.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,326,1559534400"; d="scan'208";a="3758281" From: Paul Durrant To: Date: Tue, 30 Jul 2019 14:18:49 +0100 Message-ID: <20190730131852.20543-3-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20190730131852.20543-1-paul.durrant@citrix.com> References: <20190730131852.20543-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 2/5] x86/hvm/domain: remove the 'hap_enabled' flag X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Paul Durrant , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 sanitiziing 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 Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" Cc: George Dunlap Cc: Ian Jackson Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: George Dunlap v4: - Add missing perentheses and move hap_enabled() v3: - Re-worked as suggested by Jan - Not adding Roger's R-b as the patch has changed substantially v2: - Defer changes to shadow_domain_init() to patch #4 --- xen/arch/x86/domain.c | 13 +++++++------ xen/arch/x86/mm/paging.c | 4 ++-- xen/common/domain.c | 7 +++++++ xen/drivers/passthrough/iommu.c | 2 -- xen/include/asm-x86/hvm/domain.h | 7 ------- xen/include/asm-x86/paging.h | 2 +- xen/include/xen/sched.h | 5 +++++ 7 files changed, 22 insertions(+), 18 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 5933b3f51b..87b4c033d6 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -460,6 +460,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 enabled but not supported\n"); + return -EINVAL; + } + return 0; } @@ -564,12 +570,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; diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c index 011089368a..097a27f608 100644 --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -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; } diff --git a/xen/common/domain.c b/xen/common/domain.c index df523c9ce4..36b38e1b2e 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -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 enabled for non-HVM guest\n"); + return -EINVAL; + } + return arch_sanitise_domain_config(config); } diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c index f8c3bf53bd..37eb0f7d01 100644 --- a/xen/drivers/passthrough/iommu.c +++ b/xen/drivers/passthrough/iommu.c @@ -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. diff --git a/xen/include/asm-x86/hvm/domain.h b/xen/include/asm-x86/hvm/domain.h index 6c7c4f5aa6..bcc5621797 100644 --- a/xen/include/asm-x86/hvm/domain.h +++ b/xen/include/asm-x86/hvm/domain.h @@ -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__ */ /* diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h index cf57ca708d..ab7887f23c 100644 --- a/xen/include/asm-x86/paging.h +++ b/xen/include/asm-x86/paging.h @@ -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 diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 2e6e0d3488..cfe4f375e5 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -954,6 +954,11 @@ 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) +{ + return 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) && From patchwork Tue Jul 30 13:18:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11065767 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9D211823 for ; Tue, 30 Jul 2019 13:20:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9809A28801 for ; Tue, 30 Jul 2019 13:20:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C2C528806; Tue, 30 Jul 2019 13:20:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7D7FC28831 for ; Tue, 30 Jul 2019 13:20:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsS1x-0001yS-VM; Tue, 30 Jul 2019 13:19:05 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsS1w-0001y5-HF for xen-devel@lists.xenproject.org; Tue, 30 Jul 2019 13:19:04 +0000 X-Inumbo-ID: 99c9078f-b2cc-11e9-8980-bc764e045a96 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 99c9078f-b2cc-11e9-8980-bc764e045a96; Tue, 30 Jul 2019 13:19:03 +0000 (UTC) Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: vePXMUuuy14z8RERPNkhAteB4PKBrlhFR5Cf44uiaxk4T8O5UJOewEMC74n0onk4h07/pbrqdi gAqh7z1dLCevHH8aid+0iisbgSUBTckpCwuU/lUHI1P1Zp8jn/4MzIpq/4a7h6VM3sID0SdVTm oRLXcBKYduSOD7ycwx8Nb0DEHc9TAlGWpRJCNYFzJVrgae+uDJLKbbS7FOvacrdmzd2cJQjg9U bBps6DnErQACrrFH/VA8Iz5n/oa8YF2poVLxBav/tR02oakriurtMclQvm8Vha2mbM2U0k/llc D+E= X-SBRS: 2.7 X-MesageID: 3652030 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,326,1559534400"; d="scan'208";a="3652030" From: Paul Durrant To: Date: Tue, 30 Jul 2019 14:18:50 +0100 Message-ID: <20190730131852.20543-4-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20190730131852.20543-1-paul.durrant@citrix.com> References: <20190730131852.20543-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 3/5] x86/domain: remove the 'oos_off' flag X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Wei Liu , George Dunlap , Andrew Cooper , Tim Deegan , Paul Durrant , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The flag is not needed since the domain 'options' can now be tested directly. Signed-off-by: Paul Durrant Reviewed-by: Jan Beulich --- Cc: Tim Deegan Cc: George Dunlap Cc: Andrew Cooper Cc: Wei Liu Cc: "Roger Pau Monné" v3: - Force 'oos_off' to be set for PV guests (to avoid call to is_hvm_domain() except in ASSERT) - Dropped Tim's A-b because of the change v2: - Move some of the hunks from patch #3 - Also update the definition of shadow_domain_init() in none.c --- xen/arch/x86/mm/paging.c | 2 +- xen/arch/x86/mm/shadow/common.c | 7 ++++--- xen/arch/x86/mm/shadow/none.c | 2 +- xen/common/domain.c | 16 ++++++++++++---- xen/include/asm-x86/domain.h | 1 - xen/include/asm-x86/shadow.h | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c index 097a27f608..69aa228e46 100644 --- a/xen/arch/x86/mm/paging.c +++ b/xen/arch/x86/mm/paging.c @@ -653,7 +653,7 @@ int paging_domain_init(struct domain *d) if ( hap_enabled(d) ) hap_domain_init(d); else - rc = shadow_domain_init(d, d->options); + rc = shadow_domain_init(d); return rc; } diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c index fa18de0bb6..1187176993 100644 --- a/xen/arch/x86/mm/shadow/common.c +++ b/xen/arch/x86/mm/shadow/common.c @@ -46,7 +46,7 @@ static void sh_clean_dirty_bitmap(struct domain *); /* Set up the shadow-specific parts of a domain struct at start of day. * Called for every domain from arch_domain_create() */ -int shadow_domain_init(struct domain *d, unsigned int domcr_flags) +int shadow_domain_init(struct domain *d) { static const struct log_dirty_ops sh_ops = { .enable = sh_enable_log_dirty, @@ -62,7 +62,6 @@ int shadow_domain_init(struct domain *d, unsigned int domcr_flags) #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) d->arch.paging.shadow.oos_active = 0; - d->arch.paging.shadow.oos_off = domcr_flags & XEN_DOMCTL_CDF_oos_off; #endif d->arch.paging.shadow.pagetable_dying_op = 0; @@ -2523,11 +2522,13 @@ static void sh_update_paging_modes(struct vcpu *v) #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC) /* We need to check that all the vcpus have paging enabled to * unsync PTs. */ - if ( is_hvm_domain(d) && !d->arch.paging.shadow.oos_off ) + if ( !(d->options & XEN_DOMCTL_CDF_oos_off) ) { int pe = 1; struct vcpu *vptr; + ASSERT(is_hvm_domain(d)); + for_each_vcpu(d, vptr) { if ( !hvm_paging_enabled(vptr) ) diff --git a/xen/arch/x86/mm/shadow/none.c b/xen/arch/x86/mm/shadow/none.c index a70888bd98..2fddf4274c 100644 --- a/xen/arch/x86/mm/shadow/none.c +++ b/xen/arch/x86/mm/shadow/none.c @@ -18,7 +18,7 @@ static void _clean_dirty_bitmap(struct domain *d) ASSERT(is_pv_domain(d)); } -int shadow_domain_init(struct domain *d, unsigned int domcr_flags) +int shadow_domain_init(struct domain *d) { static const struct log_dirty_ops sh_none_ops = { .enable = _enable_log_dirty, diff --git a/xen/common/domain.c b/xen/common/domain.c index 36b38e1b2e..2df908285b 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -313,11 +313,19 @@ 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) ) + if ( !(config->flags & XEN_DOMCTL_CDF_hvm_guest) ) { - dprintk(XENLOG_INFO, "HAP enabled for non-HVM guest\n"); - return -EINVAL; + if ( config->flags & XEN_DOMCTL_CDF_hap ) + { + dprintk(XENLOG_INFO, "HAP enabled for non-HVM guest\n"); + return -EINVAL; + } + + /* + * It is only meaningful for XEN_DOMCTL_CDF_oos_off to be clear + * for HVM guests. + */ + config->flags |= XEN_DOMCTL_CDF_oos_off; } return arch_sanitise_domain_config(config); diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 933b85901f..5f9899469c 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -115,7 +115,6 @@ struct shadow_domain { /* OOS */ bool_t oos_active; - bool_t oos_off; /* Has this domain ever used HVMOP_pagetable_dying? */ bool_t pagetable_dying_op; diff --git a/xen/include/asm-x86/shadow.h b/xen/include/asm-x86/shadow.h index f29f0f652b..8ebb89c027 100644 --- a/xen/include/asm-x86/shadow.h +++ b/xen/include/asm-x86/shadow.h @@ -49,7 +49,7 @@ /* Set up the shadow-specific parts of a domain struct at start of day. * Called from paging_domain_init(). */ -int shadow_domain_init(struct domain *d, unsigned int domcr_flags); +int shadow_domain_init(struct domain *d); /* Setup the shadow-specific parts of a vcpu struct. It is called by * paging_vcpu_init() in paging.c */ From patchwork Tue Jul 30 13:18:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11065789 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5450013A4 for ; Tue, 30 Jul 2019 13:20:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45135287C3 for ; Tue, 30 Jul 2019 13:20:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 395DA287E8; Tue, 30 Jul 2019 13:20:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 80054287D2 for ; Tue, 30 Jul 2019 13:20:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsS21-00021B-6x; Tue, 30 Jul 2019 13:19:09 +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.89) (envelope-from ) id 1hsS1z-000202-Ua for xen-devel@lists.xenproject.org; Tue, 30 Jul 2019 13:19:07 +0000 X-Inumbo-ID: 9a3bb082-b2cc-11e9-9fe2-6bfb64de57db Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 9a3bb082-b2cc-11e9-9fe2-6bfb64de57db; Tue, 30 Jul 2019 13:19:04 +0000 (UTC) Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: wiy462IMc+c/DpotJiUQwM10bALNP31WQiy+e3/vCKQOQi3XJFRKGMlCh0JHIKn8qTgC3XLTI4 MtG4OfB45YLXur4DWi5U9Nu8gQdpZLIBLaVjAqAQSgsPiY5gAs4gyTrMZ6BCukjOSEPXMZA35o /UskclcHTj+fNytWMUjr2cOx8CoxcWbn4WH/lQzvn+qEy9C32K7b3CJp6xqVchsSRyUBxzIJNr 0GHbf+NccZVanOogB1EXDCYVji7z8g0KmtSNJz2z7dQ+FrWHfMIGdUR4QJFBqaF8zbUEpyxz8R 6sQ= X-SBRS: 2.7 X-MesageID: 3652032 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,326,1559534400"; d="scan'208";a="3652032" From: Paul Durrant To: Date: Tue, 30 Jul 2019 14:18:51 +0100 Message-ID: <20190730131852.20543-5-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20190730131852.20543-1-paul.durrant@citrix.com> References: <20190730131852.20543-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 4/5] domain: remove the 'is_xenstore' flag X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Paul Durrant , Jan Beulich , Daniel De Graaf , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces a convenience macro, is_xenstore_domain(), which tests the domain 'options' directly and then uses that in place of the 'is_xenstore' flag. Signed-off-by: Paul Durrant Reviewed-by: "Roger Pau Monné" Acked-by: George Dunlap --- Cc: Andrew Cooper Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Tim Deegan Cc: Wei Liu Cc: Daniel De Graaf v2: - Set 'disable_migrate' to true rather 1 --- xen/common/domain.c | 9 +++------ xen/common/domctl.c | 2 +- xen/include/xen/sched.h | 7 +++++-- xen/include/xsm/dummy.h | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/xen/common/domain.c b/xen/common/domain.c index 2df908285b..9b70626753 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -363,7 +363,7 @@ struct domain *domain_create(domid_t domid, if ( hardware_domid < 0 || hardware_domid >= DOMID_FIRST_RESERVED ) panic("The value of hardware_dom must be a valid domain ID\n"); - d->disable_migrate = 1; + d->disable_migrate = true; old_hwdom = hardware_domain; hardware_domain = d; } @@ -442,11 +442,8 @@ struct domain *domain_create(domid_t domid, watchdog_domain_init(d); init_status |= INIT_watchdog; - if ( d->options & XEN_DOMCTL_CDF_xs_domain ) - { - d->is_xenstore = 1; - d->disable_migrate = 1; - } + if ( is_xenstore_domain(d) ) + d->disable_migrate = true; d->iomem_caps = rangeset_new(d, "I/O Memory", RANGESETF_prettyprint_hex); d->irq_caps = rangeset_new(d, "Interrupts", 0); diff --git a/xen/common/domctl.c b/xen/common/domctl.c index 3d937434af..6436f8b287 100644 --- a/xen/common/domctl.c +++ b/xen/common/domctl.c @@ -186,7 +186,7 @@ void getdomaininfo(struct domain *d, struct xen_domctl_getdomaininfo *info) (d->is_shut_down ? XEN_DOMINF_shutdown : 0) | (d->controller_pause_count > 0 ? XEN_DOMINF_paused : 0) | (d->debugger_attached ? XEN_DOMINF_debugged : 0) | - (d->is_xenstore ? XEN_DOMINF_xs_domain : 0) | + (is_xenstore_domain(d) ? XEN_DOMINF_xs_domain : 0) | (is_hvm_domain(d) ? XEN_DOMINF_hvm_guest : 0) | d->shutdown_code << XEN_DOMINF_shutdownshift; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index cfe4f375e5..a62161cc54 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -375,8 +375,6 @@ struct domain bool is_privileged; /* Can this guest access the Xen console? */ bool is_console; - /* Is this a xenstore domain (not dom0)? */ - bool is_xenstore; /* Non-migratable and non-restoreable? */ bool disable_migrate; /* Is this guest being debugged by dom0? */ @@ -978,6 +976,11 @@ static inline bool is_vcpu_online(const struct vcpu *v) return !test_bit(_VPF_down, &v->pause_flags); } +static inline bool is_xenstore_domain(const struct domain *d) +{ + return d->options & XEN_DOMCTL_CDF_xs_domain; +} + extern bool sched_smt_power_savings; extern enum cpufreq_controller { diff --git a/xen/include/xsm/dummy.h b/xen/include/xsm/dummy.h index ef52bb1764..b8e185e6fa 100644 --- a/xen/include/xsm/dummy.h +++ b/xen/include/xsm/dummy.h @@ -79,7 +79,7 @@ static always_inline int xsm_default_action( { return 0; case XSM_XS_PRIV: - if ( src->is_xenstore ) + if ( is_xenstore_domain(src) ) return 0; } /* fall through */ From patchwork Tue Jul 30 13:18:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11065783 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EBC4013A4 for ; Tue, 30 Jul 2019 13:20:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DD0522871A for ; Tue, 30 Jul 2019 13:20:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D1563287D2; Tue, 30 Jul 2019 13:20:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6F47C287D4 for ; Tue, 30 Jul 2019 13:20:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsS1z-0001zP-9u; Tue, 30 Jul 2019 13:19:07 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hsS1x-0001yP-RY for xen-devel@lists.xenproject.org; Tue, 30 Jul 2019 13:19:05 +0000 X-Inumbo-ID: 9a4efb19-b2cc-11e9-8980-bc764e045a96 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 9a4efb19-b2cc-11e9-8980-bc764e045a96; Tue, 30 Jul 2019 13:19:04 +0000 (UTC) Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=paul.durrant@citrix.com; spf=Pass smtp.mailfrom=Paul.Durrant@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of paul.durrant@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="paul.durrant@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Paul.Durrant@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="Paul.Durrant@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Paul.Durrant@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 1zDfZbfPR/Ze1Uv/m4dqcDUA6PKO2QmtoAZKpMtsSUi2lJKhWd+kbK6+Ki6a+PRaYFJpDthpzg 9Fpxm41hxxDjWvo2AAtxx9VConoqdKJjH8bFGAMhQlheuFVK/z1MLgxNb0BPLDX5h6SM/JEJbW /6KCxUjzktP9ykexdjDZZTL6Ju1+CA+dXdHrk9WS6R9qniIBHmTkrXjiNMEndb7+QRAtJZMeSb 2Ng/xeCv5v7dwP6w09opzPDLG8a+0Du4snsb0ns8T39fudB3HdaGrvbReUPVID3qZ+BP5mhuMv ukw= X-SBRS: 2.7 X-MesageID: 3652031 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.64,326,1559534400"; d="scan'208";a="3652031" From: Paul Durrant To: Date: Tue, 30 Jul 2019 14:18:52 +0100 Message-ID: <20190730131852.20543-6-paul.durrant@citrix.com> X-Mailer: git-send-email 2.20.1.2.gb21ebb671 In-Reply-To: <20190730131852.20543-1-paul.durrant@citrix.com> References: <20190730131852.20543-1-paul.durrant@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH v4 5/5] x86/domain: remove the 's3_integrity' flag X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Paul Durrant , Wei Liu , Jan Beulich , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The flag is not needed since the domain 'options' can now be tested directly. Signed-off-by: Paul Durrant Reviewed-by: "Roger Pau Monné" Reviewed-by: Jan Beulich --- Cc: Andrew Cooper Cc: Wei Liu v4: - s/TBOOT/CONFIG_TBOOT/g v3: - Also sanitise the flag against CONFIG_TBOOT being set --- xen/arch/x86/domain.c | 9 +++++++-- xen/arch/x86/setup.c | 2 +- xen/arch/x86/tboot.c | 2 +- xen/include/asm-x86/domain.h | 2 -- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 87b4c033d6..fbc70b9f94 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -466,6 +466,13 @@ int arch_sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } + if ( (config->flags & XEN_DOMCTL_CDF_s3_integrity) && + !IS_ENABLED(CONFIG_TBOOT) ) + { + dprintk(XENLOG_INFO, "S3 integrity check not valid without CONFIG_TBOOT\n"); + return -EINVAL; + } + return 0; } @@ -544,8 +551,6 @@ int arch_domain_create(struct domain *d, d->domain_id); } - d->arch.s3_integrity = config->flags & XEN_DOMCTL_CDF_s3_integrity; - emflags = config->arch.emulation_flags; if ( is_hardware_domain(d) && is_pv_domain(d) ) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index d2011910fa..277170f386 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -689,7 +689,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) .stop_bits = 1 }; struct xen_domctl_createdomain dom0_cfg = { - .flags = XEN_DOMCTL_CDF_s3_integrity, + .flags = IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity : 0, .max_evtchn_port = -1, .max_grant_frames = opt_max_grant_frames, .max_maptrack_frames = opt_max_maptrack_frames, diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c index f3fdee4d39..3db8a8a8d8 100644 --- a/xen/arch/x86/tboot.c +++ b/xen/arch/x86/tboot.c @@ -212,7 +212,7 @@ static void tboot_gen_domain_integrity(const uint8_t key[TB_KEY_SIZE], vmac_set_key((uint8_t *)key, &ctx); for_each_domain( d ) { - if ( !d->arch.s3_integrity ) + if ( !(d->options & XEN_DOMCTL_CDF_s3_integrity) ) continue; printk("MACing Domain %u\n", d->domain_id); diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 5f9899469c..5c038a1065 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -295,8 +295,6 @@ struct arch_domain uint32_t pci_cf8; uint8_t cmos_idx; - bool_t s3_integrity; - union { struct pv_domain pv; struct hvm_domain hvm;