All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: nVMX: initialize PML fields in vmcs02
@ 2017-04-04 12:18 Ladi Prosek
  2017-04-04 12:44 ` David Hildenbrand
  2017-04-05 14:49 ` Radim Krčmář
  0 siblings, 2 replies; 11+ messages in thread
From: Ladi Prosek @ 2017-04-04 12:18 UTC (permalink / raw)
  To: kvm; +Cc: kai.huang, wanpeng.li

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 <lprosek@redhat.com>
---
 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
+		 * 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);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-04-05 14:49 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-04 12:18 [PATCH] KVM: nVMX: initialize PML fields in vmcs02 Ladi Prosek
2017-04-04 12:44 ` David Hildenbrand
2017-04-04 12:55   ` Ladi Prosek
2017-04-04 13:09     ` David Hildenbrand
2017-04-04 13:19       ` Ladi Prosek
2017-04-04 13:34         ` David Hildenbrand
2017-04-04 13:25       ` David Hildenbrand
2017-04-04 13:37         ` Ladi Prosek
2017-04-04 13:55         ` Paolo Bonzini
2017-04-04 14:22           ` David Hildenbrand
2017-04-05 14:49 ` Radim Krčmář

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.