From patchwork Fri Oct 13 12:35:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 10004427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 212656037E for ; Fri, 13 Oct 2017 12:41:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 131E42905E for ; Fri, 13 Oct 2017 12:41:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07FE82905F; Fri, 13 Oct 2017 12:41:03 +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=-4.2 required=2.0 tests=BAYES_00, 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 AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B28A329060 for ; Fri, 13 Oct 2017 12:41:02 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2zF3-0006ds-Q6; Fri, 13 Oct 2017 12:39:05 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e2zF3-0006ZJ-1W for xen-devel@lists.xen.org; Fri, 13 Oct 2017 12:39:05 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id DF/ED-31244-8E3B0E95; Fri, 13 Oct 2017 12:39:04 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHRDpO6TzQ8 iDR78lrBY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDN+P7jCVLBNoGLdv3a2BsYFvF2MnBwSAv4S 3y7sYAOx2QT0JDbOfsUEYosIyEqs7prD3sXIxcEscIRRYuqqI+wgCWEBR4m+6yeZQWwWAVWJu y9Og9m8ArYSKx7MZIQYKi+xq+0iK4jNKWAnsXjvJLAaIaCav3snsELYqhKvX+xigegVlDg58w mYzSwgIXHwxQvmCYy8s5CkZiFJLWBkWsWoXpxaVJZapGuql1SUmZ5RkpuYmaNraGCml5taXJy YnpqTmFSsl5yfu4kRGDwMQLCDcfpl/0OMkhxMSqK8apEPIoX4kvJTKjMSizPii0pzUosPMcpw cChJ8NZvAsoJFqWmp1akZeYAwxgmLcHBoyTCaw6S5i0uSMwtzkyHSJ1i1OXouHn3D5MQS15+X qqUOK80SJEASFFGaR7cCFhMXWKUlRLmZQQ6SoinILUoN7MEVf4VozgHo5Iwrw/IFJ7MvBK4Ta +AjmACOuJdBNgRJYkIKakGxvJNEXJ317lom7wVvHVyxwsdrUnnchaHKKtdLMlYH3H8SuTJC3O v9sd8jyjdffySvWEow+p51S/uWT6s/lbe+O5M1ErFjCVfmG4wH6y4YyOu//W21nrzAzd3fn5x 1Dg9/e2xjZeVTFM2RT+Xl0xw3MEX8vHhvYjVNxx8Hl+StZm2bLFdstCa3zpKLMUZiYZazEXFi QBj7F5QpAIAAA== X-Env-Sender: prvs=452ef7b8b=sergey.dyasli@citrix.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1507898337!54001903!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50936 invoked from network); 13 Oct 2017 12:39:00 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 13 Oct 2017 12:39:00 -0000 X-IronPort-AV: E=Sophos;i="5.43,371,1503360000"; d="scan'208";a="445898688" From: Sergey Dyasli To: Date: Fri, 13 Oct 2017 13:35:07 +0100 Message-ID: <20171013123512.26102-2-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171013123512.26102-1-sergey.dyasli@citrix.com> References: <20171013123512.26102-1-sergey.dyasli@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Kevin Tian , Jan Beulich , Jun Nakajima , Sergey Dyasli Subject: [Xen-devel] [PATCH v3 1/6] x86/msr: add Raw and Host domain policies X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Raw policy contains the actual values from H/W MSRs. PLATFORM_INFO msr needs to be read again because probe_intel_cpuid_faulting() records the presence of X86_FEATURE_CPUID_FAULTING but not the presence of msr itself (if cpuid faulting is not available). Host policy might have certain features disabled if Xen decides not to use them. For now, make Host policy equal to Raw policy. Signed-off-by: Sergey Dyasli --- xen/arch/x86/msr.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index baba44f43d..9737ed706e 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -24,12 +24,34 @@ #include #include -struct msr_domain_policy __read_mostly hvm_max_msr_domain_policy, +struct msr_domain_policy __read_mostly raw_msr_domain_policy, + __read_mostly host_msr_domain_policy, + __read_mostly hvm_max_msr_domain_policy, __read_mostly pv_max_msr_domain_policy; struct msr_vcpu_policy __read_mostly hvm_max_msr_vcpu_policy, __read_mostly pv_max_msr_vcpu_policy; +static void __init calculate_raw_policy(void) +{ + struct msr_domain_policy *dp = &raw_msr_domain_policy; + uint64_t val; + + if ( rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val) == 0 ) + { + dp->plaform_info.available = true; + if ( val & MSR_PLATFORM_INFO_CPUID_FAULTING ) + dp->plaform_info.cpuid_faulting = true; + } +} + +static void __init calculate_host_policy(void) +{ + struct msr_domain_policy *dp = &host_msr_domain_policy; + + *dp = raw_msr_domain_policy; +} + static void __init calculate_hvm_max_policy(void) { struct msr_domain_policy *dp = &hvm_max_msr_domain_policy; @@ -67,6 +89,8 @@ static void __init calculate_pv_max_policy(void) void __init init_guest_msr_policy(void) { + calculate_raw_policy(); + calculate_host_policy(); calculate_hvm_max_policy(); calculate_pv_max_policy(); }