All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] [y2038]cobalt: posix: clock: Adding clock_settime64
@ 2021-03-11  2:46 chensong
  2021-03-11  9:03 ` florian.bezdeka
  0 siblings, 1 reply; 6+ messages in thread
From: chensong @ 2021-03-11  2:46 UTC (permalink / raw)
  To: florian.bezdeka, xenomai, rpm

Adding a new syscall clock_settime64 specific for timespec64,
It can solve y2038 in below scenarios:

1, 64bit kernel, y2038 safe
2, 32bit kernel, 32bit time_t, go to clock_settime, no break,
   y2038 not safe.
3, 32bit kernel, 64bit time_t, go to clock_settime64 by the help
   of libcobalt, no break, y2038 safe.

Signed-off-by: chensong <chensong@tj.kylinos.cn>
---
 include/cobalt/uapi/syscall.h |  1 +
 kernel/cobalt/posix/clock.c   | 12 ++++++++++++
 kernel/cobalt/posix/clock.h   |  4 ++++
 3 files changed, 17 insertions(+)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index 8895d2b..291b550 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_settime64		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..9643f8f 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];
 
@@ -193,6 +194,17 @@ COBALT_SYSCALL(clock_settime, current,
 	return __cobalt_clock_settime(clock_id, &ts);
 }
 
+COBALT_SYSCALL(clock_settime64, current,
+	       (clockid_t clock_id, const struct __kernel_timespec __user *u_ts))
+{
+	struct timespec64 ts64;
+
+	if (cobalt_get_timespec64(&ts64, u_ts))
+		return -EFAULT;
+
+	return __cobalt_clock_settime(clock_id, &ts64);
+}
+
 COBALT_SYSCALL(clock_adjtime, current,
 	       (clockid_t clock_id, struct __user_old_timex __user *u_tx))
 {
diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
index e69e76e..90f79fa 100644
--- a/kernel/cobalt/posix/clock.h
+++ b/kernel/cobalt/posix/clock.h
@@ -119,6 +119,10 @@ COBALT_SYSCALL_DECL(clock_gettime,
 COBALT_SYSCALL_DECL(clock_settime,
 		    (clockid_t clock_id, const struct __user_old_timespec __user *u_ts));
 
+COBALT_SYSCALL_DECL(clock_settime64,
+		    (clockid_t clock_id,
+			 const struct __kernel_timespec __user *u_ts));
+
 COBALT_SYSCALL_DECL(clock_adjtime,
 		    (clockid_t clock_id, struct __user_old_timex __user *u_tx));
 
-- 
2.7.4





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

* Re: [PATCH 2/4] [y2038]cobalt: posix: clock: Adding clock_settime64
  2021-03-11  2:46 [PATCH 2/4] [y2038]cobalt: posix: clock: Adding clock_settime64 chensong
@ 2021-03-11  9:03 ` florian.bezdeka
  2021-03-11  9:29   ` chensong
  0 siblings, 1 reply; 6+ messages in thread
From: florian.bezdeka @ 2021-03-11  9:03 UTC (permalink / raw)
  To: rpm, xenomai, chensong

On Thu, 2021-03-11 at 10:46 +0800, chensong wrote:
> Adding a new syscall clock_settime64 specific for timespec64,
> It can solve y2038 in below scenarios:
> 
> 1, 64bit kernel, y2038 safe
> 2, 32bit kernel, 32bit time_t, go to clock_settime, no break,
>    y2038 not safe.
> 3, 32bit kernel, 64bit time_t, go to clock_settime64 by the help
>    of libcobalt, no break, y2038 safe.
> 
> Signed-off-by: chensong <chensong@tj.kylinos.cn>
> ---
>  include/cobalt/uapi/syscall.h |  1 +
>  kernel/cobalt/posix/clock.c   | 12 ++++++++++++
>  kernel/cobalt/posix/clock.h   |  4 ++++
>  3 files changed, 17 insertions(+)
> 
> diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
> index 8895d2b..291b550 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_settime64		103

I assume we should keep the order of affected syscalls. The next one
would be sc_cobalt_clock_gettime64.

And I'm missing the tests... Please add tests for everything you add /
fix.

>  
> 
> 
> 
>  #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
>  
> 
> 
> 
> diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
> index 6a47956..9643f8f 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];
>  
> 
> 
> 
> @@ -193,6 +194,17 @@ COBALT_SYSCALL(clock_settime, current,
>  	return __cobalt_clock_settime(clock_id, &ts);
>  }
>  
> 
> 
> 
> +COBALT_SYSCALL(clock_settime64, current,
> +	       (clockid_t clock_id, const struct __kernel_timespec __user *u_ts))
> +{
> +	struct timespec64 ts64;
> +
> +	if (cobalt_get_timespec64(&ts64, u_ts))
> +		return -EFAULT;
> +
> +	return __cobalt_clock_settime(clock_id, &ts64);
> +}
> +
>  COBALT_SYSCALL(clock_adjtime, current,
>  	       (clockid_t clock_id, struct __user_old_timex __user *u_tx))
>  {
> diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
> index e69e76e..90f79fa 100644
> --- a/kernel/cobalt/posix/clock.h
> +++ b/kernel/cobalt/posix/clock.h
> @@ -119,6 +119,10 @@ COBALT_SYSCALL_DECL(clock_gettime,
>  COBALT_SYSCALL_DECL(clock_settime,
>  		    (clockid_t clock_id, const struct __user_old_timespec __user *u_ts));
>  
> 
> 
> 
> +COBALT_SYSCALL_DECL(clock_settime64,
> +		    (clockid_t clock_id,
> +			 const struct __kernel_timespec __user *u_ts));
> +
>  COBALT_SYSCALL_DECL(clock_adjtime,
>  		    (clockid_t clock_id, struct __user_old_timex __user *u_tx));
>  


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

* Re: [PATCH 2/4] [y2038]cobalt: posix: clock: Adding clock_settime64
  2021-03-11  9:03 ` florian.bezdeka
@ 2021-03-11  9:29   ` chensong
  2021-03-11  9:58     ` chensong
  0 siblings, 1 reply; 6+ messages in thread
From: chensong @ 2021-03-11  9:29 UTC (permalink / raw)
  To: florian.bezdeka, rpm, xenomai



On 2021年03月11日 17:03, florian.bezdeka@siemens.com wrote:
> On Thu, 2021-03-11 at 10:46 +0800, chensong wrote:
>> Adding a new syscall clock_settime64 specific for timespec64,
>> It can solve y2038 in below scenarios:
>>
>> 1, 64bit kernel, y2038 safe
>> 2, 32bit kernel, 32bit time_t, go to clock_settime, no break,
>>     y2038 not safe.
>> 3, 32bit kernel, 64bit time_t, go to clock_settime64 by the help
>>     of libcobalt, no break, y2038 safe.
>>
>> Signed-off-by: chensong <chensong@tj.kylinos.cn>
>> ---
>>   include/cobalt/uapi/syscall.h |  1 +
>>   kernel/cobalt/posix/clock.c   | 12 ++++++++++++
>>   kernel/cobalt/posix/clock.h   |  4 ++++
>>   3 files changed, 17 insertions(+)
>>
>> diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
>> index 8895d2b..291b550 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_settime64		103
>
> I assume we should keep the order of affected syscalls. The next one
> would be sc_cobalt_clock_gettime64.

yes, i thought about catagorizing them in order, probably adjust 
sc_cobalt_sem_timedwait64 later, next is sc_cobalt_clock_gettime64.


>
> And I'm missing the tests... Please add tests for everything you add /
> fix.

ongoing.

Song

>
>>
>>
>>
>>
>>   #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
>>
>>
>>
>>
>> diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
>> index 6a47956..9643f8f 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];
>>
>>
>>
>>
>> @@ -193,6 +194,17 @@ COBALT_SYSCALL(clock_settime, current,
>>   	return __cobalt_clock_settime(clock_id, &ts);
>>   }
>>
>>
>>
>>
>> +COBALT_SYSCALL(clock_settime64, current,
>> +	       (clockid_t clock_id, const struct __kernel_timespec __user *u_ts))
>> +{
>> +	struct timespec64 ts64;
>> +
>> +	if (cobalt_get_timespec64(&ts64, u_ts))
>> +		return -EFAULT;
>> +
>> +	return __cobalt_clock_settime(clock_id, &ts64);
>> +}
>> +
>>   COBALT_SYSCALL(clock_adjtime, current,
>>   	       (clockid_t clock_id, struct __user_old_timex __user *u_tx))
>>   {
>> diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
>> index e69e76e..90f79fa 100644
>> --- a/kernel/cobalt/posix/clock.h
>> +++ b/kernel/cobalt/posix/clock.h
>> @@ -119,6 +119,10 @@ COBALT_SYSCALL_DECL(clock_gettime,
>>   COBALT_SYSCALL_DECL(clock_settime,
>>   		    (clockid_t clock_id, const struct __user_old_timespec __user *u_ts));
>>
>>
>>
>>
>> +COBALT_SYSCALL_DECL(clock_settime64,
>> +		    (clockid_t clock_id,
>> +			 const struct __kernel_timespec __user *u_ts));
>> +
>>   COBALT_SYSCALL_DECL(clock_adjtime,
>>   		    (clockid_t clock_id, struct __user_old_timex __user *u_tx));
>>
>




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

* Re: [PATCH 2/4] [y2038]cobalt: posix: clock: Adding clock_settime64
  2021-03-11  9:29   ` chensong
@ 2021-03-11  9:58     ` chensong
  2021-03-11 10:10       ` florian.bezdeka
  2021-03-11 10:37       ` Jan Kiszka
  0 siblings, 2 replies; 6+ messages in thread
From: chensong @ 2021-03-11  9:58 UTC (permalink / raw)
  To: florian.bezdeka, rpm, xenomai



On 2021年03月11日 17:29, chensong via Xenomai wrote:
>
>
> On 2021年03月11日 17:03, florian.bezdeka@siemens.com wrote:
>> On Thu, 2021-03-11 at 10:46 +0800, chensong wrote:
>>> Adding a new syscall clock_settime64 specific for timespec64,
>>> It can solve y2038 in below scenarios:
>>>
>>> 1, 64bit kernel, y2038 safe
>>> 2, 32bit kernel, 32bit time_t, go to clock_settime, no break,
>>>     y2038 not safe.
>>> 3, 32bit kernel, 64bit time_t, go to clock_settime64 by the help
>>>     of libcobalt, no break, y2038 safe.
>>>
>>> Signed-off-by: chensong <chensong@tj.kylinos.cn>
>>> ---
>>>   include/cobalt/uapi/syscall.h |  1 +
>>>   kernel/cobalt/posix/clock.c   | 12 ++++++++++++
>>>   kernel/cobalt/posix/clock.h   |  4 ++++
>>>   3 files changed, 17 insertions(+)
>>>
>>> diff --git a/include/cobalt/uapi/syscall.h
>>> b/include/cobalt/uapi/syscall.h
>>> index 8895d2b..291b550 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_settime64        103
>>
>> I assume we should keep the order of affected syscalls. The next one
>> would be sc_cobalt_clock_gettime64.
>
> yes, i thought about catagorizing them in order, probably adjust
> sc_cobalt_sem_timedwait64 later, next is sc_cobalt_clock_gettime64.
>
>
>>
>> And I'm missing the tests... Please add tests for everything you add /
>> fix.
>
> ongoing.
>
> Song

by the way, i think it's better test clock_settime64 and clock_gettime64 
together, is it ok for you?

if i set time at 2038 and set it back at the end of test, will it have 
impact to the testing devices?

Song

>
>>
>>>
>>>
>>>
>>>
>>>   #define __NR_COBALT_SYSCALLS            128 /* Power of 2 */
>>>
>>>
>>>
>>>
>>> diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
>>> index 6a47956..9643f8f 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];
>>>
>>>
>>>
>>>
>>> @@ -193,6 +194,17 @@ COBALT_SYSCALL(clock_settime, current,
>>>       return __cobalt_clock_settime(clock_id, &ts);
>>>   }
>>>
>>>
>>>
>>>
>>> +COBALT_SYSCALL(clock_settime64, current,
>>> +           (clockid_t clock_id, const struct __kernel_timespec
>>> __user *u_ts))
>>> +{
>>> +    struct timespec64 ts64;
>>> +
>>> +    if (cobalt_get_timespec64(&ts64, u_ts))
>>> +        return -EFAULT;
>>> +
>>> +    return __cobalt_clock_settime(clock_id, &ts64);
>>> +}
>>> +
>>>   COBALT_SYSCALL(clock_adjtime, current,
>>>              (clockid_t clock_id, struct __user_old_timex __user *u_tx))
>>>   {
>>> diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
>>> index e69e76e..90f79fa 100644
>>> --- a/kernel/cobalt/posix/clock.h
>>> +++ b/kernel/cobalt/posix/clock.h
>>> @@ -119,6 +119,10 @@ COBALT_SYSCALL_DECL(clock_gettime,
>>>   COBALT_SYSCALL_DECL(clock_settime,
>>>               (clockid_t clock_id, const struct __user_old_timespec
>>> __user *u_ts));
>>>
>>>
>>>
>>>
>>> +COBALT_SYSCALL_DECL(clock_settime64,
>>> +            (clockid_t clock_id,
>>> +             const struct __kernel_timespec __user *u_ts));
>>> +
>>>   COBALT_SYSCALL_DECL(clock_adjtime,
>>>               (clockid_t clock_id, struct __user_old_timex __user
>>> *u_tx));
>>>
>>
>
>
>
>




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

* Re: [PATCH 2/4] [y2038]cobalt: posix: clock: Adding clock_settime64
  2021-03-11  9:58     ` chensong
@ 2021-03-11 10:10       ` florian.bezdeka
  2021-03-11 10:37       ` Jan Kiszka
  1 sibling, 0 replies; 6+ messages in thread
From: florian.bezdeka @ 2021-03-11 10:10 UTC (permalink / raw)
  To: rpm, xenomai, chensong

On Thu, 2021-03-11 at 17:58 +0800, chensong wrote:
> > > 
> > > I assume we should keep the order of affected syscalls. The next one
> > > would be sc_cobalt_clock_gettime64.
> > 
> > yes, i thought about catagorizing them in order, probably adjust
> > sc_cobalt_sem_timedwait64 later, next is sc_cobalt_clock_gettime64.
> > 
> > 
> > > 
> > > And I'm missing the tests... Please add tests for everything you add /
> > > fix.
> > 
> > ongoing.
> > 
> > Song
> 
> by the way, i think it's better test clock_settime64 and clock_gettime64 
> together, is it ok for you?
> 
> if i set time at 2038 and set it back at the end of test, will it have 
> impact to the testing devices?

Sounds reasonable...

> 
> Song
> 
> > 
> > 


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

* Re: [PATCH 2/4] [y2038]cobalt: posix: clock: Adding clock_settime64
  2021-03-11  9:58     ` chensong
  2021-03-11 10:10       ` florian.bezdeka
@ 2021-03-11 10:37       ` Jan Kiszka
  1 sibling, 0 replies; 6+ messages in thread
From: Jan Kiszka @ 2021-03-11 10:37 UTC (permalink / raw)
  To: chensong, florian.bezdeka, rpm, xenomai

On 11.03.21 10:58, chensong via Xenomai wrote:
> 
> 
> On 2021年03月11日 17:29, chensong via Xenomai wrote:
>>
>>
>> On 2021年03月11日 17:03, florian.bezdeka@siemens.com wrote:
>>> On Thu, 2021-03-11 at 10:46 +0800, chensong wrote:
>>>> Adding a new syscall clock_settime64 specific for timespec64,
>>>> It can solve y2038 in below scenarios:
>>>>
>>>> 1, 64bit kernel, y2038 safe
>>>> 2, 32bit kernel, 32bit time_t, go to clock_settime, no break,
>>>>     y2038 not safe.
>>>> 3, 32bit kernel, 64bit time_t, go to clock_settime64 by the help
>>>>     of libcobalt, no break, y2038 safe.
>>>>
>>>> Signed-off-by: chensong <chensong@tj.kylinos.cn>
>>>> ---
>>>>   include/cobalt/uapi/syscall.h |  1 +
>>>>   kernel/cobalt/posix/clock.c   | 12 ++++++++++++
>>>>   kernel/cobalt/posix/clock.h   |  4 ++++
>>>>   3 files changed, 17 insertions(+)
>>>>
>>>> diff --git a/include/cobalt/uapi/syscall.h
>>>> b/include/cobalt/uapi/syscall.h
>>>> index 8895d2b..291b550 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_settime64        103
>>>
>>> I assume we should keep the order of affected syscalls. The next one
>>> would be sc_cobalt_clock_gettime64.
>>
>> yes, i thought about catagorizing them in order, probably adjust
>> sc_cobalt_sem_timedwait64 later, next is sc_cobalt_clock_gettime64.
>>
>>
>>>
>>> And I'm missing the tests... Please add tests for everything you add /
>>> fix.
>>
>> ongoing.
>>
>> Song
> 
> by the way, i think it's better test clock_settime64 and clock_gettime64
> together, is it ok for you?
> 
> if i set time at 2038 and set it back at the end of test, will it have
> impact to the testing devices?

Yes, if something is depending on the absence of time jumps while the
test is running. But I think it is fine to require that nothing critical
is running in parallel to the test anyway.

BTW, with Dovetail and the unified clocksource, we have to require that
the user disables any ntp services because they can get upset and work
against the test. I-pipe based Xenomai has a separate time base, though.

Jan

-- 
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux


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

end of thread, other threads:[~2021-03-11 10:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11  2:46 [PATCH 2/4] [y2038]cobalt: posix: clock: Adding clock_settime64 chensong
2021-03-11  9:03 ` florian.bezdeka
2021-03-11  9:29   ` chensong
2021-03-11  9:58     ` chensong
2021-03-11 10:10       ` florian.bezdeka
2021-03-11 10:37       ` Jan Kiszka

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.