Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1676876 > unrolled thread
| Started by | Aleksandar Markovic <aleksandar.markovic@rt-rk.com> |
|---|---|
| First post | 2017-06-28 18:00 +0200 |
| Last post | 2017-06-28 18:00 +0200 |
| Articles | 3 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH v2 0/4] MIPS: Fix several VDSO-related issues Aleksandar Markovic <aleksandar.markovic@rt-rk.com> - 2017-06-28 18:00 +0200
[PATCH v2 2/4] MIPS: VDSO: Add implementation of clock_gettime() fallback Aleksandar Markovic <aleksandar.markovic@rt-rk.com> - 2017-06-28 18:00 +0200
[PATCH v2 3/4] MIPS: VDSO: Add implementation of gettimeofday() fallback Aleksandar Markovic <aleksandar.markovic@rt-rk.com> - 2017-06-28 18:00 +0200
| From | Aleksandar Markovic <aleksandar.markovic@rt-rk.com> |
|---|---|
| Date | 2017-06-28 18:00 +0200 |
| Subject | [PATCH v2 0/4] MIPS: Fix several VDSO-related issues |
| Message-ID | <tXnxL-hR-5@gated-at.bofh.it> |
From: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
v1->v2:
- updated recipient lists using get_maintainer.pl
- rebased to the letest kernel code
The patches in this series all deal with VDSO, and all originate from
the develpoment of Android emulator for Mips..
The first patch is a fix for incorrect time values returned under
certain conditions.
The second and third patches provide fallback mechanism for
clock_gettime() and gettimeofday() system calls within kernel VDSO
code. This actually brings Mips code to be in sync with other major
platforms (intel, arm, and others) (with respect to the division of
responsibility between glibc and kernel regarding VDSO functions
fallbacks). It seems to us that proposed organization is simpler
and easier for maintenance in the long run. However, since it affects
interaction between glibc and kernel, it needs to be communicated to
and reviewed by Mips glibc developers.
The fourth patch is just a correction of a comment.
Aleksandar Markovic (1):
MIPS: VDSO: Fix a mismatch between comment and preprocessor constant
Goran Ferenc (3):
MIPS: VDSO: Fix conversions in do_monotonic()/do_monotonic_coarse()
MIPS: VDSO: Add implementation of clock_gettime() fallback
MIPS: VDSO: Add implementation of gettimeofday() fallback
arch/mips/include/asm/vdso.h | 4 +--
arch/mips/vdso/gettimeofday.c | 59 ++++++++++++++++++++++++++++++++++++-------
2 files changed, 52 insertions(+), 11 deletions(-)
--
2.7.4
[toc] | [next] | [standalone]
| From | Aleksandar Markovic <aleksandar.markovic@rt-rk.com> |
|---|---|
| Date | 2017-06-28 18:00 +0200 |
| Subject | [PATCH v2 2/4] MIPS: VDSO: Add implementation of clock_gettime() fallback |
| Message-ID | <tXnxO-hR-63@gated-at.bofh.it> |
| In reply to | #1676876 |
From: Goran Ferenc <goran.ferenc@imgtec.com>
This patch adds clock_gettime_fallback() function that wraps assembly
invocation of clock_gettime() syscall using __NR_clock_gettime.
This function is used if pure VDSO implementation of clock_gettime()
does not succeed for any reason. For example, it is called if the
clkid parameter of clock_gettime() is not one of the clkids listed
in the switch-case block of the function __vdso_clock_gettime()
(one such case for clkid is CLOCK_BOOTIME).
If syscall invocation via __NR_clock_gettime fails, register a3 will
be set. So, after the syscall, register a3 is tested and the return
value is negated if it's set.
Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
---
arch/mips/vdso/gettimeofday.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/arch/mips/vdso/gettimeofday.c b/arch/mips/vdso/gettimeofday.c
index fd7d433..5f63375 100644
--- a/arch/mips/vdso/gettimeofday.c
+++ b/arch/mips/vdso/gettimeofday.c
@@ -20,6 +20,24 @@
#include <asm/unistd.h>
#include <asm/vdso.h>
+static __always_inline long clock_gettime_fallback(clockid_t _clkid,
+ struct timespec *_ts)
+{
+ register struct timespec *ts asm("a1") = _ts;
+ register clockid_t clkid asm("a0") = _clkid;
+ register long ret asm("v0");
+ register long nr asm("v0") = __NR_clock_gettime;
+ register long error asm("a3");
+
+ asm volatile(
+ " syscall\n"
+ : "=r" (ret), "=r" (error)
+ : "r" (clkid), "r" (ts), "r" (nr)
+ : "memory");
+
+ return error ? -ret : ret;
+}
+
static __always_inline int do_realtime_coarse(struct timespec *ts,
const union mips_vdso_data *data)
{
@@ -207,7 +225,7 @@ int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
int __vdso_clock_gettime(clockid_t clkid, struct timespec *ts)
{
const union mips_vdso_data *data = get_vdso_data();
- int ret;
+ int ret = -1;
switch (clkid) {
case CLOCK_REALTIME_COARSE:
@@ -223,10 +241,11 @@ int __vdso_clock_gettime(clockid_t clkid, struct timespec *ts)
ret = do_monotonic(ts, data);
break;
default:
- ret = -ENOSYS;
break;
}
- /* If we return -ENOSYS libc should fall back to a syscall. */
+ if (ret)
+ ret = clock_gettime_fallback(clkid, ts);
+
return ret;
}
--
2.7.4
[toc] | [prev] | [next] | [standalone]
| From | Aleksandar Markovic <aleksandar.markovic@rt-rk.com> |
|---|---|
| Date | 2017-06-28 18:00 +0200 |
| Subject | [PATCH v2 3/4] MIPS: VDSO: Add implementation of gettimeofday() fallback |
| Message-ID | <tXnxO-hR-67@gated-at.bofh.it> |
| In reply to | #1676876 |
From: Goran Ferenc <goran.ferenc@imgtec.com>
This patch adds gettimeofday_fallback() function that wraps assembly
invocation of gettimeofday() syscall using __NR_gettimeofday.
This function is used if pure VDSO implementation gettimeofday()
does not succeed for any reason. Its imeplementation is enclosed in
"#ifdef CONFIG_MIPS_CLOCK_VSYSCALL" to be in sync with the similar
arrangement for __vdso_gettimeofday().
If syscall invocation via __NR_gettimeofday fails, register a3 will
be set. So, after the syscall, register a3 is tested and the return
valuem is negated if it's set.
Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com>
Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com>
Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com>
---
arch/mips/vdso/gettimeofday.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/arch/mips/vdso/gettimeofday.c b/arch/mips/vdso/gettimeofday.c
index 5f63375..23305bf 100644
--- a/arch/mips/vdso/gettimeofday.c
+++ b/arch/mips/vdso/gettimeofday.c
@@ -20,6 +20,28 @@
#include <asm/unistd.h>
#include <asm/vdso.h>
+#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
+
+static __always_inline long gettimeofday_fallback(struct timeval *_tv,
+ struct timezone *_tz)
+{
+ register struct timezone *tz asm("a1") = _tz;
+ register struct timeval *tv asm("a0") = _tv;
+ register long ret asm("v0");
+ register long nr asm("v0") = __NR_gettimeofday;
+ register long error asm("a3");
+
+ asm volatile(
+ " syscall\n"
+ : "=r" (ret), "=r" (error)
+ : "r" (tv), "r" (tz), "r" (nr)
+ : "memory");
+
+ return error ? -ret : ret;
+}
+
+#endif
+
static __always_inline long clock_gettime_fallback(clockid_t _clkid,
struct timespec *_ts)
{
@@ -205,7 +227,7 @@ int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
ret = do_realtime(&ts, data);
if (ret)
- return ret;
+ return gettimeofday_fallback(tv, tz);
if (tv) {
tv->tv_sec = ts.tv_sec;
--
2.7.4
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web