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

Segher Boessenkool segher at kernel.crashing.org
Mon Jun 25 23:35:51 EST 2007


> 	It'd be nice if this made it into 2.6.22, esp. now that more
> distros are shipping glibc's that will use the VDSO.

Yeah.  Not really vital though, no sane program would call
gettimeofday() with a NULL timeval (since that doesn't do
anything).  Or did you find such a program (other than a
testsuite)?

> +++ 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 at local	/* get data page */
>  	mr	r9, r3			/* datapage ptr in r9 */
> +	cmpli	cr0,r10,0		/* check if tv is NULL */

cmplwi r10,0

cmpli with two or three arguments is not an existing PowerPC
instruction.  Also, don't write cr0 if you don't do the same
in the accompanying branch insn, it only confuses things.

> +	beq	1f
>  	bl	__do_get_xsec at local	/* get xsec from tb & kernel */
> -	bne-	2f			/* out of line -> do syscall */
> +	bne-	3f			/* out of line -> do syscall */

No need to renumber the labels.  Either pick a higher
number for your new label (nothing says they need to be
in order); or reuse some other number (both your new and
the original 1: can be 1: without any problem, these are
local labels after all); or you can use 0: since that's
a valid local label as well.


Segher




More information about the Linuxppc-dev mailing list