KVM: selftests: VMX preemption timer migration test
When a nested VM with a VMX-preemption timer is migrated, verify that the nested VM and its parent VM observe the VMX-preemption timer exit close to the original expiration deadline. Signed-off-by: Makarand Sonare <makarandsonare@google.com> Reviewed-by: Jim Mattson <jmattson@google.com> Message-Id: <20200526215107.205814-3-makarandsonare@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:

committed by
Paolo Bonzini

parent
850448f35a
commit
8d7fbf01f9
@@ -2091,20 +2091,16 @@ static u64 vmx_calc_preemption_timer_value(struct kvm_vcpu *vcpu)
|
||||
{
|
||||
struct vcpu_vmx *vmx = to_vmx(vcpu);
|
||||
struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
|
||||
u64 timer_value = 0;
|
||||
|
||||
u64 l1_scaled_tsc = kvm_read_l1_tsc(vcpu, rdtsc()) >>
|
||||
VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE;
|
||||
|
||||
if (!vmx->nested.has_preemption_timer_deadline) {
|
||||
timer_value = vmcs12->vmx_preemption_timer_value;
|
||||
vmx->nested.preemption_timer_deadline = timer_value +
|
||||
l1_scaled_tsc;
|
||||
vmx->nested.preemption_timer_deadline =
|
||||
vmcs12->vmx_preemption_timer_value + l1_scaled_tsc;
|
||||
vmx->nested.has_preemption_timer_deadline = true;
|
||||
} else if (l1_scaled_tsc < vmx->nested.preemption_timer_deadline)
|
||||
timer_value = vmx->nested.preemption_timer_deadline -
|
||||
l1_scaled_tsc;
|
||||
return timer_value;
|
||||
}
|
||||
return vmx->nested.preemption_timer_deadline - l1_scaled_tsc;
|
||||
}
|
||||
|
||||
static void vmx_start_preemption_timer(struct kvm_vcpu *vcpu,
|
||||
|
Reference in New Issue
Block a user