xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Yang Zhang <yang.z.zhang@intel.com>
Cc: xen-devel@lists.xensource.com, eddie.dong@intel.com, JBeulich@suse.com
Subject: Re: [PATCH v3 1/3] Nested VMX: Check VMX capability before read VMX related MSRs.
Date: Wed, 11 Sep 2013 09:35:30 +0100	[thread overview]
Message-ID: <52302B52.6040800@citrix.com> (raw)
In-Reply-To: <1378867960-10950-2-git-send-email-yang.z.zhang@intel.com>

On 11/09/13 03:52, Yang Zhang wrote:
> From: Yang Zhang <yang.z.zhang@Intel.com>
>
> VMX MSRs only available when the CPU support the VMX feature. In addition,
> VMX_TRUE* MSRs only available when bit 55 of VMX_BASIC MSR is set.
>
> Signed-off-by: Yang Zhang <yang.z.zhang@Intel.com>
> ---
>  xen/arch/x86/hvm/vmx/vmcs.c |    3 ++-
>  xen/arch/x86/hvm/vmx/vvmx.c |   22 ++++++++++++++++++++++
>  2 files changed, 24 insertions(+), 1 deletions(-)
>
> diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
> index 31347bb..f8d2a9d 100644
> --- a/xen/arch/x86/hvm/vmx/vmcs.c
> +++ b/xen/arch/x86/hvm/vmx/vmcs.c
> @@ -78,6 +78,7 @@ static DEFINE_PER_CPU(struct list_head, active_vmcs_list);
>  static DEFINE_PER_CPU(bool_t, vmxon);
>  
>  static u32 vmcs_revision_id __read_mostly;
> +u32 vmx_basic_msr_low, vmx_basic_msr_high;
>  
>  static void __init vmx_display_features(void)
>  {
> @@ -133,7 +134,7 @@ static bool_t cap_check(const char *name, u32 expected, u32 saw)
>  
>  static int vmx_init_vmcs_config(void)
>  {
> -    u32 vmx_basic_msr_low, vmx_basic_msr_high, min, opt;
> +    u32 min, opt;
>      u32 _vmx_pin_based_exec_control;
>      u32 _vmx_cpu_based_exec_control;
>      u32 _vmx_secondary_exec_control = 0;
> diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
> index cecc72f..554d5c0 100644
> --- a/xen/arch/x86/hvm/vmx/vvmx.c
> +++ b/xen/arch/x86/hvm/vmx/vvmx.c
> @@ -31,6 +31,7 @@
>  static DEFINE_PER_CPU(u64 *, vvmcs_buf);
>  
>  static void nvmx_purge_vvmcs(struct vcpu *v);
> +extern u32 vmx_basic_msr_high;
>  
>  #define VMCS_BUF_SIZE 100
>  
> @@ -1814,12 +1815,33 @@ int nvmx_handle_invvpid(struct cpu_user_regs *regs)
>  int nvmx_msr_read_intercept(unsigned int msr, u64 *msr_content)
>  {
>      struct vcpu *v = current;
> +    unsigned int eax, ebx, ecx, edx;
>      u64 data = 0, host_data = 0;
>      int r = 1;
>  
>      if ( !nestedhvm_enabled(v->domain) )
>          return 0;
>  
> +    /* VMX capablity MSRs are available only when guest supports VMX. */
> +    hvm_cpuid(0x1, &eax, &ebx, &ecx, &edx);
> +    if ( !(ecx & cpufeat_mask(X86_FEATURE_VMXE)) )
> +        return 0;
> +
> +    /*
> +     * Those MSRs are available only when bit 55 of
> +     * MSR_IA32_VMX_BASIC is set.
> +     */
> +    switch (msr) {
> +    case MSR_IA32_VMX_TRUE_PINBASED_CTLS:
> +    case MSR_IA32_VMX_TRUE_PROCBASED_CTLS:
> +    case MSR_IA32_VMX_TRUE_EXIT_CTLS:
> +    case MSR_IA32_VMX_TRUE_ENTRY_CTLS:
> +        if ( !(vmx_basic_msr_high & VMX_BASIC_DEFAULT1_ZERO >> 32) )
> +            return 0;
> +    default:
> +        break;

default:
    break;

Is completely useless here.

~Andrew

> +    }
> +
>      rdmsrl(msr, host_data);
>  
>      /*

  parent reply	other threads:[~2013-09-11  8:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11  2:52 [PATCH v3 0/3] Nested VMX: fix bugs when reading VMX MSRs Yang Zhang
2013-09-11  2:52 ` [PATCH v3 1/3] Nested VMX: Check VMX capability before read VMX related MSRs Yang Zhang
2013-09-11  7:31   ` Jan Beulich
2013-09-11  8:35   ` Andrew Cooper [this message]
2013-09-11  8:47     ` Zhang, Yang Z
2013-09-11  2:52 ` [PATCH v3 2/3] Nested VMX: Clear bit 31 of IA32_VMX_BASIC MSR Yang Zhang
2013-09-11  7:31   ` Jan Beulich
2013-09-11  2:52 ` [PATCH v3 3/3] Nested VMX: Fix IA32_VMX_CR4_FIXED1 msr emulation Yang Zhang
2013-09-11  7:39   ` Jan Beulich
2013-09-17  2:25     ` Zhang, Yang Z
2013-09-17  6:21       ` Jan Beulich
2013-09-22  5:34     ` Zhang, Yang Z
2013-09-23 10:15       ` Jan Beulich
2013-09-24  1:19         ` Zhang, Yang Z

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=52302B52.6040800@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=eddie.dong@intel.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=yang.z.zhang@intel.com \
    /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).