From patchwork Wed Feb 26 20:22:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11407161 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D5AE1871 for ; Wed, 26 Feb 2020 20:23:43 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DDC4824670 for ; Wed, 26 Feb 2020 20:23:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="JKvLq0rp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DDC4824670 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1j73Cj-0003rc-10; Wed, 26 Feb 2020 20:22:49 +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 1j73Ci-0003rA-0M for xen-devel@lists.xenproject.org; Wed, 26 Feb 2020 20:22:48 +0000 X-Inumbo-ID: b554081a-58d5-11ea-94dc-12813bfff9fa Received: from esa6.hc3370-68.iphmx.com (unknown [216.71.155.175]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id b554081a-58d5-11ea-94dc-12813bfff9fa; Wed, 26 Feb 2020 20:22:28 +0000 (UTC) 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=Gh7zvT2QF4Vx8o2fLYvtD5CfhlnyOcj3YGLCny2yNI8=; b=JKvLq0rpHH2tDwxjqjAk5A58Wtt1Uwe31LFWJ09Tf2Y9su8bnSpolhCt x3y3Mm1RHOVLui2Nw4JlEA5kvnzdk4L+5yO7WR5taxEuE8SYzLHnvNyEa oKLJgxxKio7YPzcdW5WyTjJIr2YrKZVLLao73xFd+lttOvjquIvz/vWmZ w=; 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 (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: dZXbkmdwAMbW4Wf01LZHbVu9Kh+kI8sy9YcBytPH3uQGEs5KGSrpDTrlkKEfWCErhwC1XnYh8I FQmRdS8OCmLgwfOiVrTDLTVXa/ONoGUI21gkpqX6VvNTg512iFtrYLIpb21AcvUrdCgpSadcoZ RE6g+OZRTl8l9aqb+Kv6paO0iKgjEuvvJBqULKR1b6meNGhUC9uC3JYrlkWwnJ+Z2V5uTUp8jC Bmie3c4iXyKyhlOsMS1dKU+hghqIGpidvepkVS7GemqQkpQaUFoPACB69V2s6Si9u8hPzYFc86 b20= X-SBRS: 2.7 X-MesageID: 13496573 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="13496573" From: Andrew Cooper To: Xen-devel Date: Wed, 26 Feb 2020 20:22:17 +0000 Message-ID: <20200226202221.6555-7-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 06/10] x86/msr: Introduce and use default MSR 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_Pau_Monn=C3=A9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" For now, the default and max policies remain identical, but this will change in the future. Update XEN_SYSCTL_get_cpu_policy and init_domain_msr_policy() to use the default policies. Take the opportunity sort PV ahead of HVM, as is the prevailing style elsewhere. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Wei Liu CC: Roger Pau Monné --- xen/arch/x86/msr.c | 32 +++++++++++++++++++++++++++----- xen/arch/x86/sysctl.c | 4 ++-- xen/include/asm-x86/msr.h | 4 +++- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index 738d7123f9..519222a2b8 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -34,9 +34,11 @@ struct msr_policy __read_mostly raw_msr_policy, __read_mostly host_msr_policy; #ifdef CONFIG_PV struct msr_policy __read_mostly pv_max_msr_policy; +struct msr_policy __read_mostly pv_def_msr_policy; #endif #ifdef CONFIG_HVM struct msr_policy __read_mostly hvm_max_msr_policy; +struct msr_policy __read_mostly hvm_def_msr_policy; #endif static void __init calculate_raw_policy(void) @@ -56,6 +58,20 @@ static void __init calculate_host_policy(void) mp->platform_info.cpuid_faulting = cpu_has_cpuid_faulting; } +static void __init calculate_pv_max_policy(void) +{ + struct msr_policy *mp = &pv_max_msr_policy; + + *mp = host_msr_policy; +} + +static void __init calculate_pv_def_policy(void) +{ + struct msr_policy *mp = &pv_def_msr_policy; + + *mp = pv_max_msr_policy; +} + static void __init calculate_hvm_max_policy(void) { struct msr_policy *mp = &hvm_max_msr_policy; @@ -66,11 +82,11 @@ static void __init calculate_hvm_max_policy(void) mp->platform_info.cpuid_faulting = true; } -static void __init calculate_pv_max_policy(void) +static void __init calculate_hvm_def_policy(void) { - struct msr_policy *mp = &pv_max_msr_policy; + struct msr_policy *mp = &hvm_def_msr_policy; - *mp = host_msr_policy; + *mp = hvm_max_msr_policy; } void __init init_guest_msr_policy(void) @@ -79,17 +95,23 @@ void __init init_guest_msr_policy(void) calculate_host_policy(); if ( IS_ENABLED(CONFIG_PV) ) + { calculate_pv_max_policy(); + calculate_pv_def_policy(); + } if ( hvm_enabled ) + { calculate_hvm_max_policy(); + calculate_hvm_def_policy(); + } } int init_domain_msr_policy(struct domain *d) { struct msr_policy *mp = is_pv_domain(d) - ? (IS_ENABLED(CONFIG_PV) ? &pv_max_msr_policy : NULL) - : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_msr_policy : NULL); + ? (IS_ENABLED(CONFIG_PV) ? &pv_def_msr_policy : NULL) + : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_msr_policy : NULL); if ( !mp ) { diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c index 7ea8c38797..cad7534373 100644 --- a/xen/arch/x86/sysctl.c +++ b/xen/arch/x86/sysctl.c @@ -49,7 +49,7 @@ const struct cpu_policy system_policies[6] = { }, [ XEN_SYSCTL_cpu_policy_pv_default ] = { &pv_max_cpuid_policy, - &pv_max_msr_policy, + &pv_def_msr_policy, }, #endif #ifdef CONFIG_HVM @@ -59,7 +59,7 @@ const struct cpu_policy system_policies[6] = { }, [ XEN_SYSCTL_cpu_policy_hvm_default ] = { &hvm_max_cpuid_policy, - &hvm_max_msr_policy, + &hvm_def_msr_policy, }, #endif }; diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h index bca41a3670..41397e19cf 100644 --- a/xen/include/asm-x86/msr.h +++ b/xen/include/asm-x86/msr.h @@ -269,8 +269,10 @@ static inline void wrmsr_tsc_aux(uint32_t val) extern struct msr_policy raw_msr_policy, host_msr_policy, + pv_max_msr_policy, + pv_def_msr_policy, hvm_max_msr_policy, - pv_max_msr_policy; + hvm_def_msr_policy; /* Container object for per-vCPU MSRs */ struct vcpu_msrs