ia64/xen-unstable

changeset 9708:2a7a46dd3bd6

This is to align PIT counter with TSC more accurately.

Signed-off-by: Eddie Dong <eddie.dong@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Apr 13 11:26:01 2006 +0100 (2006-04-13)
parents 6692dd873e21
children 14f6d138c61d
files xen/arch/x86/hvm/intercept.c xen/arch/x86/hvm/svm/intr.c xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/hvm/vmx/io.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/vpit.h
line diff
     1.1 --- a/xen/arch/x86/hvm/intercept.c	Thu Apr 13 11:25:03 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/intercept.c	Thu Apr 13 11:26:01 2006 +0100
     1.3 @@ -208,8 +208,9 @@ int register_io_handler(unsigned long ad
     1.4  
     1.5  static void pit_cal_count(struct hvm_virpit *vpit)
     1.6  {
     1.7 -    u64 nsec_delta = (unsigned int)((NOW() - vpit->inject_point));
     1.8 +    u64 nsec_delta = (unsigned int)((NOW() - vpit->count_point));
     1.9  
    1.10 +    nsec_delta += vpit->count_advance;
    1.11      if (nsec_delta > vpit->period)
    1.12          HVM_DBG_LOG(DBG_LEVEL_1,
    1.13  	            "HVM_PIT: long time has passed from last injection!");
     2.1 --- a/xen/arch/x86/hvm/svm/intr.c	Thu Apr 13 11:25:03 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/svm/intr.c	Thu Apr 13 11:26:01 2006 +0100
     2.3 @@ -79,7 +79,8 @@ interrupt_post_injection(struct vcpu * v
     2.4          } else {
     2.5              vpit->pending_intr_nr--;
     2.6          }
     2.7 -        vpit->inject_point = NOW();
     2.8 +        vpit->count_advance = 0;
     2.9 +        vpit->count_point = NOW();
    2.10  
    2.11          vpit->last_pit_gtime += vpit->period_cycles;
    2.12          svm_set_guest_time(v, vpit->last_pit_gtime);
     3.1 --- a/xen/arch/x86/hvm/svm/svm.c	Thu Apr 13 11:25:03 2006 +0100
     3.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Thu Apr 13 11:26:01 2006 +0100
     3.3 @@ -679,6 +679,7 @@ static void svm_freeze_time(struct vcpu 
     3.4      
     3.5      if ( vpit->first_injected && !v->domain->arch.hvm_domain.guest_time ) {
     3.6          v->domain->arch.hvm_domain.guest_time = svm_get_guest_time(v);
     3.7 +        vpit->count_advance += (NOW() - vpit->count_point);
     3.8          stop_timer(&(vpit->pit_timer));
     3.9      }
    3.10  }
     4.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Thu Apr 13 11:25:03 2006 +0100
     4.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Thu Apr 13 11:26:01 2006 +0100
     4.3 @@ -485,6 +485,7 @@ void svm_do_resume(struct vcpu *v)
     4.4      if ( vpit->first_injected ) {
     4.5          if ( v->domain->arch.hvm_domain.guest_time ) {
     4.6              svm_set_guest_time(v, v->domain->arch.hvm_domain.guest_time);
     4.7 +            vpit->count_point = NOW();
     4.8              v->domain->arch.hvm_domain.guest_time = 0;
     4.9          }
    4.10          pickup_deactive_ticks(vpit);
     5.1 --- a/xen/arch/x86/hvm/vmx/io.c	Thu Apr 13 11:25:03 2006 +0100
     5.2 +++ b/xen/arch/x86/hvm/vmx/io.c	Thu Apr 13 11:26:01 2006 +0100
     5.3 @@ -84,7 +84,8 @@ interrupt_post_injection(struct vcpu * v
     5.4          } else {
     5.5              vpit->pending_intr_nr--;
     5.6          }
     5.7 -        vpit->inject_point = NOW();
     5.8 +        vpit->count_advance = 0;
     5.9 +        vpit->count_point = NOW();
    5.10  
    5.11          vpit->last_pit_gtime += vpit->period_cycles;
    5.12          set_guest_time(v, vpit->last_pit_gtime);
    5.13 @@ -208,6 +209,7 @@ void vmx_do_resume(struct vcpu *v)
    5.14      /* pick up the elapsed PIT ticks and re-enable pit_timer */
    5.15      if ( vpit->first_injected ) {
    5.16          if ( v->domain->arch.hvm_domain.guest_time ) {
    5.17 +            vpit->count_point = NOW();
    5.18              set_guest_time(v, v->domain->arch.hvm_domain.guest_time);
    5.19              v->domain->arch.hvm_domain.guest_time = 0;
    5.20          }
     6.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Thu Apr 13 11:25:03 2006 +0100
     6.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Thu Apr 13 11:26:01 2006 +0100
     6.3 @@ -362,6 +362,7 @@ static void vmx_freeze_time(struct vcpu 
     6.4      
     6.5      if ( vpit->first_injected && !v->domain->arch.hvm_domain.guest_time ) {
     6.6          v->domain->arch.hvm_domain.guest_time = get_guest_time(v);
     6.7 +        vpit->count_advance += (NOW() - vpit->count_point);
     6.8          stop_timer(&(vpit->pit_timer));
     6.9      }
    6.10  }
     7.1 --- a/xen/include/asm-x86/hvm/vpit.h	Thu Apr 13 11:25:03 2006 +0100
     7.2 +++ b/xen/include/asm-x86/hvm/vpit.h	Thu Apr 13 11:26:01 2006 +0100
     7.3 @@ -38,7 +38,8 @@
     7.4  struct hvm_virpit {
     7.5      /* for simulation of counter 0 in mode 2 */
     7.6      u64 period_cycles;          /* pit frequency in cpu cycles */
     7.7 -    s_time_t inject_point;      /* the time inject virt intr */
     7.8 +    s_time_t count_advance;     /* accumulated count advance since last fire */
     7.9 +    s_time_t count_point;        /* last point accumulating count advance */
    7.10      s_time_t scheduled;         /* scheduled timer interrupt */
    7.11      struct timer pit_timer;     /* periodic timer for mode 2*/
    7.12      unsigned int channel;       /* the pit channel, counter 0~2 */