Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1261338

Re: [PATCH] KVM: VMX: fix SMEP and SMAP without EPT

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Paolo Bonzini <pbonzini@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH] KVM: VMX: fix SMEP and SMAP without EPT
Date Tue, 03 Nov 2015 10:50:02 +0100
Message-ID <qqGo2-WT-7@gated-at.bofh.it> (permalink)
References <qquPV-21L-19@gated-at.bofh.it>
X-Original-To Radim Krčmář <rkrcmar@redhat.com>, linux-kernel@vger.kernel.org
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 8bit
X-Scanned-By MIMEDefang 2.68 on 10.5.11.22
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 59
Organization linux.* mail to news gateway
X-Original-Cc kvm@vger.kernel.org, Feng Wu <feng.wu@intel.com>, Dongxiao Xu <dongxiao.xu@intel.com>, stable <stable@vger.kernel.org>
X-Original-Date Tue, 3 Nov 2015 10:45:01 +0100
X-Original-Message-ID <5638821D.6070701@redhat.com>
X-Original-References <1446499200-17836-1-git-send-email-rkrcmar@redhat.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1261338

Show key headers only | View raw



On 02/11/2015 22:20, Radim Krčmář wrote:
> The comment in code had it mostly right, but we enable paging for
> emulated real mode regardless of EPT.
> 
> Without EPT (which implies emulated real mode), secondary VCPUs won't
> start unless we disable SM[AE]P when the guest doesn't use paging.
> 
> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
> ---
>  arch/x86/kvm/vmx.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index b680c2e0e8a3..ab598558a7a4 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -3788,20 +3788,21 @@ static int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4)
>  		if (!is_paging(vcpu)) {
>  			hw_cr4 &= ~X86_CR4_PAE;
>  			hw_cr4 |= X86_CR4_PSE;
> -			/*
> -			 * 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/SMAP needs to be
> -			 * manually disabled when guest switches to non-paging
> -			 * mode.
> -			 */
> -			hw_cr4 &= ~(X86_CR4_SMEP | X86_CR4_SMAP);
>  		} else if (!(cr4 & X86_CR4_PAE)) {
>  			hw_cr4 &= ~X86_CR4_PAE;
>  		}
>  	}
>  
> +	if (!enable_unrestricted_guest && !is_paging(vcpu))
> +		/*
> +		 * SMEP/SMAP is disabled if CPU is in non-paging mode in
> +		 * hardware.  However KVM always uses paging mode without
> +		 * unrestricted guest.
> +		 * To emulate this behavior, SMEP/SMAP needs to be manually
> +		 * disabled when guest switches to non-paging mode.
> +		 */
> +		hw_cr4 &= ~(X86_CR4_SMEP | X86_CR4_SMAP);
> +
>  	vmcs_writel(CR4_READ_SHADOW, cr4);
>  	vmcs_writel(GUEST_CR4, hw_cr4);
>  	return 0;
> 

Applied with Cc: stable@vger.kernel.org.

Paolo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] KVM: VMX: fix SMEP and SMAP without EPT Radim Krčmář <rkrcmar@redhat.com> - 2015-11-02 22:30 +0100
  Re: [PATCH] KVM: VMX: fix SMEP and SMAP without EPT Paolo Bonzini <pbonzini@redhat.com> - 2015-11-03 10:50 +0100

csiph-web