Skip to contentSkip to conversation

x86: don't pass negative time to gtime_to_gtsc()

PATCH In review Jan Beulich 2 participants 2 messages Apr 11, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86: don't pass negative time to gtime_to_gtsc()

scale_delta(), which is being called by that function, doesn't cope with that.

Also print a warning message, so hopefully we can eventually figure why occasionally a negative value results from the calculation in the first place.

xen/arch/x86/time.c +9 -0
@@ -854,7 +854,16 @@ static void __update_vcpu_system_time(st
         if ( is_hvm_domain(d) )
         {
             struct pl_time *pl = &v->domain->arch.hvm_domain.pl_time;
+
             stime += pl->stime_offset + v->arch.hvm_vcpu.stime_offset;
+            if ( (s64)stime < 0 )
+            {
+                printk(XENLOG_G_WARNING "d%dv%d: bogus time %" PRId64
+                       " (offsets %" PRId64 "/%" PRId64 ")\n",
+                       d->domain_id, v->vcpu_id, stime,
+		       pl->stime_offset, v->arch.hvm_vcpu.stime_offset);
+                stime = 0;
+            }
         }
         tsc_stamp = gtime_to_gtsc(d, stime);
     }

x86: don't pass negative time to gtime_to_gtsc()

scale_delta(), which is being called by that function, doesn't cope with that.

Also print a warning message, so hopefully we can eventually figure why occasionally a negative value results from the calculation in the first place.

xen/arch/x86/time.c +9 -0
@@ -854,7 +854,16 @@ static void __update_vcpu_system_time(st
         if ( is_hvm_domain(d) )
         {
             struct pl_time *pl = &v->domain->arch.hvm_domain.pl_time;
+
             stime += pl->stime_offset + v->arch.hvm_vcpu.stime_offset;
+            if ( (s64)stime < 0 )
+            {
+                printk(XENLOG_G_WARNING "d%dv%d: bogus time %" PRId64
+                       " (offsets %" PRId64 "/%" PRId64 ")\n",
+                       d->domain_id, v->vcpu_id, stime,
+		       pl->stime_offset, v->arch.hvm_vcpu.stime_offset);
+                stime = 0;
+            }
         }
         tsc_stamp = gtime_to_gtsc(d, stime);
     }

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jan Beulich

scale_delta(), which is being called by that function, doesn't cope with that.

Also print a warning message, so hopefully we can eventually figure why occasionally a negative value results from the calculation in the first place.

Quoted 22 lines
xen/arch/x86/time.c +9 -0
@@ -854,7 +854,16 @@ static void __update_vcpu_system_time(st
         if ( is_hvm_domain(d) )
         {
             struct pl_time *pl = &v->domain->arch.hvm_domain.pl_time;
+
             stime += pl->stime_offset + v->arch.hvm_vcpu.stime_offset;
+            if ( (s64)stime < 0 )
+            {
+                printk(XENLOG_G_WARNING "d%dv%d: bogus time %" PRId64
+                       " (offsets %" PRId64 "/%" PRId64 ")\n",
+                       d->domain_id, v->vcpu_id, stime,
+         pl->stime_offset, v->arch.hvm_vcpu.stime_offset);
+                stime = 0;
+            }
         }
         tsc_stamp = gtime_to_gtsc(d, stime);
     }