All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Feng Wu <feng.wu@intel.com>
Cc: kevin.tian@intel.com, eddie.dong@intel.com,
	jun.nakajima@intel.com, JBeulich@suse.com,
	xen-devel@lists.xen.org
Subject: Re: [PATCH v2] x86/vmx: correct the SMEP logic for HVM_CR0_GUEST_RESERVED_BITS
Date: Mon, 28 Apr 2014 09:50:27 +0100	[thread overview]
Message-ID: <535E1653.2090405@citrix.com> (raw)
In-Reply-To: <1398653096-5214-1-git-send-email-feng.wu@intel.com>

On 28/04/14 03:44, Feng Wu wrote:
> When checking the SMEP feature for HVM guests, we should check the
> VCPU instead of the host CPU.
>
> Signed-off-by: Feng Wu <feng.wu@intel.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

> ---
>  xen/include/asm-x86/hvm/hvm.h | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
> index dcc3483..99bfc4c 100644
> --- a/xen/include/asm-x86/hvm/hvm.h
> +++ b/xen/include/asm-x86/hvm/hvm.h
> @@ -351,6 +351,19 @@ static inline int hvm_event_pending(struct vcpu *v)
>      return hvm_funcs.event_pending(v);
>  }
>  
> +static inline bool_t hvm_vcpu_has_smep(void)
> +{
> +    unsigned int eax, ebx;
> +
> +    hvm_cpuid(0x0, &eax, NULL, NULL, NULL);
> +
> +    if (eax < 0x7)
> +        return 0;
> +
> +    hvm_cpuid(0x7, NULL, &ebx, NULL, NULL);
> +    return !!(ebx & cpufeat_mask(X86_FEATURE_SMEP));
> +}
> +
>  /* These reserved bits in lower 32 remain 0 after any load of CR0 */
>  #define HVM_CR0_GUEST_RESERVED_BITS             \
>      (~((unsigned long)                          \
> @@ -370,7 +383,7 @@ static inline int hvm_event_pending(struct vcpu *v)
>          X86_CR4_DE  | X86_CR4_PSE | X86_CR4_PAE |       \
>          X86_CR4_MCE | X86_CR4_PGE | X86_CR4_PCE |       \
>          X86_CR4_OSFXSR | X86_CR4_OSXMMEXCPT |           \
> -        (cpu_has_smep ? X86_CR4_SMEP : 0) |             \
> +        (hvm_vcpu_has_smep() ? X86_CR4_SMEP : 0) |      \
>          (cpu_has_fsgsbase ? X86_CR4_FSGSBASE : 0) |     \
>          ((nestedhvm_enabled((_v)->domain) && cpu_has_vmx)\
>                        ? X86_CR4_VMXE : 0)  |             \

      reply	other threads:[~2014-04-28  8:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-28  2:44 [PATCH v2] x86/vmx: correct the SMEP logic for HVM_CR0_GUEST_RESERVED_BITS Feng Wu
2014-04-28  8:50 ` Andrew Cooper [this message]

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=535E1653.2090405@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=eddie.dong@intel.com \
    --cc=feng.wu@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.