aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorMakarand Sonare <makarandsonare@google.com>2020-05-26 14:51:07 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2020-06-01 04:26:10 -0400
commit8d7fbf01f9afc9ea1381de705013aa3ca453009f (patch)
tree63b25e1b64880e18b437834fac8d2357b8122f88 /arch/x86/kvm
parentKVM: nVMX: Fix VMX preemption timer migration (diff)
downloadlinux-dev-8d7fbf01f9afc9ea1381de705013aa3ca453009f.tar.xz
linux-dev-8d7fbf01f9afc9ea1381de705013aa3ca453009f.zip
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>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/vmx/nested.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index da87bb8670bb..9c74a732b08d 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -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,