xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Dyasli <sergey.dyasli@citrix.com>
To: xen-devel@lists.xen.org
Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>,
	Kevin Tian <kevin.tian@intel.com>,
	Jan Beulich <jbeulich@suse.com>,
	Jun Nakajima <jun.nakajima@intel.com>,
	Sergey Dyasli <sergey.dyasli@citrix.com>
Subject: [PATCH v3 3/6] x86/msr: read VMX MSRs values into Raw policy
Date: Fri, 13 Oct 2017 13:35:09 +0100	[thread overview]
Message-ID: <20171013123512.26102-4-sergey.dyasli@citrix.com> (raw)
In-Reply-To: <20171013123512.26102-1-sergey.dyasli@citrix.com>

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 <sergey.dyasli@citrix.com>
---
 xen/arch/x86/msr.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 77 insertions(+)

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 24029a2ac1..955aba0849 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -32,6 +32,81 @@ 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)
+{
+    if ( !cpu_has_vmx )
+        return;
+
+    dp->vmx_basic.available = true;
+    rdmsrl(MSR_IA32_VMX_BASIC, dp->vmx_basic.u.raw);
+
+    dp->vmx_pinbased_ctls.available = true;
+    rdmsrl(MSR_IA32_VMX_PINBASED_CTLS, dp->vmx_pinbased_ctls.u.raw);
+
+    dp->vmx_procbased_ctls.available = true;
+    rdmsrl(MSR_IA32_VMX_PROCBASED_CTLS, dp->vmx_procbased_ctls.u.raw);
+
+    dp->vmx_exit_ctls.available = true;
+    rdmsrl(MSR_IA32_VMX_EXIT_CTLS, dp->vmx_exit_ctls.u.raw);
+
+    dp->vmx_entry_ctls.available = true;
+    rdmsrl(MSR_IA32_VMX_ENTRY_CTLS, dp->vmx_entry_ctls.u.raw);
+
+    dp->vmx_misc.available = true;
+    rdmsrl(MSR_IA32_VMX_MISC, dp->vmx_misc.u.raw);
+
+    dp->vmx_cr0_fixed0.available = true;
+    rdmsrl(MSR_IA32_VMX_CR0_FIXED0, dp->vmx_cr0_fixed0.u.raw);
+
+    dp->vmx_cr0_fixed1.available = true;
+    rdmsrl(MSR_IA32_VMX_CR0_FIXED1, dp->vmx_cr0_fixed1.u.raw);
+
+    dp->vmx_cr4_fixed0.available = true;
+    rdmsrl(MSR_IA32_VMX_CR4_FIXED0, dp->vmx_cr4_fixed0.u.raw);
+
+    dp->vmx_cr4_fixed1.available = true;
+    rdmsrl(MSR_IA32_VMX_CR4_FIXED1, dp->vmx_cr4_fixed1.u.raw);
+
+    dp->vmx_vmcs_enum.available = true;
+    rdmsrl(MSR_IA32_VMX_VMCS_ENUM, dp->vmx_vmcs_enum.u.raw);
+
+    if ( dp->vmx_procbased_ctls.u.allowed_1.activate_secondary_controls )
+    {
+        dp->vmx_procbased_ctls2.available = true;
+        rdmsrl(MSR_IA32_VMX_PROCBASED_CTLS2, dp->vmx_procbased_ctls2.u.raw);
+
+        if ( dp->vmx_procbased_ctls2.u.allowed_1.enable_ept ||
+             dp->vmx_procbased_ctls2.u.allowed_1.enable_vpid )
+        {
+            dp->vmx_ept_vpid_cap.available = true;
+            rdmsrl(MSR_IA32_VMX_EPT_VPID_CAP, dp->vmx_ept_vpid_cap.u.raw);
+        }
+    }
+
+    if ( dp->vmx_basic.u.default1_zero )
+    {
+        dp->vmx_true_pinbased_ctls.available = true;
+        rdmsrl(MSR_IA32_VMX_TRUE_PINBASED_CTLS,
+               dp->vmx_true_pinbased_ctls.u.raw);
+
+        dp->vmx_true_procbased_ctls.available = true;
+        rdmsrl(MSR_IA32_VMX_TRUE_PROCBASED_CTLS,
+               dp->vmx_true_procbased_ctls.u.raw);
+
+        dp->vmx_true_exit_ctls.available = true;
+        rdmsrl(MSR_IA32_VMX_TRUE_EXIT_CTLS, dp->vmx_true_exit_ctls.u.raw);
+
+        dp->vmx_true_entry_ctls.available = true;
+        rdmsrl(MSR_IA32_VMX_TRUE_ENTRY_CTLS, dp->vmx_true_entry_ctls.u.raw);
+    }
+
+    if ( dp->vmx_procbased_ctls2.u.allowed_1.enable_vm_functions )
+    {
+        dp->vmx_vmfunc.available = true;
+        rdmsrl(MSR_IA32_VMX_VMFUNC, dp->vmx_vmfunc.u.raw);
+    }
+}
+
 static void __init calculate_raw_policy(void)
 {
     struct msr_domain_policy *dp = &raw_msr_domain_policy;
@@ -43,6 +118,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)
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-10-13 12:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-13 12:35 [PATCH v3 0/6] VMX MSRs policy for Nested Virt: part 1 Sergey Dyasli
2017-10-13 12:35 ` [PATCH v3 1/6] x86/msr: add Raw and Host domain policies Sergey Dyasli
2017-10-13 12:35 ` [PATCH v3 2/6] x86/msr: add VMX MSRs into struct msr_domain_policy Sergey Dyasli
2017-10-13 15:16   ` Andrew Cooper
2017-10-16  7:42     ` Sergey Dyasli
2017-10-16 14:01       ` Andrew Cooper
2017-10-18  7:30         ` Sergey Dyasli
2017-10-13 12:35 ` Sergey Dyasli [this message]
2017-10-13 12:35 ` [PATCH v3 4/6] x86/msr: add VMX MSRs into HVM_max domain policy Sergey Dyasli
2017-10-13 12:35 ` [PATCH v3 5/6] x86/msr: update domain policy on CPUID policy changes Sergey Dyasli
2017-10-13 15:25   ` Andrew Cooper
2017-10-16  7:46     ` Sergey Dyasli
2017-10-13 12:35 ` [PATCH v3 6/6] x86/msr: handle VMX MSRs with guest_rd/wrmsr() Sergey Dyasli
2017-10-13 15:38   ` Andrew Cooper
2017-10-16 14:50     ` Sergey Dyasli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171013123512.26102-4-sergey.dyasli@citrix.com \
    --to=sergey.dyasli@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).