From nobody Mon Feb 9 18:19:06 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=1582748608; cv=none; d=zohomail.com; s=zohoarc; b=cIhLIaQsQVB4MsPqIltRCHkm/ADpMglT2sP5dmijAICOjz6qYcpdR7W4r+xiYLuF7y9Rn+HWEpYfevvOu5kTGLhFFy2o3yzVYpS/o/J3JAgUAlABpdWWYr9bKpuK5fN58iNhs5DJJxRTftRLXcmqzVQo9mCUEodj7UAFkF0Ka2k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582748608; 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=I1ztdYIl9SGjIp8img7C/VuoMBGw0LjunX7Rerow8Cg=; b=LpjE8xTMDXpOLOgjMmcfruVfnj7tb3wYTt1gzs+rXvBY7X6qUGK68Nw7IJ6Z0wr4w7zpPvCCBhf+dMNbvZEj0DEVP2BbSgLo9qSa3xQY36h9V7UYiqFTmMnApXzk4jKiFGCiAZvggIqydE9t0evV3IufYYULQkoYDWlyPxXkFmc= 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 158274860821078.24677836847479; Wed, 26 Feb 2020 12:23:28 -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 1j73Co-0003vO-Ah; Wed, 26 Feb 2020 20:22:54 +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 1j73Cn-0003uh-0T for xen-devel@lists.xenproject.org; Wed, 26 Feb 2020 20:22:53 +0000 Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b595a90b-58d5-11ea-94dc-12813bfff9fa; Wed, 26 Feb 2020 20:22:29 +0000 (UTC) X-Inumbo-ID: b595a90b-58d5-11ea-94dc-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1582748549; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=R21aiCvpBVK8pX/VEYsT9FBNc3fKBXVbw2HxNXegm9s=; b=BkkWXvQ4lBYMX2LFu1t4yxtDBy16z9rtJOPU01plyDqcTkGV7Dnxf9dE 9tJzP8fURf7yqSAqwx2btg16GSgHOoUcqHPZ1C8WM3gzXBlUhLibEomTm SDuWYoIc6z5NUCZew5uczjvQGP6iw6NmL3oz55JeUcnaGRlp7+cvSseRW c=; 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: gpR4kjurA5/tCzcdJ25V1t4YJUtWNdApY3/+bNFx4N1VayTDkMm439E3667pVIj9L9eJiTj64o xuHahg3BA7lFa9s5c7+HQdUG09yOh6KX7XzO0DgqEErJ46eq6kDlk9Asas6QMtlQgiZ3HG6tog kF9lR5rWTWvkl74bGk3PpRFDINLvmxmup9Yi5/cYAKKElbwT/wjQb+MWr9P0avGVWDU3R/GEto MYmNjFp44hxMYYZ6YVyUvzm2y11F4lBuYMtVwKIMiCLe5ILxZXSXoLP5S3DjxiZqovJjrSHJyi zPo= X-SBRS: 2.7 X-MesageID: 13496576 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="13496576" From: Andrew Cooper To: Xen-devel Date: Wed, 26 Feb 2020 20:22:19 +0000 Message-ID: <20200226202221.6555-9-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 08/10] x86/cpuid: Introduce and use default CPUID policies 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) For now, the default and max policies remain identical, but this will change in the future. Write calculate_{pv,hvm}_def_policy() in a way which will c= ope with simple feature differences for now. Update XEN_SYSCTL_get_cpu_policy and init_domain_cpuid_policy() to use the default policies. 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 | 55 +++++++++++++++++++++++++++++++++++++++++= ++-- xen/arch/x86/sysctl.c | 4 ++-- xen/include/asm-x86/cpuid.h | 3 ++- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c index cd9a02143c..6e01394fd2 100644 --- a/xen/arch/x86/cpuid.c +++ b/xen/arch/x86/cpuid.c @@ -18,6 +18,9 @@ const uint32_t special_features[] =3D INIT_SPECIAL_FEATUR= ES; static const uint32_t pv_max_featuremask[] =3D INIT_PV_MAX_FEATURES; static const uint32_t hvm_shadow_max_featuremask[] =3D INIT_HVM_SHADOW_MAX= _FEATURES; static const uint32_t hvm_hap_max_featuremask[] =3D INIT_HVM_HAP_MAX_FEATU= RES; +static const uint32_t pv_def_featuremask[] =3D INIT_PV_DEF_FEATURES; +static const uint32_t hvm_shadow_def_featuremask[] =3D INIT_HVM_SHADOW_DEF= _FEATURES; +static const uint32_t hvm_hap_def_featuremask[] =3D INIT_HVM_HAP_DEF_FEATU= RES; static const uint32_t deep_features[] =3D INIT_DEEP_FEATURES; =20 static int __init parse_xen_cpuid(const char *s) @@ -99,9 +102,11 @@ 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; +struct cpuid_policy __read_mostly pv_def_cpuid_policy; #endif #ifdef CONFIG_HVM struct cpuid_policy __read_mostly hvm_max_cpuid_policy; +struct cpuid_policy __read_mostly hvm_def_cpuid_policy; #endif =20 static void sanitise_featureset(uint32_t *fs) @@ -381,6 +386,23 @@ static void __init calculate_pv_max_policy(void) p->extd.raw[0xa] =3D EMPTY_LEAF; /* No SVM for PV guests. */ } =20 +static void __init calculate_pv_def_policy(void) +{ + struct cpuid_policy *p =3D &pv_def_cpuid_policy; + uint32_t pv_featureset[FSCAPINTS]; + unsigned int i; + + *p =3D pv_max_cpuid_policy; + cpuid_policy_to_featureset(p, pv_featureset); + + for ( i =3D 0; i < ARRAY_SIZE(pv_featureset); ++i ) + pv_featureset[i] &=3D pv_def_featuremask[i]; + + sanitise_featureset(pv_featureset); + cpuid_featureset_to_policy(pv_featureset, p); + recalculate_xstate(p); +} + static void __init calculate_hvm_max_policy(void) { struct cpuid_policy *p =3D &hvm_max_cpuid_policy; @@ -440,16 +462,45 @@ static void __init calculate_hvm_max_policy(void) recalculate_xstate(p); } =20 +static void __init calculate_hvm_def_policy(void) +{ + struct cpuid_policy *p =3D &hvm_def_cpuid_policy; + uint32_t hvm_featureset[FSCAPINTS]; + unsigned int i; + const uint32_t *hvm_featuremask; + + *p =3D hvm_max_cpuid_policy; + cpuid_policy_to_featureset(p, hvm_featureset); + + hvm_featuremask =3D hvm_hap_supported() ? + hvm_hap_def_featuremask : hvm_shadow_def_featuremask; + + for ( i =3D 0; i < ARRAY_SIZE(hvm_featureset); ++i ) + hvm_featureset[i] &=3D hvm_featuremask[i]; + + guest_common_feature_adjustments(hvm_featureset); + + sanitise_featureset(hvm_featureset); + cpuid_featureset_to_policy(hvm_featureset, p); + recalculate_xstate(p); +} + void __init init_guest_cpuid(void) { calculate_raw_policy(); calculate_host_policy(); =20 if ( IS_ENABLED(CONFIG_PV) ) + { calculate_pv_max_policy(); + calculate_pv_def_policy(); + } =20 if ( hvm_enabled ) + { calculate_hvm_max_policy(); + calculate_hvm_def_policy(); + } } =20 bool recheck_cpu_features(unsigned int cpu) @@ -625,8 +676,8 @@ void recalculate_cpuid_policy(struct domain *d) int init_domain_cpuid_policy(struct domain *d) { 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); + ? (IS_ENABLED(CONFIG_PV) ? &pv_def_cpuid_policy : NULL) + : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_cpuid_policy : NULL); =20 if ( !p ) { diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index cad7534373..b7948f2663 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -48,7 +48,7 @@ const struct cpu_policy system_policies[6] =3D { &pv_max_msr_policy, }, [ XEN_SYSCTL_cpu_policy_pv_default ] =3D { - &pv_max_cpuid_policy, + &pv_def_cpuid_policy, &pv_def_msr_policy, }, #endif @@ -58,7 +58,7 @@ const struct cpu_policy system_policies[6] =3D { &hvm_max_msr_policy, }, [ XEN_SYSCTL_cpu_policy_hvm_default ] =3D { - &hvm_max_cpuid_policy, + &hvm_def_cpuid_policy, &hvm_def_msr_policy, }, #endif diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h index 1b00e832d6..7baf6c9628 100644 --- a/xen/include/asm-x86/cpuid.h +++ b/xen/include/asm-x86/cpuid.h @@ -49,7 +49,8 @@ DECLARE_PER_CPU(struct cpuidmasks, cpuidmasks); extern struct cpuidmasks cpuidmask_defaults; =20 extern struct cpuid_policy raw_cpuid_policy, host_cpuid_policy, - pv_max_cpuid_policy, hvm_max_cpuid_policy; + pv_max_cpuid_policy, pv_def_cpuid_policy, + hvm_max_cpuid_policy, hvm_def_cpuid_policy; =20 extern const struct cpu_policy system_policies[]; =20 --=20 2.11.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel