All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Bezdeka <florian.bezdeka@siemens.com>
To: xenomai@xenomai.org, jan.kiszka@siemens.com, rpm@xenomai.org,
	chensong@kylinos.cn
Subject: [y2038][RFC PATCH 2/2] y2038: Adding sem_timedwait_time64
Date: Thu,  4 Mar 2021 12:36:53 +0100	[thread overview]
Message-ID: <20210304113653.45432-3-florian.bezdeka@siemens.com> (raw)
In-Reply-To: <20210304113653.45432-1-florian.bezdeka@siemens.com>

Implementation is heavily inspired by the sem_timedwait syscall,
but expecting time64 based timespec / timeout.

We need two new syscall handlers:
  - The native one (COBALT_SYSCALL()) to get 32 bit kernels time64
    aware. This handler is added for 64 bit kernels as well, but not
    used. As we don't have separate syscall tables for this both
    worlds we have to add it.

 - The compat handler (COBALT_SYSCALL32emu()) for x32 or x86
   applications running on an x86_64 kernel. Otherwise the redirection
   to the compat / emulation syscalls is broken.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/cobalt/uapi/syscall.h   |  1 +
 kernel/cobalt/posix/sem.c       | 12 ++++++++++++
 kernel/cobalt/posix/sem.h       |  4 ++++
 kernel/cobalt/posix/syscall32.c | 12 ++++++++++++
 kernel/cobalt/posix/syscall32.h |  4 ++++
 5 files changed, 33 insertions(+)

diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
index aa3c308d0..9b005da47 100644
--- a/include/cobalt/uapi/syscall.h
+++ b/include/cobalt/uapi/syscall.h
@@ -122,6 +122,7 @@
 #define sc_cobalt_sendmmsg			99
 #define sc_cobalt_clock_adjtime			100
 #define sc_cobalt_thread_setschedprio		101
+#define sc_cobalt_sem_timedwait_time64		102
 
 #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
 
diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index a0565e9f8..a2211af36 100644
--- a/kernel/cobalt/posix/sem.c
+++ b/kernel/cobalt/posix/sem.c
@@ -430,6 +430,18 @@ COBALT_SYSCALL(sem_timedwait, primary,
 	return __cobalt_sem_timedwait(u_sem, &ts64);
 }
 
+COBALT_SYSCALL(sem_timedwait_time64, primary,
+	       (struct cobalt_sem_shadow __user *u_sem,
+		const struct __kernel_timespec __user *u_ts))
+{
+	struct timespec64 ts64;
+
+	if (get_timespec64(&ts64, u_ts))
+		return -EFAULT;
+
+	return __cobalt_sem_timedwait(u_sem, &ts64);
+}
+
 COBALT_SYSCALL(sem_trywait, primary,
 	       (struct cobalt_sem_shadow __user *u_sem))
 {
diff --git a/kernel/cobalt/posix/sem.h b/kernel/cobalt/posix/sem.h
index 658e11f7a..8491b69ba 100644
--- a/kernel/cobalt/posix/sem.h
+++ b/kernel/cobalt/posix/sem.h
@@ -66,6 +66,10 @@ __cobalt_sem_open(struct cobalt_sem_shadow __user *usm,
 int __cobalt_sem_timedwait(struct cobalt_sem_shadow __user *u_sem,
 			   const struct timespec64 *ts);
 
+COBALT_SYSCALL_DECL(sem_timedwait_time64,
+		    (struct cobalt_sem_shadow __user *u_sem,
+		     const struct __kernel_timespec __user *u_ts));
+
 int __cobalt_sem_destroy(xnhandle_t handle);
 
 void cobalt_nsem_reclaim(struct cobalt_process *process);
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index c2a2423ed..d50532952 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -136,6 +136,18 @@ COBALT_SYSCALL32emu(sem_timedwait, primary,
 	return __cobalt_sem_timedwait(u_sem, &ts64);
 }
 
+COBALT_SYSCALL32emu(sem_timedwait_time64, primary,
+		    (struct cobalt_sem_shadow __user *u_sem,
+		     const struct __kernel_timespec __user *u_ts))
+{
+	struct timespec64 ts64;
+
+	if (get_timespec64(&ts64, u_ts))
+		return -EFAULT;
+
+	return __cobalt_sem_timedwait(u_sem, &ts64);
+}
+
 COBALT_SYSCALL32emu(clock_getres, current,
 		    (clockid_t clock_id,
 		     struct old_timespec32 __user *u_ts))
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index d72fd2022..3612bf751 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -231,4 +231,8 @@ COBALT_SYSCALL32emu_DECL(sem_timedwait,
 			 (struct cobalt_sem_shadow __user *u_sem,
 			  const struct old_timespec32 __user *u_ts));
 
+COBALT_SYSCALL32emu_DECL(sem_timedwait_time64,
+			 (struct cobalt_sem_shadow __user * u_sem,
+			  const struct __kernel_timespec __user *u_ts));
+
 #endif /* !_COBALT_POSIX_SYSCALL32_H */
-- 
2.29.2



  parent reply	other threads:[~2021-03-04 11:36 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-20 15:18 [PATCH 1/5] cobalt/kernel: y2038: convert struct timeval to __kernel_old_timeval Philippe Gerum
2021-02-20 15:18 ` [PATCH 2/5] cobalt/kernel: y2038: convert struct timespec to timespec64 Philippe Gerum
2021-02-21  2:17   ` chensong
2021-02-21 15:27     ` Philippe Gerum
2021-02-22  1:04       ` chensong
2021-02-22  8:21       ` florian.bezdeka
2021-02-22  9:08         ` Philippe Gerum
2021-03-08 12:19           ` Jan Kiszka
2021-03-08 14:01             ` Philippe Gerum
2021-03-08 14:03               ` Jan Kiszka
2021-03-03 10:05   ` florian.bezdeka
2021-03-04  9:35     ` Philippe Gerum
2021-03-04  9:49       ` florian.bezdeka
2021-03-04  9:55         ` Philippe Gerum
2021-03-04  9:59           ` florian.bezdeka
2021-03-04 10:08           ` Philippe Gerum
2021-03-04 11:36             ` [y2038][RFC PATCH 0/2] Pattern for implementing y2038 syscalls Florian Bezdeka
2021-03-04 11:36               ` [y2038][RFC PATCH 1/2] y2038: Fixing the sem_timedwait syscall for 32 bit systems Florian Bezdeka
2021-03-04 15:11                 ` Philippe Gerum
2021-03-04 15:22                   ` florian.bezdeka
2021-03-04 15:42                     ` Philippe Gerum
2021-03-08 17:02                       ` [RFC PATCH v2 0/4] Pattern for implementing y2038 syscalls Florian Bezdeka
2021-03-08 17:02                         ` [RFC PATCH v2 1/4] y2038: Fixing the sem_timedwait syscall for 32 bit systems Florian Bezdeka
2021-03-08 17:12                           ` Jan Kiszka
2021-03-08 18:11                             ` florian.bezdeka
2021-03-08 18:22                               ` Jan Kiszka
2021-03-09  9:46                           ` Philippe Gerum
2021-03-09 11:08                             ` florian.bezdeka
2021-03-08 17:02                         ` [RFC PATCH v2 2/4] y2038: Adding sem_timedwait_time64 Florian Bezdeka
2021-03-08 18:28                           ` Jan Kiszka
2021-03-09  7:53                             ` florian.bezdeka
2021-03-10  7:51                               ` florian.bezdeka
2021-03-10  9:46                                 ` chensong
2021-03-08 17:02                         ` [RFC PATCH v2 3/4] y2038: Add tests for the sc_cobalt_sem_timedwait_time64 syscall Florian Bezdeka
2021-03-08 18:35                           ` Jan Kiszka
2021-03-09  8:00                             ` florian.bezdeka
2021-03-08 17:02                         ` [RFC PATCH v2 4/4] y2038: lib/cobalt: Add support of sc_cobalt_sem_timedwait_time64 Florian Bezdeka
2021-03-10 13:09                           ` [y2038][PATCH v3 0/4] Pattern for implementing y2038 syscalls Florian Bezdeka
2021-03-10 13:09                             ` [y2038][PATCH v3 1/4] y2038: Fixing the sem_timedwait syscall for 32 bit systems Florian Bezdeka
2021-03-10 13:09                             ` [y2038][PATCH v3 2/4] y2038: Adding sem_timedwait64 Florian Bezdeka
2021-03-10 13:09                             ` [y2038][PATCH v3 3/4] y2038: Add tests for the sc_cobalt_sem_timedwait64 syscall Florian Bezdeka
2021-03-10 13:09                             ` [y2038][PATCH v3 4/4] y2038: lib/cobalt: Add support of sc_cobalt_sem_timedwait64 Florian Bezdeka
2021-03-11  2:38                               ` chensong
2021-03-04 11:36               ` Florian Bezdeka [this message]
2021-03-05  5:49                 ` [y2038][RFC PATCH 2/2] y2038: Adding sem_timedwait_time64 chensong
2021-03-05  6:36                   ` florian.bezdeka
2021-03-05  7:42                     ` chensong
2021-03-05  7:53                       ` florian.bezdeka
2021-03-08 12:59             ` [PATCH 2/5] cobalt/kernel: y2038: convert struct timespec to timespec64 Jan Kiszka
2021-03-10 17:52             ` florian.bezdeka
2021-03-10 18:14               ` Philippe Gerum
2021-03-03 14:36   ` florian.bezdeka
2021-03-04  9:44     ` Philippe Gerum
2021-03-04  9:57       ` florian.bezdeka
2021-02-20 15:18 ` [PATCH 3/5] lib: y2038: convert to internal timespec type Philippe Gerum
2021-02-20 15:18 ` [PATCH 4/5] cobalt/kernel: y2038: convert struct itimerspec to itimerspec64 Philippe Gerum
2021-02-20 15:18 ` [PATCH 5/5] cobalt/kernel: y2038: convert struct timex to __kernel_timex Philippe Gerum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210304113653.45432-3-florian.bezdeka@siemens.com \
    --to=florian.bezdeka@siemens.com \
    --cc=chensong@kylinos.cn \
    --cc=jan.kiszka@siemens.com \
    --cc=rpm@xenomai.org \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.