From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka 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 Message-ID: <53344E76.1010702@web.de> References: <1395923135-15329-1-git-send-email-feng.wu@intel.com> <1395923135-15329-5-git-send-email-feng.wu@intel.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3t2lm2MlJU5Qg359ExHCpfhSh1Nk7CSfM" To: Feng Wu , pbonzini@redhat.com, gleb@redhat.com, hpa@zytor.com, kvm@vger.kernel.org Return-path: Received: from mout.web.de ([212.227.17.11]:59872 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755416AbaC0QQy (ORCPT ); Thu, 27 Mar 2014 12:16:54 -0400 In-Reply-To: <1395923135-15329-5-git-send-email-feng.wu@intel.com> Sender: kvm-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --3t2lm2MlJU5Qg359ExHCpfhSh1Nk7CSfM Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Feng Wu > --- > arch/x86/kvm/vmx.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) >=20 > 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, u= nsigned long cr4) > hw_cr4 &=3D ~X86_CR4_PAE; > hw_cr4 |=3D 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 &=3D ~X86_CR4_SMEP; > + hw_cr4 &=3D ~X86_CR4_SMAP; Why not hw_cr4 &=3D ~(X86_CR4_SMEP | X86_CR4_SMAP); ? Jan > } else if (!(cr4 & X86_CR4_PAE)) { > hw_cr4 &=3D ~X86_CR4_PAE; > } >=20 --3t2lm2MlJU5Qg359ExHCpfhSh1Nk7CSfM Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlM0TnoACgkQitSsb3rl5xR4QQCgp4V0ZWTn5TaqbI25jnpn46HS NOMAn1ykbdvs8sLCHe6vNbk2g9yCT6gr =XB0s -----END PGP SIGNATURE----- --3t2lm2MlJU5Qg359ExHCpfhSh1Nk7CSfM--