From: Marcelo Tosatti <mtosatti@redhat.com>
To: "Yang, Wei Y" <wei.y.yang@intel.com>
Cc: Avi Kivity <avi@redhat.com>, "kvm@vger.kernel.org" <kvm@vger.kernel.org>
Subject: Re: [Patch v4 2/4] Add SMEP handling when setting CR4
Date: Tue, 31 May 2011 14:52:32 -0300 [thread overview]
Message-ID: <20110531175232.GA2721@amt.cnet> (raw)
In-Reply-To: <5D8008F58939784290FAB48F5497519844E9278011@shsmsx502.ccr.corp.intel.com>
On Sun, May 29, 2011 at 07:41:57PM +0800, Yang, Wei Y wrote:
> This patch adds SMEP handling when setting CR4.
>
> Signed-off-by: Yang, Wei <wei.y.yang@intel.com>
> Signed-off-by: Shan, Haitao <haitao.shan@intel.com>
> Signed-off-by: Li, Xin <xin.li@intel.com>
>
> ---
> arch/x86/kvm/x86.c | 15 +++++++++++++--
> 1 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 77c9d86..91bfc40 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -579,6 +579,14 @@ static bool guest_cpuid_has_xsave(struct kvm_vcpu *vcpu)
> return best && (best->ecx & bit(X86_FEATURE_XSAVE));
> }
>
> +static bool guest_cpuid_has_smep(struct kvm_vcpu *vcpu)
> +{
> + struct kvm_cpuid_entry2 *best;
> +
> + best = kvm_find_cpuid_entry(vcpu, 7, 0);
> + return best && (best->ebx & bit(X86_FEATURE_SMEP));
> +}
> +
> static void update_cpuid(struct kvm_vcpu *vcpu)
> {
> struct kvm_cpuid_entry2 *best;
> @@ -598,14 +606,17 @@ static void update_cpuid(struct kvm_vcpu *vcpu)
> int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
> {
> unsigned long old_cr4 = kvm_read_cr4(vcpu);
> - unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE | X86_CR4_PAE;
> -
> + unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE |
> + X86_CR4_PAE | X86_CR4_SMEP;
> if (cr4 & CR4_RESERVED_BITS)
> return 1;
>
> if (!guest_cpuid_has_xsave(vcpu) && (cr4 & X86_CR4_OSXSAVE))
> return 1;
>
> + if (!guest_cpuid_has_smep(vcpu) && (cr4 & X86_CR4_SMEP))
> + return 1;
> +
> if (is_long_mode(vcpu)) {
> if (!(cr4 & X86_CR4_PAE))
> return 1;
A new field in vcpu->arch.mmu.base_role for smep is required
for shadow MMU (similar to nxe).
next prev parent reply other threads:[~2011-05-31 17:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-29 11:41 [Patch v4 2/4] Add SMEP handling when setting CR4 Yang, Wei Y
2011-05-31 17:52 ` Marcelo Tosatti [this message]
2011-05-31 18:05 ` Avi Kivity
2011-05-31 18:48 ` Marcelo Tosatti
2011-05-31 19:03 ` Avi Kivity
2011-06-01 12:32 ` Marcelo Tosatti
2011-06-01 12:36 ` Avi Kivity
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=20110531175232.GA2721@amt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=wei.y.yang@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