All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: Feng Wu <feng.wu@intel.com>,
	pbonzini@redhat.com, gleb@redhat.com, hpa@zytor.com,
	kvm@vger.kernel.org
Subject: Re: [PATCH 4/4] KVM: Disable SMAP for guests in EPT realmode and EPT unpaging mode
Date: Thu, 27 Mar 2014 17:14:46 +0100	[thread overview]
Message-ID: <53344E76.1010702@web.de> (raw)
In-Reply-To: <1395923135-15329-5-git-send-email-feng.wu@intel.com>

[-- Attachment #1: Type: text/plain, Size: 1529 bytes --]

On 2014-03-27 13:25, Feng Wu wrote:
> SMAP is disabled if CPU is in non-paging mode in hardware.
> However KVM always uses paging mode to emulate guest non-paging
> mode with TDP. To emulate this behavior, SMAP needs to be
> manually disabled when guest switches to non-paging mode.
> 
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> ---
>  arch/x86/kvm/vmx.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index dcc4de3..1d37e50 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3421,13 +3421,15 @@ static int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
>  			hw_cr4 &= ~X86_CR4_PAE;
>  			hw_cr4 |= X86_CR4_PSE;
>  			/*
> -			 * SMEP is disabled if CPU is in non-paging mode in
> -			 * hardware. However KVM always uses paging mode to
> +			 * SMEP/SMAP is disabled if CPU is in non-paging mode
> +			 * in hardware. However KVM always uses paging mode to
>  			 * emulate guest non-paging mode with TDP.
> -			 * To emulate this behavior, SMEP needs to be manually
> -			 * disabled when guest switches to non-paging mode.
> +			 * To emulate this behavior, SMEP/SMAP needs to be
> +			 * manually disabled when guest switches to non-paging
> +			 * mode.
>  			 */
>  			hw_cr4 &= ~X86_CR4_SMEP;
> +			hw_cr4 &= ~X86_CR4_SMAP;

Why not

hw_cr4 &= ~(X86_CR4_SMEP | X86_CR4_SMAP);

?

Jan

>  		} else if (!(cr4 & X86_CR4_PAE)) {
>  			hw_cr4 &= ~X86_CR4_PAE;
>  		}
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

  reply	other threads:[~2014-03-27 16:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-27 12:25 [PATCH 0/4] KVM: enable Intel SMAP for KVM Feng Wu
2014-03-27 11:50 ` Paolo Bonzini
2014-03-27 17:52   ` H. Peter Anvin
2014-03-27 12:25 ` [PATCH 1/4] KVM: expose SMAP feature to guest Feng Wu
2014-03-27 12:25 ` [PATCH 2/4] KVM: Remove SMAP bit from CR4_RESERVED_BITS Feng Wu
2014-03-27 12:25 ` [PATCH 3/4] KVM: Add SMAP support when setting CR4 Feng Wu
2014-03-27 11:46   ` Paolo Bonzini
2014-03-28  5:47     ` Zhang, Yang Z
2014-03-28  6:23       ` Paolo Bonzini
2014-03-28  7:33         ` Wu, Feng
2014-03-28 14:09           ` Paolo Bonzini
2014-03-28  9:35     ` Wu, Feng
2014-03-27 12:25 ` [PATCH 4/4] KVM: Disable SMAP for guests in EPT realmode and EPT unpaging mode Feng Wu
2014-03-27 16:14   ` Jan Kiszka [this message]
2014-03-28  0:41     ` Wu, Feng

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=53344E76.1010702@web.de \
    --to=jan.kiszka@web.de \
    --cc=feng.wu@intel.com \
    --cc=gleb@redhat.com \
    --cc=hpa@zytor.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.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 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.