From patchwork Wed Oct 18 08:27:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasli X-Patchwork-Id: 10014081 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 7F8BE60215 for ; Wed, 18 Oct 2017 08:30:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E2F828AF2 for ; Wed, 18 Oct 2017 08:30:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6325D28AF9; Wed, 18 Oct 2017 08:30: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 9539628AF8 for ; Wed, 18 Oct 2017 08:30:01 +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 1e4jhd-0002aE-8J; Wed, 18 Oct 2017 08:27:49 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4jhb-0002Zw-IO for xen-devel@lists.xen.org; Wed, 18 Oct 2017 08:27:47 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 36/FB-05363-28017E95; Wed, 18 Oct 2017 08:27:46 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupnkeJIrShJLcpLzFFi42JxWrrBXrdJ4Hm kQXcjj8WSj4tZHBg9ju7+zRTAGMWamZeUX5HAmrFp6ly2gkkCFdeeqzcwfuHpYuTkkBDwl7je fY0RxGYT0JPYOPsVE4gtIiArsbprDnsXIxcHs8ARRompq46wgySEBVwl9s1fydbFyMHBIqAqs ec5WJhXwEZi05Q2FoiZ8hK72i6ygticArYS10+vYQOxhYBqfr+5ygphq0q8frGLBaJXUOLkzC dgNrOAhMTBFy+YJzDyzkKSmoUktYCRaRWjenFqUVlqka6lXlJRZnpGSW5iZo6uoYGxXm5qcXF iempOYlKxXnJ+7iZGYODUMzAw7mB8/dPpEKMkB5OSKK/ugWeRQnxJ+SmVGYnFGfFFpTmpxYcY ZTg4lCR4V/E/jxQSLEpNT61Iy8wBhjBMWoKDR0mENxAkzVtckJhbnJkOkTrFqMvRcfPuHyYhl rz8vFQpcd4KkCIBkKKM0jy4EbB4usQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmLcBZApPZl 4J3KZXQEcwAR2xzukJyBEliQgpqQbG+f6BCyyC7bK3vUuafeyp/Ee3jfUTf97L4f2kPWvJciv Vi9ITLp34oHnZ0E7RPJr1c/XF5sxtZWWfE/63WljNn3Po7eJFzdtm1Sy8/eeNl6hib/eTuN9n P1X/Ozk76+9ineMP/Se4RqTnbekO4D3w5+3bGckrS0zmMKg8W32o9/69dWu6TLV07iqxFGckG moxFxUnAgCAnLG6ogIAAA== X-Env-Sender: prvs=457a530fd=sergey.dyasli@citrix.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1508315263!106734118!2 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 35894 invoked from network); 18 Oct 2017 08:27:45 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-15.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 18 Oct 2017 08:27:45 -0000 X-IronPort-AV: E=Sophos;i="5.43,395,1503360000"; d="scan'208";a="454748841" From: Sergey Dyasli To: Date: Wed, 18 Oct 2017 09:27:18 +0100 Message-ID: <20171018082722.6279-4-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 3/7] x86/msr: read VMX MSRs values into Raw policy 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 Add calculate_raw_vmx_policy() which fills Raw policy with H/W values of VMX MSRs. Host policy will contain a copy of these values. Signed-off-by: Sergey Dyasli --- xen/arch/x86/msr.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c index 9dc3de8ce1..7ac0fceb49 100644 --- a/xen/arch/x86/msr.c +++ b/xen/arch/x86/msr.c @@ -32,6 +32,37 @@ struct msr_domain_policy __read_mostly raw_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_vmx_policy(struct msr_domain_policy *dp) +{ + unsigned int i; + + if ( !cpu_has_vmx ) + return; + + for ( i = MSR_IA32_VMX_BASIC; i <= MSR_IA32_VMX_VMCS_ENUM; i++ ) + rdmsrl(i, dp->vmx.raw[i - MSR_IA32_VMX_BASIC]); + + if ( dp->vmx.procbased_ctls.allowed_1.activate_secondary_controls ) + { + rdmsrl(MSR_IA32_VMX_PROCBASED_CTLS2, dp->vmx_procbased_ctls2.raw); + + if ( dp->vmx_procbased_ctls2.allowed_1.enable_ept || + dp->vmx_procbased_ctls2.allowed_1.enable_vpid ) + rdmsrl(MSR_IA32_VMX_EPT_VPID_CAP, dp->vmx_ept_vpid_cap.raw); + } + + if ( dp->vmx.basic.default1_zero ) + { + for ( i = MSR_IA32_VMX_TRUE_PINBASED_CTLS; + i <= MSR_IA32_VMX_TRUE_ENTRY_CTLS; i++ ) + rdmsrl(i, + dp->vmx_true_ctls.raw[i - MSR_IA32_VMX_TRUE_PINBASED_CTLS]); + } + + if ( dp->vmx_procbased_ctls2.allowed_1.enable_vm_functions ) + rdmsrl(MSR_IA32_VMX_VMFUNC, dp->vmx_vmfunc.raw); +} + static void __init calculate_raw_policy(void) { struct msr_domain_policy *dp = &raw_msr_domain_policy; @@ -43,6 +74,8 @@ static void __init calculate_raw_policy(void) if ( val & MSR_PLATFORM_INFO_CPUID_FAULTING ) dp->plaform_info.cpuid_faulting = true; } + + calculate_raw_vmx_policy(dp); } static void __init calculate_host_policy(void)