xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Feng Wu <feng.wu@intel.com>
Cc: kevin.tian@intel.com, ian.campbell@citrix.com,
	eddie.dong@intel.com, xen-devel@lists.xen.org, JBeulich@suse.com,
	jun.nakajima@intel.com
Subject: Re: [PATCH] x86/vmx: correct the SMEP logic for HVM_CR0_GUEST_RESERVED_BITS
Date: Wed, 23 Apr 2014 10:43:16 +0100	[thread overview]
Message-ID: <53578B34.5010707@citrix.com> (raw)
In-Reply-To: <1398263547-31877-1-git-send-email-feng.wu@intel.com>

On 23/04/14 15:32, 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>
> ---
>  xen/include/asm-x86/hvm/hvm.h | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h
> index dcc3483..74a09ef 100644
> --- a/xen/include/asm-x86/hvm/hvm.h
> +++ b/xen/include/asm-x86/hvm/hvm.h
> @@ -351,6 +351,15 @@ 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 ebx = 0, leaf = 0x7;

You need to check hvm_cpuid.0.eax for max leaf.

~Andrew

> +
> +    hvm_cpuid(leaf, 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 +379,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-23  9:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-23 14:32 [PATCH] x86/vmx: correct the SMEP logic for HVM_CR0_GUEST_RESERVED_BITS Feng Wu
2014-04-23  9:43 ` Andrew Cooper [this message]
2014-04-23 10:05 ` Jan Beulich

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=53578B34.5010707@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=eddie.dong@intel.com \
    --cc=feng.wu@intel.com \
    --cc=ian.campbell@citrix.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).