From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Hildenbrand Subject: Re: [PATCH] KVM: nVMX: initialize PML fields in vmcs02 Date: Tue, 4 Apr 2017 14:44:12 +0200 Message-ID: References: <20170404121853.28057-1-lprosek@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: kai.huang@linux.intel.com, wanpeng.li@hotmail.com To: Ladi Prosek , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:45436 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbdDDMoP (ORCPT ); Tue, 4 Apr 2017 08:44:15 -0400 In-Reply-To: <20170404121853.28057-1-lprosek@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On 04.04.2017 14:18, Ladi Prosek wrote: > L2 was running with uninitialized PML fields which led to incomplete > dirty bitmap logging. This manifested as all kinds of subtle erratic > behavior of the nested guest. > > Fixes: 843e4330573c ("KVM: VMX: Add PML support in VMX") > Signed-off-by: Ladi Prosek > --- > arch/x86/kvm/vmx.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c > index 2ee00db..f47d701 100644 > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -10267,6 +10267,18 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12, > > } > > + if (enable_pml) { > + /* > + * Conceptually we want to copy the PML address and index from > + * vmcs01 here, and then back to vmcs01 on nested vmexit. But, > + * since we always flush the log on each vmexit, this happens we == KVM running in g2? If so, other hypervisors might handle this differently. > + * to be equivalent to simply resetting the fields in vmcs02. > + */ > + ASSERT(vmx->pml_pg); > + vmcs_write64(PML_ADDRESS, page_to_phys(vmx->pml_pg)); > + vmcs_write16(GUEST_PML_INDEX, PML_ENTITY_NUM - 1); > + } > + > if (nested_cpu_has_ept(vmcs12)) { > kvm_mmu_unload(vcpu); > nested_ept_init_mmu_context(vcpu); > -- Thanks, David