linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mips: Fix gettimeofday() in the vdso library
@ 2019-11-29 14:36 Vincenzo Frascino
  2019-11-29 14:52 ` H. Nikolaus Schaller
  2019-12-02 19:48 ` Paul Burton
  0 siblings, 2 replies; 5+ messages in thread
From: Vincenzo Frascino @ 2019-11-29 14:36 UTC (permalink / raw)
  To: vincenzo.frascino, paulburton, hns
  Cc: mips-creator-ci20-dev, letux-kernel, linux-mips, linux-kernel

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.

Cc: Paul Burton <paulburton@kernel.org>
Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
Testes-by: H. Nikolaus Schaller <hns@goldelico.com> # CI20 with JZ4780
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---
 arch/mips/include/asm/vdso/gettimeofday.h | 13 -------------
 arch/mips/vdso/vgettimeofday.c            | 20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/arch/mips/include/asm/vdso/gettimeofday.h b/arch/mips/include/asm/vdso/gettimeofday.h
index b08825531e9f..0ae9b4cbc153 100644
--- a/arch/mips/include/asm/vdso/gettimeofday.h
+++ b/arch/mips/include/asm/vdso/gettimeofday.h
@@ -26,8 +26,6 @@
 
 #define __VDSO_USE_SYSCALL		ULLONG_MAX
 
-#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
-
 static __always_inline long gettimeofday_fallback(
 				struct __kernel_old_timeval *_tv,
 				struct timezone *_tz)
@@ -48,17 +46,6 @@ static __always_inline long gettimeofday_fallback(
 	return error ? -ret : ret;
 }
 
-#else
-
-static __always_inline long gettimeofday_fallback(
-				struct __kernel_old_timeval *_tv,
-				struct timezone *_tz)
-{
-	return -1;
-}
-
-#endif
-
 static __always_inline long clock_gettime_fallback(
 					clockid_t _clkid,
 					struct __kernel_timespec *_ts)
diff --git a/arch/mips/vdso/vgettimeofday.c b/arch/mips/vdso/vgettimeofday.c
index 6ebdc37c89fc..6b83b6376a4b 100644
--- a/arch/mips/vdso/vgettimeofday.c
+++ b/arch/mips/vdso/vgettimeofday.c
@@ -17,12 +17,22 @@ int __vdso_clock_gettime(clockid_t clock,
 	return __cvdso_clock_gettime32(clock, ts);
 }
 
+#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
+
+/*
+ * This is behind the ifdef so that we don't provide the symbol when there's no
+ * possibility of there being a usable clocksource, because there's nothing we
+ * can do without it. When libc fails the symbol lookup it should fall back on
+ * the standard syscall path.
+ */
 int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
 			struct timezone *tz)
 {
 	return __cvdso_gettimeofday(tv, tz);
 }
 
+#endif /* CONFIG_MIPS_CLOCK_VSYSCALL */
+
 int __vdso_clock_getres(clockid_t clock_id,
 			struct old_timespec32 *res)
 {
@@ -43,12 +53,22 @@ int __vdso_clock_gettime(clockid_t clock,
 	return __cvdso_clock_gettime(clock, ts);
 }
 
+#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
+
+/*
+ * This is behind the ifdef so that we don't provide the symbol when there's no
+ * possibility of there being a usable clocksource, because there's nothing we
+ * can do without it. When libc fails the symbol lookup it should fall back on
+ * the standard syscall path.
+ */
 int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
 			struct timezone *tz)
 {
 	return __cvdso_gettimeofday(tv, tz);
 }
 
+#endif /* CONFIG_MIPS_CLOCK_VSYSCALL */
+
 int __vdso_clock_getres(clockid_t clock_id,
 			struct __kernel_timespec *res)
 {
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] mips: Fix gettimeofday() in the vdso library
  2019-11-29 14:36 [PATCH] mips: Fix gettimeofday() in the vdso library Vincenzo Frascino
@ 2019-11-29 14:52 ` H. Nikolaus Schaller
  2019-11-29 14:58   ` Vincenzo Frascino
  2019-12-02 19:48 ` Paul Burton
  1 sibling, 1 reply; 5+ messages in thread
From: H. Nikolaus Schaller @ 2019-11-29 14:52 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Paul Burton, mips-creator-ci20-dev, letux-kernel, linux-mips,
	linux-kernel


> Am 29.11.2019 um 15:36 schrieb Vincenzo Frascino <vincenzo.frascino@arm.com>:
> 
> 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.
> 
> Cc: Paul Burton <paulburton@kernel.org>
> Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
> Testes-by: H. Nikolaus Schaller <hns@goldelico.com> # CI20 with JZ4780
^^^ funny typo... -> Tested-by:
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
> arch/mips/include/asm/vdso/gettimeofday.h | 13 -------------
> arch/mips/vdso/vgettimeofday.c            | 20 ++++++++++++++++++++
> 2 files changed, 20 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/mips/include/asm/vdso/gettimeofday.h b/arch/mips/include/asm/vdso/gettimeofday.h
> index b08825531e9f..0ae9b4cbc153 100644
> --- a/arch/mips/include/asm/vdso/gettimeofday.h
> +++ b/arch/mips/include/asm/vdso/gettimeofday.h
> @@ -26,8 +26,6 @@
> 
> #define __VDSO_USE_SYSCALL		ULLONG_MAX
> 
> -#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
> -
> static __always_inline long gettimeofday_fallback(
> 				struct __kernel_old_timeval *_tv,
> 				struct timezone *_tz)
> @@ -48,17 +46,6 @@ static __always_inline long gettimeofday_fallback(
> 	return error ? -ret : ret;
> }
> 
> -#else
> -
> -static __always_inline long gettimeofday_fallback(
> -				struct __kernel_old_timeval *_tv,
> -				struct timezone *_tz)
> -{
> -	return -1;
> -}
> -
> -#endif
> -
> static __always_inline long clock_gettime_fallback(
> 					clockid_t _clkid,
> 					struct __kernel_timespec *_ts)
> diff --git a/arch/mips/vdso/vgettimeofday.c b/arch/mips/vdso/vgettimeofday.c
> index 6ebdc37c89fc..6b83b6376a4b 100644
> --- a/arch/mips/vdso/vgettimeofday.c
> +++ b/arch/mips/vdso/vgettimeofday.c
> @@ -17,12 +17,22 @@ int __vdso_clock_gettime(clockid_t clock,
> 	return __cvdso_clock_gettime32(clock, ts);
> }
> 
> +#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
> +
> +/*
> + * This is behind the ifdef so that we don't provide the symbol when there's no
> + * possibility of there being a usable clocksource, because there's nothing we
> + * can do without it. When libc fails the symbol lookup it should fall back on
> + * the standard syscall path.
> + */
> int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
> 			struct timezone *tz)
> {
> 	return __cvdso_gettimeofday(tv, tz);
> }
> 
> +#endif /* CONFIG_MIPS_CLOCK_VSYSCALL */
> +
> int __vdso_clock_getres(clockid_t clock_id,
> 			struct old_timespec32 *res)
> {
> @@ -43,12 +53,22 @@ int __vdso_clock_gettime(clockid_t clock,
> 	return __cvdso_clock_gettime(clock, ts);
> }
> 
> +#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
> +
> +/*
> + * This is behind the ifdef so that we don't provide the symbol when there's no
> + * possibility of there being a usable clocksource, because there's nothing we
> + * can do without it. When libc fails the symbol lookup it should fall back on
> + * the standard syscall path.
> + */
> int __vdso_gettimeofday(struct __kernel_old_timeval *tv,
> 			struct timezone *tz)
> {
> 	return __cvdso_gettimeofday(tv, tz);
> }
> 
> +#endif /* CONFIG_MIPS_CLOCK_VSYSCALL */
> +
> int __vdso_clock_getres(clockid_t clock_id,
> 			struct __kernel_timespec *res)
> {
> -- 
> 2.24.0
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mips: Fix gettimeofday() in the vdso library
  2019-11-29 14:52 ` H. Nikolaus Schaller
@ 2019-11-29 14:58   ` Vincenzo Frascino
  2019-11-29 15:09     ` H. Nikolaus Schaller
  0 siblings, 1 reply; 5+ messages in thread
From: Vincenzo Frascino @ 2019-11-29 14:58 UTC (permalink / raw)
  To: H. Nikolaus Schaller
  Cc: Paul Burton, mips-creator-ci20-dev, letux-kernel, linux-mips,
	linux-kernel

On 11/29/19 2:52 PM, H. Nikolaus Schaller wrote:
> 
>> Am 29.11.2019 um 15:36 schrieb Vincenzo Frascino <vincenzo.frascino@arm.com>:
>>
>> 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.
>>
>> Cc: Paul Burton <paulburton@kernel.org>
>> Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
>> Testes-by: H. Nikolaus Schaller <hns@goldelico.com> # CI20 with JZ4780
> ^^^ funny typo... -> Tested-by:

Ops, I copy-pasted it from your email ;) Can't trust you ;)

-- 
Regards,
Vincenzo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mips: Fix gettimeofday() in the vdso library
  2019-11-29 14:58   ` Vincenzo Frascino
@ 2019-11-29 15:09     ` H. Nikolaus Schaller
  0 siblings, 0 replies; 5+ messages in thread
From: H. Nikolaus Schaller @ 2019-11-29 15:09 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Paul Burton, mips-creator-ci20-dev, letux-kernel, linux-mips,
	linux-kernel


> Am 29.11.2019 um 15:58 schrieb Vincenzo Frascino <vincenzo.frascino@arm.com>:
> 
> On 11/29/19 2:52 PM, H. Nikolaus Schaller wrote:
>> 
>>> Am 29.11.2019 um 15:36 schrieb Vincenzo Frascino <vincenzo.frascino@arm.com>:
>>> 
>>> 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.
>>> 
>>> Cc: Paul Burton <paulburton@kernel.org>
>>> Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
>>> Testes-by: H. Nikolaus Schaller <hns@goldelico.com> # CI20 with JZ4780
>> ^^^ funny typo... -> Tested-by:
> 
> Ops, I copy-pasted it from your email ;) Can't trust you ;)

No :)

Well, typos happen and nobody seems to notice. My favourite:

5f9e832c137075045d15cd6899ab0505cfb2ca4b

BR,
Nikolaus


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] mips: Fix gettimeofday() in the vdso library
  2019-11-29 14:36 [PATCH] mips: Fix gettimeofday() in the vdso library Vincenzo Frascino
  2019-11-29 14:52 ` H. Nikolaus Schaller
@ 2019-12-02 19:48 ` Paul Burton
  1 sibling, 0 replies; 5+ messages in thread
From: Paul Burton @ 2019-12-02 19:48 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: vincenzo.frascino, paulburton, hns, mips-creator-ci20-dev,
	letux-kernel, linux-mips, linux-kernel, linux-mips

Hello,

Vincenzo Frascino wrote:
> 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.

Applied to mips-fixes.

> commit 7d2aa4bb90f5
> https://git.kernel.org/mips/c/7d2aa4bb90f5
> 
> Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
> Tested-by: H. Nikolaus Schaller <hns@goldelico.com> # CI20 with JZ4780
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> Signed-off-by: Paul Burton <paulburton@kernel.org>

Thanks,
    Paul

[ This message was auto-generated; if you believe anything is incorrect
  then please email paulburton@kernel.org to report it. ]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-02 19:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 14:36 [PATCH] mips: Fix gettimeofday() in the vdso library Vincenzo Frascino
2019-11-29 14:52 ` H. Nikolaus Schaller
2019-11-29 14:58   ` Vincenzo Frascino
2019-11-29 15:09     ` H. Nikolaus Schaller
2019-12-02 19:48 ` Paul Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).