x86/VPMU: save VPMU state for PV guests during context switch
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Thu, 9 Jul 2015 11:51:42 +0000 (13:51 +0200)
committerJan Beulich <jbeulich@suse.com>
Thu, 9 Jul 2015 11:51:42 +0000 (13:51 +0200)
Save VPMU state during context switch for both HVM and PV(H) guests.

A subsequent patch ("x86/VPMU: NMI-based VPMU support") will make it possible
for vpmu_switch_to() to call vmx_vmcs_try_enter()->vcpu_pause() which needs
is_running to be correctly set/cleared. To prepare for that, call context_saved()
before vpmu_switch_to() is executed. (Note that while this change could have
been dalayed until that later patch, the changes are harmless to existing code
and so we do it here)

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Dietmar Hahn <dietmar.hahn@ts.fujitsu.com>
xen/arch/x86/domain.c

index ff21db407b6bb1d0afffb56edee3b3739f9677c0..4487326b0fdd17afa78cf5bbb2b27103881cedcb 100644 (file)
@@ -1587,17 +1587,14 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
     }
 
     if ( prev != next )
-        _update_runstate_area(prev);
-
-    if ( is_hvm_domain(prevd) )
     {
-        if (prev != next)
-            vpmu_switch_from(prev);
-
-        if ( !list_empty(&prev->arch.hvm_vcpu.tm_list) )
-            pt_save_timer(prev);
+        _update_runstate_area(prev);
+        vpmu_switch_from(prev);
     }
 
+    if ( is_hvm_domain(prevd) && !list_empty(&prev->arch.hvm_vcpu.tm_list) )
+        pt_save_timer(prev);
+
     local_irq_disable();
 
     set_current(next);
@@ -1635,15 +1632,16 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
                            !is_hardware_domain(nextd));
     }
 
-    if (is_hvm_domain(nextd) && (prev != next) )
-        /* Must be done with interrupts enabled */
-        vpmu_switch_to(next);
-
     context_saved(prev);
 
     if ( prev != next )
+    {
         _update_runstate_area(next);
 
+        /* Must be done with interrupts enabled */
+        vpmu_switch_to(next);
+    }
+
     /* Ensure that the vcpu has an up-to-date time base. */
     update_vcpu_system_time(next);