* [PATCH v5 1/5] y2038: cobalt/posix/clock: Adding clock_gettime64
@ 2021-04-21 8:33 Song Chen
2021-04-23 11:10 ` Bezdeka, Florian
2021-04-23 14:46 ` Bezdeka, Florian
0 siblings, 2 replies; 5+ messages in thread
From: Song Chen @ 2021-04-21 8:33 UTC (permalink / raw)
To: xenomai, florian.bezdeka; +Cc: chensong
From: chensong <chensong@tj.kylinos.cn>
Add a syscall specific for clock_gettime with 64bit
time_t.
Signed-off-by: chensong <chensong@tj.kylinos.cn>
---
v5:
1, new helper __cobalt_clock_gettime64
---
include/cobalt/kernel/time.h | 11 +++++++++++
include/cobalt/uapi/syscall.h | 1 +
kernel/cobalt/posix/clock.c | 23 ++++++++++++++++++++++-
kernel/cobalt/posix/clock.h | 6 ++++++
kernel/cobalt/posix/syscall32.c | 8 ++++++++
kernel/cobalt/posix/syscall32.h | 4 ++++
kernel/cobalt/time.c | 11 +++++++++++
7 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/include/cobalt/kernel/time.h b/include/cobalt/kernel/time.h
index 19e8f2c..2890e25 100644
--- a/include/cobalt/kernel/time.h
+++ b/include/cobalt/kernel/time.h
@@ -19,4 +19,15 @@
int cobalt_get_timespec64(struct timespec64 *ts,
const struct __kernel_timespec __user *uts);
+/**
+ * Covert struct timespec64 to struct __kernel_timespec
+ * and copy to userspace
+ *
+ * @param ts The source, provided by kernel
+ * @param uts The destination, will be filled
+ * @return 0 on success, -EFAULT otherwise
+ */
+int cobalt_put_timespec64(const struct timespec64 *ts,
+ struct __kernel_timespec __user *uts);
+
#endif //_COBALT_KERNEL_TIME_H
diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 8895d2b..9859963 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -123,6 +123,7 @@
#define sc_cobalt_clock_adjtime 100
#define sc_cobalt_thread_setschedprio 101
#define sc_cobalt_sem_timedwait64 102
+#define sc_cobalt_clock_gettime64 103
#define __NR_COBALT_SYSCALLS 128 /* Power of 2 */
diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 6a47956..9127013 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -23,6 +23,7 @@
#include "thread.h"
#include "clock.h"
#include <trace/events/cobalt-posix.h>
+#include <cobalt/kernel/time.h>
static struct xnclock *external_clocks[COBALT_MAX_EXTCLOCKS];
@@ -134,11 +135,31 @@ COBALT_SYSCALL(clock_gettime, current,
if (cobalt_put_u_timespec(u_ts, &ts))
return -EFAULT;
- trace_cobalt_clock_gettime(clock_id, &ts);
+ return 0;
+}
+
+int __cobalt_clock_gettime64(clockid_t clock_id,
+ struct __kernel_timespec __user *u_ts)
+{
+ struct timespec64 ts;
+ int ret;
+
+ ret = __cobalt_clock_gettime(clock_id, &ts);
+ if (ret)
+ return ret;
+
+ if (cobalt_put_timespec64(&ts, u_ts))
+ return -EFAULT;
return 0;
}
+COBALT_SYSCALL(clock_gettime64, current,
+ (clockid_t clock_id, struct __kernel_timespec __user *u_ts))
+{
+ return __cobalt_clock_gettime64(clock_id, u_ts);
+}
+
int __cobalt_clock_settime(clockid_t clock_id, const struct timespec64 *ts)
{
int _ret, ret = 0;
diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
index e69e76e..639f030 100644
--- a/kernel/cobalt/posix/clock.h
+++ b/kernel/cobalt/posix/clock.h
@@ -100,6 +100,9 @@ int __cobalt_clock_getres(clockid_t clock_id,
int __cobalt_clock_gettime(clockid_t clock_id,
struct timespec64 *ts);
+int __cobalt_clock_gettime64(clockid_t clock_id,
+ struct __kernel_timespec __user *u_ts);
+
int __cobalt_clock_settime(clockid_t clock_id,
const struct timespec64 *ts);
@@ -116,6 +119,9 @@ COBALT_SYSCALL_DECL(clock_getres,
COBALT_SYSCALL_DECL(clock_gettime,
(clockid_t clock_id, struct __user_old_timespec __user *u_ts));
+COBALT_SYSCALL_DECL(clock_gettime64,
+ (clockid_t clock_id, struct __kernel_timespec __user *u_ts));
+
COBALT_SYSCALL_DECL(clock_settime,
(clockid_t clock_id, const struct __user_old_timespec __user *u_ts));
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index a5dc6e4..5770ebc 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -35,6 +35,7 @@
#include "mqueue.h"
#include "io.h"
#include "../debug.h"
+#include <cobalt/kernel/time.h>
COBALT_SYSCALL32emu(thread_create, init,
(compat_ulong_t pth,
@@ -170,6 +171,13 @@ COBALT_SYSCALL32emu(clock_gettime, current,
return sys32_put_timespec(u_ts, &ts);
}
+COBALT_SYSCALL32emu(clock_gettime64, current,
+ (clockid_t clock_id,
+ struct __kernel_timespec __user *u_ts))
+{
+ return __cobalt_clock_gettime64(clock_id, u_ts);
+}
+
COBALT_SYSCALL32emu(clock_settime, current,
(clockid_t clock_id,
const struct old_timespec32 __user *u_ts))
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index 0b5e26d..68067e6 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -59,6 +59,10 @@ COBALT_SYSCALL32emu_DECL(clock_gettime,
(clockid_t clock_id,
struct old_timespec32 __user *u_ts));
+COBALT_SYSCALL32emu_DECL(clock_gettime64,
+ (clockid_t clock_id,
+ struct __kernel_timespec __user *u_ts));
+
COBALT_SYSCALL32emu_DECL(clock_settime,
(clockid_t clock_id,
const struct old_timespec32 __user *u_ts));
diff --git a/kernel/cobalt/time.c b/kernel/cobalt/time.c
index a3fd8a7..4091def 100644
--- a/kernel/cobalt/time.c
+++ b/kernel/cobalt/time.c
@@ -27,3 +27,14 @@ int cobalt_get_timespec64(struct timespec64 *ts,
return 0;
}
+
+int cobalt_put_timespec64(const struct timespec64 *ts,
+ struct __kernel_timespec __user *uts)
+{
+ struct __kernel_timespec kts = {
+ .tv_sec = ts->tv_sec,
+ .tv_nsec = ts->tv_nsec
+ };
+
+ return cobalt_copy_to_user(uts, &kts, sizeof(kts)) ? -EFAULT : 0;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v5 1/5] y2038: cobalt/posix/clock: Adding clock_gettime64
2021-04-21 8:33 [PATCH v5 1/5] y2038: cobalt/posix/clock: Adding clock_gettime64 Song Chen
@ 2021-04-23 11:10 ` Bezdeka, Florian
2021-04-23 11:48 ` chensong
2021-04-23 14:46 ` Bezdeka, Florian
1 sibling, 1 reply; 5+ messages in thread
From: Bezdeka, Florian @ 2021-04-23 11:10 UTC (permalink / raw)
To: xenomai, chensong_2000; +Cc: chensong
On Wed, 2021-04-21 at 16:33 +0800, Song Chen wrote:
> From: chensong <chensong@tj.kylinos.cn>
>
> Add a syscall specific for clock_gettime with 64bit
> time_t.
>
> Signed-off-by: chensong <chensong@tj.kylinos.cn>
>
> ---
> v5:
> 1, new helper __cobalt_clock_gettime64
> ---
> include/cobalt/kernel/time.h | 11 +++++++++++
> include/cobalt/uapi/syscall.h | 1 +
> kernel/cobalt/posix/clock.c | 23 ++++++++++++++++++++++-
> kernel/cobalt/posix/clock.h | 6 ++++++
> kernel/cobalt/posix/syscall32.c | 8 ++++++++
> kernel/cobalt/posix/syscall32.h | 4 ++++
> kernel/cobalt/time.c | 11 +++++++++++
> 7 files changed, 63 insertions(+), 1 deletion(-)
>
> +COBALT_SYSCALL(clock_gettime64, current,
> + (clockid_t clock_id, struct __kernel_timespec __user *u_ts))
> +{
> + return __cobalt_clock_gettime64(clock_id, u_ts);
Whitespace at end of line! Will fix it up in my tree.
>
> +COBALT_SYSCALL32emu(clock_gettime64, current,
> + (clockid_t clock_id,
> + struct __kernel_timespec __user *u_ts))
> +{
> + return __cobalt_clock_gettime64(clock_id, u_ts);
WS at EOL again. Will fix it up in my tree.
> +}
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v5 1/5] y2038: cobalt/posix/clock: Adding clock_gettime64
2021-04-23 11:10 ` Bezdeka, Florian
@ 2021-04-23 11:48 ` chensong
0 siblings, 0 replies; 5+ messages in thread
From: chensong @ 2021-04-23 11:48 UTC (permalink / raw)
To: Bezdeka, Florian, xenomai; +Cc: chensong
On 2021/4/23 下午7:10, Bezdeka, Florian wrote:
> On Wed, 2021-04-21 at 16:33 +0800, Song Chen wrote:
>> From: chensong <chensong@tj.kylinos.cn>
>>
>> Add a syscall specific for clock_gettime with 64bit
>> time_t.
>>
>> Signed-off-by: chensong <chensong@tj.kylinos.cn>
>>
>> ---
>> v5:
>> 1, new helper __cobalt_clock_gettime64
>> ---
>> include/cobalt/kernel/time.h | 11 +++++++++++
>> include/cobalt/uapi/syscall.h | 1 +
>> kernel/cobalt/posix/clock.c | 23 ++++++++++++++++++++++-
>> kernel/cobalt/posix/clock.h | 6 ++++++
>> kernel/cobalt/posix/syscall32.c | 8 ++++++++
>> kernel/cobalt/posix/syscall32.h | 4 ++++
>> kernel/cobalt/time.c | 11 +++++++++++
>> 7 files changed, 63 insertions(+), 1 deletion(-)
>>
>> +COBALT_SYSCALL(clock_gettime64, current,
>> + (clockid_t clock_id, struct __kernel_timespec __user *u_ts))
>> +{
>> + return __cobalt_clock_gettime64(clock_id, u_ts);
>
> Whitespace at end of line! Will fix it up in my tree.
sorry, i did checkpatch each time, probably missed it this time.
thanks for fixing it up.
Song
>
>>
>> +COBALT_SYSCALL32emu(clock_gettime64, current,
>> + (clockid_t clock_id,
>> + struct __kernel_timespec __user *u_ts))
>> +{
>> + return __cobalt_clock_gettime64(clock_id, u_ts);
>
> WS at EOL again. Will fix it up in my tree.
>
>
>> +}
>>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v5 1/5] y2038: cobalt/posix/clock: Adding clock_gettime64
2021-04-21 8:33 [PATCH v5 1/5] y2038: cobalt/posix/clock: Adding clock_gettime64 Song Chen
2021-04-23 11:10 ` Bezdeka, Florian
@ 2021-04-23 14:46 ` Bezdeka, Florian
1 sibling, 0 replies; 5+ messages in thread
From: Bezdeka, Florian @ 2021-04-23 14:46 UTC (permalink / raw)
To: xenomai, chensong_2000; +Cc: chensong
On Wed, 2021-04-21 at 16:33 +0800, Song Chen wrote:
> From: chensong <chensong@tj.kylinos.cn>
>
> Add a syscall specific for clock_gettime with 64bit
> time_t.
>
> Signed-off-by: chensong <chensong@tj.kylinos.cn>
>
>
> diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
> index 8895d2b..9859963 100644
> --- a/include/cobalt/uapi/syscall.h
> +++ b/include/cobalt/uapi/syscall.h
> @@ -123,6 +123,7 @@
> #define sc_cobalt_clock_adjtime 100
> #define sc_cobalt_thread_setschedprio 101
> #define sc_cobalt_sem_timedwait64 102
> +#define sc_cobalt_clock_gettime64 103
>
My fault didn't notice that during review but now while preparing the
wiki stuff for being available inside the Xenomai hacker space:
The next syscall would be clock_getres64 instead of clock_gettime64
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v5 1/5] y2038: cobalt/posix/clock: Adding clock_gettime64
@ 2021-04-20 6:22 Song Chen
0 siblings, 0 replies; 5+ messages in thread
From: Song Chen @ 2021-04-20 6:22 UTC (permalink / raw)
To: xenomai, florian.bezdeka; +Cc: chensong
From: chensong <chensong@tj.kylinos.cn>
Add a syscall specific for clock_gettime with 64bit
time_t.
Signed-off-by: chensong <chensong@tj.kylinos.cn>
---
v5:
1, new helper __cobalt_clock_gettime64
---
include/cobalt/kernel/time.h | 11 +++++++++++
include/cobalt/uapi/syscall.h | 1 +
kernel/cobalt/posix/clock.c | 23 ++++++++++++++++++++++-
kernel/cobalt/posix/clock.h | 6 ++++++
kernel/cobalt/posix/syscall32.c | 8 ++++++++
kernel/cobalt/posix/syscall32.h | 4 ++++
kernel/cobalt/time.c | 11 +++++++++++
7 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/include/cobalt/kernel/time.h b/include/cobalt/kernel/time.h
index 19e8f2c..2890e25 100644
--- a/include/cobalt/kernel/time.h
+++ b/include/cobalt/kernel/time.h
@@ -19,4 +19,15 @@
int cobalt_get_timespec64(struct timespec64 *ts,
const struct __kernel_timespec __user *uts);
+/**
+ * Covert struct timespec64 to struct __kernel_timespec
+ * and copy to userspace
+ *
+ * @param ts The source, provided by kernel
+ * @param uts The destination, will be filled
+ * @return 0 on success, -EFAULT otherwise
+ */
+int cobalt_put_timespec64(const struct timespec64 *ts,
+ struct __kernel_timespec __user *uts);
+
#endif //_COBALT_KERNEL_TIME_H
diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 8895d2b..9859963 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -123,6 +123,7 @@
#define sc_cobalt_clock_adjtime 100
#define sc_cobalt_thread_setschedprio 101
#define sc_cobalt_sem_timedwait64 102
+#define sc_cobalt_clock_gettime64 103
#define __NR_COBALT_SYSCALLS 128 /* Power of 2 */
diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 6a47956..9127013 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -23,6 +23,7 @@
#include "thread.h"
#include "clock.h"
#include <trace/events/cobalt-posix.h>
+#include <cobalt/kernel/time.h>
static struct xnclock *external_clocks[COBALT_MAX_EXTCLOCKS];
@@ -134,11 +135,31 @@ COBALT_SYSCALL(clock_gettime, current,
if (cobalt_put_u_timespec(u_ts, &ts))
return -EFAULT;
- trace_cobalt_clock_gettime(clock_id, &ts);
+ return 0;
+}
+
+int __cobalt_clock_gettime64(clockid_t clock_id,
+ struct __kernel_timespec __user *u_ts)
+{
+ struct timespec64 ts;
+ int ret;
+
+ ret = __cobalt_clock_gettime(clock_id, &ts);
+ if (ret)
+ return ret;
+
+ if (cobalt_put_timespec64(&ts, u_ts))
+ return -EFAULT;
return 0;
}
+COBALT_SYSCALL(clock_gettime64, current,
+ (clockid_t clock_id, struct __kernel_timespec __user *u_ts))
+{
+ return __cobalt_clock_gettime64(clock_id, u_ts);
+}
+
int __cobalt_clock_settime(clockid_t clock_id, const struct timespec64 *ts)
{
int _ret, ret = 0;
diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
index e69e76e..639f030 100644
--- a/kernel/cobalt/posix/clock.h
+++ b/kernel/cobalt/posix/clock.h
@@ -100,6 +100,9 @@ int __cobalt_clock_getres(clockid_t clock_id,
int __cobalt_clock_gettime(clockid_t clock_id,
struct timespec64 *ts);
+int __cobalt_clock_gettime64(clockid_t clock_id,
+ struct __kernel_timespec __user *u_ts);
+
int __cobalt_clock_settime(clockid_t clock_id,
const struct timespec64 *ts);
@@ -116,6 +119,9 @@ COBALT_SYSCALL_DECL(clock_getres,
COBALT_SYSCALL_DECL(clock_gettime,
(clockid_t clock_id, struct __user_old_timespec __user *u_ts));
+COBALT_SYSCALL_DECL(clock_gettime64,
+ (clockid_t clock_id, struct __kernel_timespec __user *u_ts));
+
COBALT_SYSCALL_DECL(clock_settime,
(clockid_t clock_id, const struct __user_old_timespec __user *u_ts));
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index a5dc6e4..5770ebc 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -35,6 +35,7 @@
#include "mqueue.h"
#include "io.h"
#include "../debug.h"
+#include <cobalt/kernel/time.h>
COBALT_SYSCALL32emu(thread_create, init,
(compat_ulong_t pth,
@@ -170,6 +171,13 @@ COBALT_SYSCALL32emu(clock_gettime, current,
return sys32_put_timespec(u_ts, &ts);
}
+COBALT_SYSCALL32emu(clock_gettime64, current,
+ (clockid_t clock_id,
+ struct __kernel_timespec __user *u_ts))
+{
+ return __cobalt_clock_gettime64(clock_id, u_ts);
+}
+
COBALT_SYSCALL32emu(clock_settime, current,
(clockid_t clock_id,
const struct old_timespec32 __user *u_ts))
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index 0b5e26d..68067e6 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -59,6 +59,10 @@ COBALT_SYSCALL32emu_DECL(clock_gettime,
(clockid_t clock_id,
struct old_timespec32 __user *u_ts));
+COBALT_SYSCALL32emu_DECL(clock_gettime64,
+ (clockid_t clock_id,
+ struct __kernel_timespec __user *u_ts));
+
COBALT_SYSCALL32emu_DECL(clock_settime,
(clockid_t clock_id,
const struct old_timespec32 __user *u_ts));
diff --git a/kernel/cobalt/time.c b/kernel/cobalt/time.c
index a3fd8a7..4091def 100644
--- a/kernel/cobalt/time.c
+++ b/kernel/cobalt/time.c
@@ -27,3 +27,14 @@ int cobalt_get_timespec64(struct timespec64 *ts,
return 0;
}
+
+int cobalt_put_timespec64(const struct timespec64 *ts,
+ struct __kernel_timespec __user *uts)
+{
+ struct __kernel_timespec kts = {
+ .tv_sec = ts->tv_sec,
+ .tv_nsec = ts->tv_nsec
+ };
+
+ return cobalt_copy_to_user(uts, &kts, sizeof(kts)) ? -EFAULT : 0;
+}
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-23 14:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21 8:33 [PATCH v5 1/5] y2038: cobalt/posix/clock: Adding clock_gettime64 Song Chen
2021-04-23 11:10 ` Bezdeka, Florian
2021-04-23 11:48 ` chensong
2021-04-23 14:46 ` Bezdeka, Florian
-- strict thread matches above, loose matches on Subject: below --
2021-04-20 6:22 Song Chen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.