arm64: vdso: fix coarse clock handling
authorNathan Lynch <nathan_lynch@mentor.com>
Wed, 5 Feb 2014 05:53:04 +0000 (05:53 +0000)
committerMark Brown <broonie@linaro.org>
Wed, 14 May 2014 11:18:35 +0000 (12:18 +0100)
commit1a94c46eed86275ee899eae5210dd14d4129a03a
tree47f784104441a7247931fd626cf10f9fead433fa
parent3a44eb49a2734233b5fc9d98afee53be701f4c4d
arm64: vdso: fix coarse clock handling

commit 069b918623e1510e58dacf178905a72c3baa3ae4 upstream.

When __kernel_clock_gettime is called with a CLOCK_MONOTONIC_COARSE or
CLOCK_REALTIME_COARSE clock id, it returns incorrectly to whatever the
caller has placed in x2 ("ret x2" to return from the fast path).  Fix
this by saving x30/LR to x2 only in code that will call
__do_get_tspec, restoring x30 afterward, and using a plain "ret" to
return from the routine.

Also: while the resulting tv_nsec value for CLOCK_REALTIME and
CLOCK_MONOTONIC must be computed using intermediate values that are
left-shifted by cs_shift (x12, set by __do_get_tspec), the results for
coarse clocks should be calculated using unshifted values
(xtime_coarse_nsec is in units of actual nanoseconds).  The current
code shifts intermediate values by x12 unconditionally, but x12 is
uninitialized when servicing a coarse clock.  Fix this by setting x12
to 0 once we know we are dealing with a coarse clock id.

Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit fb569d15d867a06e89b1be8278404b6fbf6b5bde)
Signed-off-by: Mark Brown <broonie@linaro.org>
arch/arm64/kernel/vdso/gettimeofday.S