diff options
author | Nathan Lynch <nathan_lynch@mentor.com> | 2014-02-05 00:53:04 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-20 14:06:11 -0500 |
commit | fb569d15d867a06e89b1be8278404b6fbf6b5bde (patch) | |
tree | d33c3160fb70043c0e660a0c3a3df3a3ab67e006 /arch | |
parent | f35f27e775d6f8aa265fb698975c9c95f2757ef4 (diff) |
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>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm64/kernel/vdso/gettimeofday.S | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/arm64/kernel/vdso/gettimeofday.S b/arch/arm64/kernel/vdso/gettimeofday.S index f0a6d10b5211..fe652ffd34c2 100644 --- a/arch/arm64/kernel/vdso/gettimeofday.S +++ b/arch/arm64/kernel/vdso/gettimeofday.S | |||
@@ -103,6 +103,8 @@ ENTRY(__kernel_clock_gettime) | |||
103 | bl __do_get_tspec | 103 | bl __do_get_tspec |
104 | seqcnt_check w9, 1b | 104 | seqcnt_check w9, 1b |
105 | 105 | ||
106 | mov x30, x2 | ||
107 | |||
106 | cmp w0, #CLOCK_MONOTONIC | 108 | cmp w0, #CLOCK_MONOTONIC |
107 | b.ne 6f | 109 | b.ne 6f |
108 | 110 | ||
@@ -118,6 +120,9 @@ ENTRY(__kernel_clock_gettime) | |||
118 | ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne | 120 | ccmp w0, #CLOCK_MONOTONIC_COARSE, #0x4, ne |
119 | b.ne 8f | 121 | b.ne 8f |
120 | 122 | ||
123 | /* xtime_coarse_nsec is already right-shifted */ | ||
124 | mov x12, #0 | ||
125 | |||
121 | /* Get coarse timespec. */ | 126 | /* Get coarse timespec. */ |
122 | adr vdso_data, _vdso_data | 127 | adr vdso_data, _vdso_data |
123 | 3: seqcnt_acquire | 128 | 3: seqcnt_acquire |
@@ -156,7 +161,7 @@ ENTRY(__kernel_clock_gettime) | |||
156 | lsr x11, x11, x12 | 161 | lsr x11, x11, x12 |
157 | stp x10, x11, [x1, #TSPEC_TV_SEC] | 162 | stp x10, x11, [x1, #TSPEC_TV_SEC] |
158 | mov x0, xzr | 163 | mov x0, xzr |
159 | ret x2 | 164 | ret |
160 | 7: | 165 | 7: |
161 | mov x30, x2 | 166 | mov x30, x2 |
162 | 8: /* Syscall fallback. */ | 167 | 8: /* Syscall fallback. */ |