[PATCH 12/13] KVM: nVMX: Don't mark vmcs12 as dirty when L1 writes pin controls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pin controls doesn't affect dirty logic, e.g. the preemption timer value
is loaded from vmcs12 even if vmcs12 is "clean", i.e. there is no need
to mark vmcs12 dirty when L1 writes pin controls.

KVM currently toggles the VMX_PREEMPTION_TIMER control flag when it
disables or enables the timer.  The VMWRITE to toggle the flag can be
responsible for a large percentage of vmcs12 dirtying when running KVM
as L1 (depending on the behavior of L2).

Signed-off-by: Sean Christopherson <sean.j.christopherson@xxxxxxxxx>
---
 arch/x86/kvm/vmx/nested.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 6ecdcfc67245..652022a77b64 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -4508,8 +4508,12 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
 			/*
 			 * The fields that can be updated by L1 without a vmexit are
 			 * always updated in the vmcs02, the others go down the slow
-			 * path of prepare_vmcs02.
+			 * path of prepare_vmcs02.  Pin controls is an exception as
+			 * writing pin controls doesn't affect KVM's dirty logic and
+			 * the VMX_PREEMPTION_TIMER flag may be toggled frequently,
+			 * but not frequently enough to justify shadowing.
 			 */
+		case PIN_BASED_VM_EXEC_CONTROL:
 			break;
 		default:
 			vmx->nested.dirty_vmcs12 = true;
-- 
2.21.0




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux