From: Paolo Bonzini Subject: Re: [PATCH] kvm: nVMX: Validate the virtual-APIC address on nested VM-entry Date: Fri, 25 Aug 2017 12:39:32 +0200 Message-ID: <0e4000ce-7c5f-3ba0-282a-9489dcfcb0b2@redhat.com> References: <20170824202447.61553-1-jmattson@google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Jim Mattson , kvm@vger.kernel.org Return-path: Received: from mail-wr0-f194.google.com ([209.85.128.194]:37479 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754734AbdHYKjf (ORCPT ); Fri, 25 Aug 2017 06:39:35 -0400 Received: by mail-wr0-f194.google.com with SMTP id p14so1227882wrg.4 for ; Fri, 25 Aug 2017 03:39:34 -0700 (PDT) In-Reply-To: <20170824202447.61553-1-jmattson@google.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 24/08/2017 22:24, Jim Mattson wrote: > According to the SDM, if the "use TPR shadow" VM-execution control is > 1, bits 11:0 of the virtual-APIC address must be 0 and the address > should set any bits beyond the processor's physical-address width. > > Signed-off-by: Jim Mattson Applied, thanks. Paolo > --- > arch/x86/kvm/vmx.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 19aa69af7c2d..abe8caf9756a 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -9915,6 +9915,18 @@ static int nested_vmx_check_msr_bitmap_controls(struct kvm_vcpu *vcpu, > return 0; > } > > +static int nested_vmx_check_tpr_shadow_controls(struct kvm_vcpu *vcpu, > + struct vmcs12 *vmcs12) > +{ > + if (!nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW)) > + return 0; > + > + if (!page_address_valid(vcpu, vmcs12->virtual_apic_page_addr)) > + return -EINVAL; > + > + return 0; > +} > + > /* > * Merge L0's and L1's MSR bitmap, return false to indicate that > * we do not use the hardware. > @@ -10601,6 +10613,9 @@ static int check_vmentry_prereqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) > if (nested_vmx_check_msr_bitmap_controls(vcpu, vmcs12)) > return VMXERR_ENTRY_INVALID_CONTROL_FIELD; > > + if (nested_vmx_check_tpr_shadow_controls(vcpu, vmcs12)) > + return VMXERR_ENTRY_INVALID_CONTROL_FIELD; > + > if (nested_vmx_check_apicv_controls(vcpu, vmcs12)) > return VMXERR_ENTRY_INVALID_CONTROL_FIELD; > >