WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Broken timer macros breaks VMX

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] Broken timer macros breaks VMX
From: Leendert van Doorn <leendert@xxxxxxxxxxxxxx>
Date: Sat, 30 Jul 2005 00:54:52 -0400
Cc: Ian Pratt <m+Ian.Pratt@xxxxxxxxxxxx>
Delivery-date: Sat, 30 Jul 2005 05:09:48 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: IBM T.J. Watson Research Center
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
While merging my development tree with the latest hg tree I noticed that
VMX support was broken. When you boot an unmodified Linux kernel it gets
stuck in the "Calibrating delay" loop.  The reason for this is that the
vmx code is repeatedly delivering timer interrupts.

The reason for this is the following:

#define MILLISECS(_ms)  (((s_time_t)(_ms)) * 1000000ULL )

The resulting type of this macro is ULL (instead of s_time_t). When this
macro is used in

     missed_ticks = (NOW() - vpit->scheduled) / MILLISECS(vpit->period);

and "scheduled > NOW()" (this condition occurs when the timer is reset)
then this creates a very large number positive number of missed_ticks
rather than a negative. This causes

     if ( missed_ticks > 0 ) {
         vpit->pending_intr_nr += missed_ticks;

pending_intr_nr to be increased by a large positive number and causes
the (seemingly) endless loop of timer interrupt deliveries.

Correcting the MILLISECS() and friends macros to return s_time_t instead
of ULL fixes this problem. The other changes are just to get rid of
redundant code and variables.

        Leendert

Signed-Off-By: Leendert van Doorn <leendert@xxxxxxxxxxxxxx>


diff -r 55a5ad2f028d xen/arch/x86/vmx_intercept.c
--- a/xen/arch/x86/vmx_intercept.c      Fri Jul 29 11:21:39 2005
+++ b/xen/arch/x86/vmx_intercept.c      Sat Jul 30 00:54:51 2005
@@ -197,8 +197,7 @@
 static void pit_timer_fn(void *data)
 {
     struct vmx_virpit_t *vpit = data;
-    s_time_t   next;
-    int        missed_ticks;
+    int missed_ticks;
 
     missed_ticks = (NOW() - vpit->scheduled) / MILLISECS(vpit->period);
 
@@ -208,12 +207,11 @@
 
     /* pick up missed timer tick */
     if ( missed_ticks > 0 ) {
-        vpit->pending_intr_nr+= missed_ticks;
+        vpit->pending_intr_nr += missed_ticks;
         vpit->scheduled += missed_ticks * MILLISECS(vpit->period);
     }
-    next = vpit->scheduled + MILLISECS(vpit->period);
-    set_ac_timer(&vpit->pit_timer, next);
-    vpit->scheduled = next;
+    vpit->scheduled += MILLISECS(vpit->period);
+    set_ac_timer(&vpit->pit_timer, vpit->scheduled);
 }
 
 
diff -r 55a5ad2f028d xen/include/xen/time.h
--- a/xen/include/xen/time.h    Fri Jul 29 11:21:39 2005
+++ b/xen/include/xen/time.h    Sat Jul 30 00:54:51 2005
@@ -51,9 +51,9 @@
 s_time_t get_s_time(void);
 
 #define NOW()           ((s_time_t)get_s_time())
-#define SECONDS(_s)     (((s_time_t)(_s))  * 1000000000ULL )
-#define MILLISECS(_ms)  (((s_time_t)(_ms)) * 1000000ULL )
-#define MICROSECS(_us)  (((s_time_t)(_us)) * 1000ULL )
+#define SECONDS(_s)     ((s_time_t)((_s)  * 1000000000ULL))
+#define MILLISECS(_ms)  ((s_time_t)((_ms) * 1000000ULL))
+#define MICROSECS(_us)  ((s_time_t)((_us) * 1000ULL))
 
 extern void update_dom_time(struct vcpu *v);
 extern void do_settime(

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Broken timer macros breaks VMX, Leendert van Doorn <=