From nobody Mon Feb 9 20:34:30 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1582748601; cv=none; d=zohomail.com; s=zohoarc; b=KO72tKeK6cHDxnUt8GVGb6qCBf6roelMF5G8UFi3JdxEudF/MprH6+w91qhrpVvDGTPE1AjmpvFvWoxRnJ9WYGr2xrdH8IgskwoMmJ6asQCRwGLTISeRbjH6wRDGhA1zz2xmnXsUQTdQ0xW8vMyXggbAz1ypgjTt3DxXencjwxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582748601; 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=QfVI65DDyMe7M70h/YoEav8q1qNMyyX9de1RX8hpsjo=; b=eqh8LcLNJh3jUR5mPS9dWqCGDckE8rykpBDTImhRY711Xvh1gtlwoPVDNTkGtl03jzNYm8//9nbbL4lF3nWJHbB3wRHCOKhDlEThEErJgtXFEr47PsebK4/Z0VlItQfuGOYK4CkDyCtl0faRahmyuAAoO168T8IuFLU/Lg+gZM0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none 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 1582748600684624.278274870706; Wed, 26 Feb 2020 12:23:20 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j73Ce-0003ni-GY; Wed, 26 Feb 2020 20:22:44 +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 1j73Cd-0003mD-0I for xen-devel@lists.xenproject.org; Wed, 26 Feb 2020 20:22:43 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b595a90a-58d5-11ea-94dc-12813bfff9fa; Wed, 26 Feb 2020 20:22:28 +0000 (UTC) X-Inumbo-ID: b595a90a-58d5-11ea-94dc-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582748548; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OEZtdx2fk/4Ziy8SwPLeKsxlKT/7PZqtGcFqzT6kEz4=; b=CX+9O4Hd8eznDi5enc3mhXg1/w+np9LeOm3fEk5Bn3i0csxDRaT6nsOz LtTG0/2lpthEIjesbCEIOlwt7zRlEUPIAtZYsMcJWnh7Dys95YLZ/rxah 72cZiCTnofmGoE4tvucvW2mVkp3c6K8uVjVOmjFxuA4NZnfR5kU2pUOIS 8=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa6.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa6.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@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 ip4:168.245.78.127 ~all" Received-SPF: None (esa6.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=esa6.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: s0SWoYFh7DFgFmCvfQgTEFWJ7ehGrZlV5SO68Yx7/X0nRHaH1KVC3Xs15ltF1RYzUBHH9otoae fEBxvssTSM9YfxmtUgOFXRs0Hwl4jlwM98+xiW2jCd7XkRT1h5LmbngYaLjoIbwEkwsFY2zTuJ t46mi1N6HL4O+AN3xiy+ncWPiNSNzbpp2xB8+Mx45W9Dn8IcrJazOS7GyX4or1/27AbppV+PyQ odGkGeuwo5ucoJ809dA/XNrN3pJNJAy+pLjlGxBdJ2pEdlvc4rZ+fmlgxbbPd+8OQCSI3LVgVo AO8= X-SBRS: 2.7 X-MesageID: 13496574 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.70,489,1574139600"; d="scan'208";a="13496574" From: Andrew Cooper To: Xen-devel Date: Wed, 26 Feb 2020 20:22:18 +0000 Message-ID: <20200226202221.6555-8-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200226202221.6555-1-andrew.cooper3@citrix.com> References: <20200226202221.6555-1-andrew.cooper3@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 07/10] x86/cpuid: Compile out unused logic/objects 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 , Wei Liu , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) CPUID Policy objects are large (1860 bytes at the time of writing), so compiling them out based on CONFIG_{PV,HVM} makes a lot of sense. This involves a bit of complexity in init_domain_cpuid_policy() and recalculate_cpuid_policy() as is_pv_domain() can't be evaulated at compile time. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monn=C3=A9 --- xen/arch/x86/cpuid.c | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index 546ae31bb9..cd9a02143c 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -95,10 +95,14 @@ static void zero_leaves(struct cpuid_leaf *l, memset(&l[first], 0, sizeof(*l) * (last - first + 1)); } =20 -struct cpuid_policy __read_mostly raw_cpuid_policy, - __read_mostly host_cpuid_policy, - __read_mostly pv_max_cpuid_policy, - __read_mostly hvm_max_cpuid_policy; +struct cpuid_policy __read_mostly raw_cpuid_policy, + __read_mostly host_cpuid_policy; +#ifdef CONFIG_PV +struct cpuid_policy __read_mostly pv_max_cpuid_policy; +#endif +#ifdef CONFIG_HVM +struct cpuid_policy __read_mostly hvm_max_cpuid_policy; +#endif =20 static void sanitise_featureset(uint32_t *fs) { @@ -384,9 +388,6 @@ static void __init calculate_hvm_max_policy(void) unsigned int i; const uint32_t *hvm_featuremask; =20 - if ( !hvm_enabled ) - return; - *p =3D host_cpuid_policy; cpuid_policy_to_featureset(p, hvm_featureset); =20 @@ -443,8 +444,12 @@ void __init init_guest_cpuid(void) { calculate_raw_policy(); calculate_host_policy(); - calculate_pv_max_policy(); - calculate_hvm_max_policy(); + + if ( IS_ENABLED(CONFIG_PV) ) + calculate_pv_max_policy(); + + if ( hvm_enabled ) + calculate_hvm_max_policy(); } =20 bool recheck_cpu_features(unsigned int cpu) @@ -472,11 +477,18 @@ bool recheck_cpu_features(unsigned int cpu) void recalculate_cpuid_policy(struct domain *d) { struct cpuid_policy *p =3D d->arch.cpuid; - const struct cpuid_policy *max =3D - is_pv_domain(d) ? &pv_max_cpuid_policy : &hvm_max_cpuid_policy; + const struct cpuid_policy *max =3D is_pv_domain(d) + ? (IS_ENABLED(CONFIG_PV) ? &pv_max_cpuid_policy : NULL) + : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpuid_policy : NULL); uint32_t fs[FSCAPINTS], max_fs[FSCAPINTS]; unsigned int i; =20 + if ( !max ) + { + ASSERT_UNREACHABLE(); + return; + } + p->x86_vendor =3D x86_cpuid_lookup_vendor( p->basic.vendor_ebx, p->basic.vendor_ecx, p->basic.vendor_edx); =20 @@ -612,10 +624,17 @@ void recalculate_cpuid_policy(struct domain *d) =20 int init_domain_cpuid_policy(struct domain *d) { - struct cpuid_policy *p =3D - xmemdup(is_pv_domain(d) ? &pv_max_cpuid_policy - : &hvm_max_cpuid_policy); + struct cpuid_policy *p =3D is_pv_domain(d) + ? (IS_ENABLED(CONFIG_PV) ? &pv_max_cpuid_policy : NULL) + : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpuid_policy : NULL); + + if ( !p ) + { + ASSERT_UNREACHABLE(); + return -EOPNOTSUPP; + } =20 + p =3D xmemdup(p); if ( !p ) return -ENOMEM; =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel