Skip to content

Commit 7d2aa4b

Browse files
fvincenzopaulburton
authored andcommitted
mips: Fix gettimeofday() in the vdso library
The libc provides a discovery mechanism for vDSO library and its symbols. When a symbol is not exposed by the vDSOs the libc falls back on the system calls. With the introduction of the unified vDSO library on mips this behavior is not honored anymore by the kernel in the case of gettimeofday(). The issue has been noticed and reported due to a dhclient failure on the CI20 board: root@letux:~# dhclient ../../../../lib/isc/unix/time.c:200: Operation not permitted root@letux:~# Restore the original behavior fixing gettimeofday() in the vDSO library. Reported-by: H. Nikolaus Schaller <[email protected]> Tested-by: H. Nikolaus Schaller <[email protected]> # CI20 with JZ4780 Signed-off-by: Vincenzo Frascino <[email protected]> Signed-off-by: Paul Burton <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected]
1 parent 87f67cc commit 7d2aa4b

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

arch/mips/include/asm/vdso/gettimeofday.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626

2727
#define __VDSO_USE_SYSCALL ULLONG_MAX
2828

29-
#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
30-
3129
static __always_inline long gettimeofday_fallback(
3230
struct __kernel_old_timeval *_tv,
3331
struct timezone *_tz)
@@ -48,17 +46,6 @@ static __always_inline long gettimeofday_fallback(
4846
return error ? -ret : ret;
4947
}
5048

51-
#else
52-
53-
static __always_inline long gettimeofday_fallback(
54-
struct __kernel_old_timeval *_tv,
55-
struct timezone *_tz)
56-
{
57-
return -1;
58-
}
59-
60-
#endif
61-
6249
static __always_inline long clock_gettime_fallback(
6350
clockid_t _clkid,
6451
struct __kernel_timespec *_ts)

arch/mips/vdso/vgettimeofday.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,22 @@ int __vdso_clock_gettime(clockid_t clock,
1717
return __cvdso_clock_gettime32(clock, ts);
1818
}
1919

20+
#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
21+
22+
/*
23+
* This is behind the ifdef so that we don't provide the symbol when there's no
24+
* possibility of there being a usable clocksource, because there's nothing we
25+
* can do without it. When libc fails the symbol lookup it should fall back on
26+
* the standard syscall path.
27+
*/
2028
int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
2129
struct timezone *tz)
2230
{
2331
return __cvdso_gettimeofday(tv, tz);
2432
}
2533

34+
#endif /* CONFIG_MIPS_CLOCK_VSYSCALL */
35+
2636
int __vdso_clock_getres(clockid_t clock_id,
2737
struct old_timespec32 *res)
2838
{
@@ -43,12 +53,22 @@ int __vdso_clock_gettime(clockid_t clock,
4353
return __cvdso_clock_gettime(clock, ts);
4454
}
4555

56+
#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
57+
58+
/*
59+
* This is behind the ifdef so that we don't provide the symbol when there's no
60+
* possibility of there being a usable clocksource, because there's nothing we
61+
* can do without it. When libc fails the symbol lookup it should fall back on
62+
* the standard syscall path.
63+
*/
4664
int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
4765
struct timezone *tz)
4866
{
4967
return __cvdso_gettimeofday(tv, tz);
5068
}
5169

70+
#endif /* CONFIG_MIPS_CLOCK_VSYSCALL */
71+
5272
int __vdso_clock_getres(clockid_t clock_id,
5373
struct __kernel_timespec *res)
5474
{

0 commit comments

Comments
 (0)