Don't clobber the VMX-preemption timer value in the VMCS12 during migration on the source while handling an L1 VMLAUNCH/VMRESUME but before L2 ran. In that case the VMCS12 preemption timer value should not be touched as it will be restarted on the target from its original value. This emulates migration occurring while L1 awaits completion of its VMLAUNCH/VMRESUME instruction. Signed-off-by: Makarand Sonare <makarandsonare@xxxxxxxxxx> Signed-off-by: Peter Shier <pshier@xxxxxxxxxx> Change-Id: I376d151585d4f1449319f7512151f11bbf08c5bf --- arch/x86/kvm/vmx/nested.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 5365d7e5921ea..66155e9114114 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -3897,11 +3897,13 @@ static void sync_vmcs02_to_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12) vmcs12->guest_activity_state = GUEST_ACTIVITY_ACTIVE; if (nested_cpu_has_preemption_timer(vmcs12)) { - vmx->nested.preemption_timer_remaining = - vmx_get_preemption_timer_value(vcpu); - if (vmcs12->vm_exit_controls & VM_EXIT_SAVE_VMX_PREEMPTION_TIMER) - vmcs12->vmx_preemption_timer_value = - vmx->nested.preemption_timer_remaining; + if (!vmx->nested.nested_run_pending) { + vmx->nested.preemption_timer_remaining = + vmx_get_preemption_timer_value(vcpu); + if (vmcs12->vm_exit_controls & VM_EXIT_SAVE_VMX_PREEMPTION_TIMER) + vmcs12->vmx_preemption_timer_value = + vmx->nested.preemption_timer_remaining; + } } /* -- 2.26.1.301.g55bc3eb7cb9-goog