From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752850AbdKFMRE (ORCPT ); Mon, 6 Nov 2017 07:17:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52764 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752076AbdKFMRC (ORCPT ); Mon, 6 Nov 2017 07:17:02 -0500 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5009A61B8F 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 v6 2/3] KVM: nVMX: Validate the IA32_BNDCFGS on nested VM-entry To: Wanpeng Li , linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , Wanpeng Li , Jim Mattson References: <1509929689-2935-1-git-send-email-wanpeng.li@hotmail.com> <1509929689-2935-2-git-send-email-wanpeng.li@hotmail.com> From: Paolo Bonzini Message-ID: <11dca4df-9547-bd48-0bfe-df974e4aeb89@redhat.com> Date: Mon, 6 Nov 2017 13:16:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <1509929689-2935-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]); Mon, 06 Nov 2017 12:17:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/11/2017 01:54, 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. > > Reviewed-by: Konrad Rzeszutek Wilk > Cc: Paolo Bonzini > Cc: Radim Krčmář > Cc: Jim Mattson > Signed-off-by: Wanpeng Li > --- > v5 -> v6: > * keep the right conjunct > v3 -> v4: > * simply condition > * use && instead of nested "if"s > > arch/x86/kvm/vmx.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index e6c8ffa..6cf3972 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -10805,6 +10805,11 @@ static int check_vmentry_postreqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, > return 1; > } > > + if ((vmcs12->vm_entry_controls & VM_ENTRY_LOAD_BNDCFGS) && > + (is_noncanonical_address(vmcs12->guest_bndcfgs & PAGE_MASK, vcpu) || > + (vmcs12->guest_bndcfgs & MSR_IA32_BNDCFGS_RSVD))) > + return 1; > + > return 0; > } > > Reviewed-by: Paolo Bonzini