Subject: Re: [PATCH] Fix VDSO gettimeofday() when called with NULL struct timeval.

From: Benjamin Herrenschmidt <[email-masked]>
Date: Mon, 25 Jun 2007 22:39:42 +1000

> Index: working/arch/powerpc/kernel/vdso32/gettimeofday.S
> ===================================================================
> --- working.orig/arch/powerpc/kernel/vdso32/gettimeofday.S	2007-06-25 19:35:47.000000000 +1000
> +++ working/arch/powerpc/kernel/vdso32/gettimeofday.S	2007-06-25 19:40:34.000000000 +1000
> @@ -32,8 +32,10 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
>  	mr	r11,r4			/* r11 saves tz */
>  	bl	__get_datapage@local	/* get data page */
>  	mr	r9, r3			/* datapage ptr in r9 */
> +	cmpli	cr0,r10,0		/* check if tv is NULL */
> +	beq	1f

Please use cmplwi here.

>  	bl	__do_get_xsec@local	/* get xsec from tb & kernel */
> -	bne-	2f			/* out of line -> do syscall */
> +	bne-	3f			/* out of line -> do syscall */
>  
>  	/* seconds are xsec >> 20 */
>  	rlwinm	r5,r4,12,20,31
> @@ -50,20 +52,19 @@ V_FUNCTION_BEGIN(__kernel_gettimeofday)
>  	mulhwu	r5,r5,r6
>  	stw	r5,TVAL32_TV_USEC(r10)
>  
> -	cmpli	cr0,r11,0		/* check if tz is NULL */
> -	beq	1f
> +1:	cmpli	cr0,r11,0		/* check if tz is NULL */
> +	beq	2f

And fix that one while at it :-) It's the same thing, but at least one
is explicit on the size of the comparison. Also, I don't think you need
to renumber the labels, or did I miss something ?

Cheers,
Ben.