# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 2a7a46dd3bd6a600deee21990aef41456cba9724
# Parent 6692dd873e21d74073a3c61d5905e55ee0ffd8be
This is to align PIT counter with TSC more accurately.
Signed-off-by: Eddie Dong <eddie.dong@xxxxxxxxx>
diff -r 6692dd873e21 -r 2a7a46dd3bd6 xen/arch/x86/hvm/intercept.c
--- a/xen/arch/x86/hvm/intercept.c Thu Apr 13 10:25:03 2006
+++ b/xen/arch/x86/hvm/intercept.c Thu Apr 13 10:26:01 2006
@@ -208,8 +208,9 @@
static void pit_cal_count(struct hvm_virpit *vpit)
{
- u64 nsec_delta = (unsigned int)((NOW() - vpit->inject_point));
-
+ u64 nsec_delta = (unsigned int)((NOW() - vpit->count_point));
+
+ nsec_delta += vpit->count_advance;
if (nsec_delta > vpit->period)
HVM_DBG_LOG(DBG_LEVEL_1,
"HVM_PIT: long time has passed from last injection!");
diff -r 6692dd873e21 -r 2a7a46dd3bd6 xen/arch/x86/hvm/svm/intr.c
--- a/xen/arch/x86/hvm/svm/intr.c Thu Apr 13 10:25:03 2006
+++ b/xen/arch/x86/hvm/svm/intr.c Thu Apr 13 10:26:01 2006
@@ -79,7 +79,8 @@
} else {
vpit->pending_intr_nr--;
}
- vpit->inject_point = NOW();
+ vpit->count_advance = 0;
+ vpit->count_point = NOW();
vpit->last_pit_gtime += vpit->period_cycles;
svm_set_guest_time(v, vpit->last_pit_gtime);
diff -r 6692dd873e21 -r 2a7a46dd3bd6 xen/arch/x86/hvm/svm/svm.c
--- a/xen/arch/x86/hvm/svm/svm.c Thu Apr 13 10:25:03 2006
+++ b/xen/arch/x86/hvm/svm/svm.c Thu Apr 13 10:26:01 2006
@@ -679,6 +679,7 @@
if ( vpit->first_injected && !v->domain->arch.hvm_domain.guest_time ) {
v->domain->arch.hvm_domain.guest_time = svm_get_guest_time(v);
+ vpit->count_advance += (NOW() - vpit->count_point);
stop_timer(&(vpit->pit_timer));
}
}
diff -r 6692dd873e21 -r 2a7a46dd3bd6 xen/arch/x86/hvm/svm/vmcb.c
--- a/xen/arch/x86/hvm/svm/vmcb.c Thu Apr 13 10:25:03 2006
+++ b/xen/arch/x86/hvm/svm/vmcb.c Thu Apr 13 10:26:01 2006
@@ -485,6 +485,7 @@
if ( vpit->first_injected ) {
if ( v->domain->arch.hvm_domain.guest_time ) {
svm_set_guest_time(v, v->domain->arch.hvm_domain.guest_time);
+ vpit->count_point = NOW();
v->domain->arch.hvm_domain.guest_time = 0;
}
pickup_deactive_ticks(vpit);
diff -r 6692dd873e21 -r 2a7a46dd3bd6 xen/arch/x86/hvm/vmx/io.c
--- a/xen/arch/x86/hvm/vmx/io.c Thu Apr 13 10:25:03 2006
+++ b/xen/arch/x86/hvm/vmx/io.c Thu Apr 13 10:26:01 2006
@@ -84,7 +84,8 @@
} else {
vpit->pending_intr_nr--;
}
- vpit->inject_point = NOW();
+ vpit->count_advance = 0;
+ vpit->count_point = NOW();
vpit->last_pit_gtime += vpit->period_cycles;
set_guest_time(v, vpit->last_pit_gtime);
@@ -208,6 +209,7 @@
/* pick up the elapsed PIT ticks and re-enable pit_timer */
if ( vpit->first_injected ) {
if ( v->domain->arch.hvm_domain.guest_time ) {
+ vpit->count_point = NOW();
set_guest_time(v, v->domain->arch.hvm_domain.guest_time);
v->domain->arch.hvm_domain.guest_time = 0;
}
diff -r 6692dd873e21 -r 2a7a46dd3bd6 xen/arch/x86/hvm/vmx/vmx.c
--- a/xen/arch/x86/hvm/vmx/vmx.c Thu Apr 13 10:25:03 2006
+++ b/xen/arch/x86/hvm/vmx/vmx.c Thu Apr 13 10:26:01 2006
@@ -362,6 +362,7 @@
if ( vpit->first_injected && !v->domain->arch.hvm_domain.guest_time ) {
v->domain->arch.hvm_domain.guest_time = get_guest_time(v);
+ vpit->count_advance += (NOW() - vpit->count_point);
stop_timer(&(vpit->pit_timer));
}
}
diff -r 6692dd873e21 -r 2a7a46dd3bd6 xen/include/asm-x86/hvm/vpit.h
--- a/xen/include/asm-x86/hvm/vpit.h Thu Apr 13 10:25:03 2006
+++ b/xen/include/asm-x86/hvm/vpit.h Thu Apr 13 10:26:01 2006
@@ -38,7 +38,8 @@
struct hvm_virpit {
/* for simulation of counter 0 in mode 2 */
u64 period_cycles; /* pit frequency in cpu cycles */
- s_time_t inject_point; /* the time inject virt intr */
+ s_time_t count_advance; /* accumulated count advance since last fire */
+ s_time_t count_point; /* last point accumulating count advance */
s_time_t scheduled; /* scheduled timer interrupt */
struct timer pit_timer; /* periodic timer for mode 2*/
unsigned int channel; /* the pit channel, counter 0~2 */
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|