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 RFC] do_settime is backwards?!

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH RFC] do_settime is backwards?!
From: Rik van Riel <riel@xxxxxxxxxx>
Date: Wed, 6 Aug 2008 17:37:23 -0400
Delivery-date: Wed, 06 Aug 2008 14:37:54 -0700
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/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Organization: Red Hat, Inc
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
While digging through the time code, I found something very strange
in do_settime:

    x = (secs * 1000000000ULL) + (u64)nsecs - system_time_base;
    y = do_div(x, 1000000000);

    spin_lock(&wc_lock);
    wc_sec  = _wc_sec  = (u32)x;
    wc_nsec = _wc_nsec = (u32)y;
    spin_unlock(&wc_lock);

The value "x" appears to be the number of nanoseconds, while
the value "y" is the value in seconds.  The assignments to 
wc_sec and wc_nsec seem backwards, though...

I hope I've overlooked some detail, but just in case I am
right here's a patch to reverse the assignments.

How did this ever work?

Signed-off-by: Rik van Riel <riel@xxxxxxxxxx>
--- 

diff -up xen/arch/x86/time.c.backwards xen/arch/x86/time.c
--- xen/arch/x86/time.c.backwards       2008-08-06 17:33:26.000000000 -0400
+++ xen/arch/x86/time.c 2008-08-06 17:33:45.000000000 -0400
@@ -823,8 +823,8 @@ void do_settime(unsigned long secs, unsi
     y = do_div(x, 1000000000);
 
     spin_lock(&wc_lock);
-    wc_sec  = _wc_sec  = (u32)x;
-    wc_nsec = _wc_nsec = (u32)y;
+    wc_sec  = _wc_sec  = (u32)y;
+    wc_nsec = _wc_nsec = (u32)x;
     spin_unlock(&wc_lock);
 
     rcu_read_lock(&domlist_read_lock);



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

<Prev in Thread] Current Thread [Next in Thread>