[HVM] Remove HVM halt timer. It's no longer needed since interrupts
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 10 Nov 2006 11:01:15 +0000 (11:01 +0000)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Fri, 10 Nov 2006 11:01:15 +0000 (11:01 +0000)
can wake it up now.

Signed-off-by: Xin Li <xin.b.li@intel.com>
xen/arch/x86/hvm/hvm.c
xen/arch/x86/hvm/intercept.c
xen/arch/x86/hvm/svm/svm.c
xen/arch/x86/hvm/vlapic.c
xen/arch/x86/hvm/vmx/vmx.c
xen/include/asm-x86/hvm/vcpu.h

index b3cabe5d0cf0e81c77f3a7b122318bf78d8885af..63c1235a396bb6d3ee04bcb8058711b58514f32d 100644 (file)
@@ -176,8 +176,6 @@ int hvm_vcpu_initialise(struct vcpu *v)
         get_vio(v->domain, v->vcpu_id)->vp_eport =
             v->arch.hvm_vcpu.xen_port;
 
-    init_timer(&v->arch.hvm_vcpu.hlt_timer, hlt_timer_fn, v, v->processor);
-
     if ( v->vcpu_id != 0 )
         return 0;
 
@@ -198,7 +196,6 @@ int hvm_vcpu_initialise(struct vcpu *v)
 
 void hvm_vcpu_destroy(struct vcpu *v)
 {
-    kill_timer(&v->arch.hvm_vcpu.hlt_timer);
     vlapic_destroy(v);
     hvm_funcs.vcpu_destroy(v);
 
@@ -272,10 +269,6 @@ static void hvm_vcpu_down(void)
 
 void hvm_hlt(unsigned long rflags)
 {
-    struct vcpu *v = current;
-    struct periodic_time *pt = &v->domain->arch.hvm_domain.pl_time.periodic_tm;
-    s_time_t next_pt = -1, next_wakeup;
-
     /*
      * If we halt with interrupts disabled, that's a pretty sure sign that we
      * want to shut down. In a real processor, NMIs are the only way to break
@@ -284,13 +277,6 @@ void hvm_hlt(unsigned long rflags)
     if ( unlikely(!(rflags & X86_EFLAGS_IF)) )
         return hvm_vcpu_down();
 
-    if ( !v->vcpu_id )
-        next_pt = get_scheduled(v, pt->irq, pt);
-    next_wakeup = get_apictime_scheduled(v);
-    if ( (next_pt != -1 && next_pt < next_wakeup) || next_wakeup == -1 )
-        next_wakeup = next_pt;
-    if ( next_wakeup != - 1 ) 
-        set_timer(&current->arch.hvm_vcpu.hlt_timer, next_wakeup);
     do_sched_op_compat(SCHEDOP_block, 0);
 }
 
index 839d29787ab57af559d6e2072e5681e2ec91dbe3..a145659f2dee884ba94c8080bf127cb7e6f28b24 100644 (file)
@@ -268,13 +268,6 @@ int register_io_handler(
     return 1;
 }
 
-/* Hook function for the HLT instruction emulation wakeup. */
-void hlt_timer_fn(void *data)
-{
-    struct vcpu *v = data;
-    vcpu_kick(v);
-}
-
 static __inline__ void missed_ticks(struct periodic_time *pt)
 {
     s_time_t missed_ticks;
@@ -297,16 +290,19 @@ static __inline__ void missed_ticks(struct periodic_time *pt)
 void pt_timer_fn(void *data)
 {
     struct vcpu *v = data;
-    struct periodic_time *pt = &(v->domain->arch.hvm_domain.pl_time.periodic_tm);
+    struct periodic_time *pt = &v->domain->arch.hvm_domain.pl_time.periodic_tm;
 
     pt->pending_intr_nr++;
     pt->scheduled += pt->period;
 
-    /* pick up missed timer tick */
+    /* Pick up missed timer ticks. */
     missed_ticks(pt);
-    if ( test_bit(_VCPUF_running, &v->vcpu_flags) ) {
+
+    /* No need to run the timer while a VCPU is descheduled. */
+    if ( test_bit(_VCPUF_running, &v->vcpu_flags) )
         set_timer(&pt->timer, pt->scheduled);
-    }
+
+    vcpu_kick(v);
 }
 
 /* pick up missed timer ticks at deactive time */
index 62963980b1d9e1f7461f72a2a11d73dace64577c..7b8bf462581cecdd50e70938effbffe38d2ad88a 100644 (file)
@@ -712,11 +712,13 @@ static void arch_svm_do_launch(struct vcpu *v)
 static void svm_freeze_time(struct vcpu *v)
 {
     struct periodic_time *pt=&v->domain->arch.hvm_domain.pl_time.periodic_tm;
-    
-    if ( pt->enabled && pt->first_injected && v->vcpu_id == pt->bind_vcpu 
+
+    if ( pt->enabled && pt->first_injected
+            && (v->vcpu_id == pt->bind_vcpu)
             && !v->arch.hvm_vcpu.guest_time ) {
         v->arch.hvm_vcpu.guest_time = hvm_get_guest_time(v);
-        stop_timer(&(pt->timer));
+        if ( test_bit(_VCPUF_blocked, &v->vcpu_flags) )
+            stop_timer(&pt->timer);
     }
 }
 
@@ -853,7 +855,6 @@ static void svm_migrate_timers(struct vcpu *v)
     if ( pt->enabled )
     {
         migrate_timer(&pt->timer, v->processor);
-        migrate_timer(&v->arch.hvm_vcpu.hlt_timer, v->processor);
     }
     migrate_timer(&vcpu_vlapic(v)->vlapic_timer, v->processor);
     migrate_timer(&vrtc->second_timer, v->processor);
index 7996f31b692d3ec635a83de83851fabc627cccbe..3209416157c0cd5a28a4b9d221d0f70d78579d73 100644 (file)
@@ -835,6 +835,8 @@ void vlapic_timer_fn(void *data)
     else
         vlapic_set_reg(vlapic, APIC_TMCCT, 0);
 
+    vcpu_kick(vlapic_vcpu(vlapic));
+
     HVM_DBG_LOG(DBG_LEVEL_VLAPIC_TIMER,
                 "now 0x%016"PRIx64", expire @ 0x%016"PRIx64", "
                 "timer initial count 0x%x, timer current count 0x%x.",
index 77f711a1eae79c18647d6687e30d739198750e5d..2eed6af1a35567a0b25b23a6ff0d5661f65a648a 100644 (file)
@@ -368,11 +368,13 @@ static inline void vmx_restore_dr(struct vcpu *v)
 static void vmx_freeze_time(struct vcpu *v)
 {
     struct periodic_time *pt=&v->domain->arch.hvm_domain.pl_time.periodic_tm;
-    
-    if ( pt->enabled && pt->first_injected && v->vcpu_id == pt->bind_vcpu
+
+    if ( pt->enabled && pt->first_injected
+            && (v->vcpu_id == pt->bind_vcpu)
             && !v->arch.hvm_vcpu.guest_time ) {
         v->arch.hvm_vcpu.guest_time = hvm_get_guest_time(v);
-        stop_timer(&(pt->timer));
+        if ( !test_bit(_VCPUF_blocked, &v->vcpu_flags) )
+            stop_timer(&pt->timer);
     }
 }
 
@@ -407,7 +409,6 @@ void vmx_migrate_timers(struct vcpu *v)
     if ( pt->enabled )
     {
         migrate_timer(&pt->timer, v->processor);
-        migrate_timer(&v->arch.hvm_vcpu.hlt_timer, v->processor);
     }
     migrate_timer(&vcpu_vlapic(v)->vlapic_timer, v->processor);
     migrate_timer(&vrtc->second_timer, v->processor);
index 990562cd71ac8acc7c6995a78111c453a66c64d5..0c073028eefa21f59e76eae27464d21e66663400 100644 (file)
@@ -44,9 +44,6 @@ struct hvm_vcpu {
     /* Flags */
     int                 flag_dr_dirty;
 
-    /* hlt ins emulation wakeup timer */
-    struct timer        hlt_timer;
-
     unsigned long       hvm_trace_values[5];
 
     union {