From patchwork Wed Oct 18 08:27:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 10014099 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 18CCE60215 for ; Wed, 18 Oct 2017 08:30:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0797B28AAE for ; Wed, 18 Oct 2017 08:30:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F0A8928AF8; Wed, 18 Oct 2017 08:30:27 +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 A2A8A28AAE for ; Wed, 18 Oct 2017 08:30:27 +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 1e4jiJ-0002lH-2t; Wed, 18 Oct 2017 08:28:31 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4jiH-0002hp-2M for xen-devel@lists.xen.org; Wed, 18 Oct 2017 08:28:29 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 03/4C-24473-CA017E95; Wed, 18 Oct 2017 08:28:28 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprEIsWRWlGSWpSXmKPExsXitHRDpO4Kgee RBjt/Glss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBm/H1xhKtgmULHuXztbA+MC3i5GTg4JAX+J p/+/MILYbAJ6Ehtnv2ICsUUEZCVWd81h72Lk4mAWOMIoMXXVEXaQhLCAo8TzxUeZQWwWAVWJW acvgjXzCthI7P3yiBViqLzErraLYDangK3E9dNr2EBsIaCa32+uskLYqhKvX+xigegVlDg58w mYzSwgIXHwxQvmCYy8s5CkZiFJLWBkWsWoUZxaVJZapGtkpJdUlJmeUZKbmJmja2hgrJebWly cmJ6ak5hUrJecn7uJERg+9QwMjDsYp57wO8QoycGkJMqre+BZpBBfUn5KZUZicUZ8UWlOavEh RhkODiUJXg3+55FCgkWp6akVaZk5wECGSUtw8CiJ8AaCpHmLCxJzizPTIVKnGHU5Om7e/cMkx JKXn5cqJc5bAVIkAFKUUZoHNwIWVZcYZaWEeRkZGBiEeApSi3IzS1DlXzGKczAqCfM6gUzhyc wrgdv0CugIJqAj1jk9ATmiJBEhJdXA6B3kEyrcZ3DztY7rcTcFzmM2jEXtp+qDewyeHAnOb1R KWn1JbBIDi2Dxm91vrxoGblWp0uWacmeay+NNegcYDJ5M69igObu0O9Glc1ntQs8T/AXs+27L HnaqmZ4qGBt6NdHwGvN/7UNzNTwYp+ZvvaqiaPFlV8GkOTMXl/bEL4woFH2Q+KhaiaU4I9FQi 7moOBEAddm4c6UCAAA= X-Env-Sender: prvs=457a530fd=sergey.dyasli@citrix.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1508315302!103178682!1 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 7256 invoked from network); 18 Oct 2017 08:28:24 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-16.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 18 Oct 2017 08:28:24 -0000 X-IronPort-AV: E=Sophos;i="5.43,395,1503360000"; d="scan'208";a="446828216" From: Sergey Dyasli To: Date: Wed, 18 Oct 2017 09:27:16 +0100 Message-ID: <20171018082722.6279-2-sergey.dyasli@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171018082722.6279-1-sergey.dyasli@citrix.com> References: <20171018082722.6279-1-sergey.dyasli@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Kevin Tian , Jan Beulich , Jun Nakajima , Sergey Dyasli Subject: [Xen-devel] [PATCH v4 1/7] 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(); }