From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755450AbdJJIgw (ORCPT ); Tue, 10 Oct 2017 04:36:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58488 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752207AbdJJIgv (ORCPT ); Tue, 10 Oct 2017 04:36:51 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 05C3525789 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=pbonzini@redhat.com Subject: Re: [PATCH v2 2/2] KVM: VMX: Don't expose unrestricted_guest is enabled if ept is disabled To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li , Jim Mattson References: <1507546852-6153-1-git-send-email-wanpeng.li@hotmail.com> <1507546852-6153-2-git-send-email-wanpeng.li@hotmail.com> From: Paolo Bonzini Message-ID: Date: Tue, 10 Oct 2017 10:36:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1507546852-6153-2-git-send-email-wanpeng.li@hotmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 10 Oct 2017 08:36:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/10/2017 13:00, Wanpeng Li wrote: > From: Wanpeng Li > > SDM mentioned: > > "If either the “unrestricted guest” VM-execution control or the “mode-based > execute control for EPT” VM- execution control is 1, the “enable EPT” > VM-execution control must also be 1." > > However, we can still observe unrestricted_guest is Y after inserting the kvm-intel.ko > w/ ept=N. It depends on later starts a guest in order that the function > vmx_compute_secondary_exec_control() can be executed, then both the module parameter > and exec control fields will be amended. > > This patch fixes it by amending module parameter immediately during vmcs data setup. > > Reviewed-by: Jim Mattson > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Jim Mattson > Signed-off-by: Wanpeng Li > --- > v1 -> v2: > * reduce to just "enable_ept = 0" > > arch/x86/kvm/vmx.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index ab0f16e..dedff59 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -6730,16 +6730,13 @@ static __init int hardware_setup(void) > if (!cpu_has_vmx_ept() || > !cpu_has_vmx_ept_4levels() || > !cpu_has_vmx_ept_mt_wb() || > - !cpu_has_vmx_invept_global()) { > + !cpu_has_vmx_invept_global()) > enable_ept = 0; > - enable_unrestricted_guest = 0; > - enable_ept_ad_bits = 0; > - } > > if (!cpu_has_vmx_ept_ad_bits() || !enable_ept) > enable_ept_ad_bits = 0; > > - if (!cpu_has_vmx_unrestricted_guest()) > + if (!cpu_has_vmx_unrestricted_guest() || !enable_ept) > enable_unrestricted_guest = 0; > > if (!cpu_has_vmx_flexpriority()) > Queued both, thanks. Paolo