From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH v3 2/3] KVM: nVMX: Validate the IA32_BNDCFGS on nested VM-entry Date: Thu, 2 Nov 2017 18:50:08 +0100 Message-ID: <0d8c0a81-9b0d-ef0c-ad5d-bd08b139eebe@redhat.com> References: <1509611499-9401-1-git-send-email-wanpeng.li@hotmail.com> <1509611499-9401-2-git-send-email-wanpeng.li@hotmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li , Jim Mattson To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:49332 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932945AbdKBRuL (ORCPT ); Thu, 2 Nov 2017 13:50:11 -0400 In-Reply-To: <1509611499-9401-2-git-send-email-wanpeng.li@hotmail.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 02/11/2017 09:31, Wanpeng Li wrote: > From: Wanpeng Li > > According to the SDM, if the "load IA32_BNDCFGS" VM-entry controls is 1, the > following checks are performed on the field for the IA32_BNDCFGS MSR: > - Bits reserved in the IA32_BNDCFGS MSR must be 0. > - The linear address in bits 63:12 must be canonical. > > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Jim Mattson > Signed-off-by: Wanpeng Li > --- > arch/x86/kvm/vmx.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index e6c8ffa..f29f57d 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -10805,6 +10805,13 @@ static int check_vmentry_postreqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, > return 1; > } > > + if (kvm_mpx_supported() && > + (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS)) { Whenever !kvm_mpx_supported() is true, the bit is not set in vmcs12->vm_entry_controls (see nested_vmx_setup_ctls_msrs), so the condition can be simplified. Please also use && instead of nested "if"s. Thanks, Paolo > + if (is_noncanonical_address(vmcs12->guest_bndcfgs & PAGE_MASK, vcpu) || > + (vmcs12->guest_bndcfgs & MSR_IA32_BNDCFGS_RSVD)) > + return 1; > + } > + > return 0; > } > >