Fix VDSO gettimeofday() when called with NULL struct timeval.
[sfrench/cifs-2.6.git] / arch / powerpc / kernel / vdso64 / gettimeofday.S
index ccaeda5136d17e63a71c6d1d64209e2d8d515694..c6401f9e37f1fd2427cc6fa9373a3bff335949c8 100644 (file)
@@ -1,5 +1,4 @@
-
-       /*
+/*
  * Userland implementation of gettimeofday() for 64 bits processes in a
  * ppc64 kernel for use in the vDSO
  *
@@ -11,7 +10,6 @@
  * as published by the Free Software Foundation; either version
  * 2 of the License, or (at your option) any later version.
  */
-#include <linux/config.h>
 #include <asm/processor.h>
 #include <asm/ppc_asm.h>
 #include <asm/vdso.h>
@@ -33,6 +31,8 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
        mr      r11,r3                  /* r11 holds tv */
        mr      r10,r4                  /* r10 holds tz */
        bl      V_LOCAL_FUNC(__get_datapage)    /* get data page */
+       cmpldi  r11,0                   /* check if tv is NULL */
+       beq     2f
        bl      V_LOCAL_FUNC(__do_get_xsec)     /* get xsec from tb & kernel */
        lis     r7,15                   /* r7 = 1000000 = USEC_PER_SEC */
        ori     r7,r7,16960
@@ -44,8 +44,8 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
                                         * XSEC_PER_SEC
                                         */
        rldicl  r0,r0,44,20
-       cmpldi  cr0,r10,0               /* check if tz is NULL */
        std     r0,TVAL64_TV_USEC(r11)  /* store usec in tv */
+2:     cmpldi  r10,0                   /* check if tz is NULL */
        beq     1f
        lwz     r4,CFG_TZ_MINUTEWEST(r3)/* fill tz */
        lwz     r5,CFG_TZ_DSTTIME(r3)
@@ -225,13 +225,15 @@ V_FUNCTION_BEGIN(__do_get_xsec)
   .cfi_startproc
        /* check for update count & load values */
 1:     ld      r8,CFG_TB_UPDATE_COUNT(r3)
-       andi.   r0,r4,1                 /* pending update ? loop */
+       andi.   r0,r8,1                 /* pending update ? loop */
        bne-    1b
-       xor     r0,r4,r4                /* create dependency */
+       xor     r0,r8,r8                /* create dependency */
        add     r3,r3,r0
 
-       /* Get TB & offset it */
-       mftb    r7
+       /* Get TB & offset it. We use the MFTB macro which will generate
+        * workaround code for Cell.
+        */
+       MFTB(r7)
        ld      r9,CFG_TB_ORIG_STAMP(r3)
        subf    r7,r9,r7