xenomai.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/4] y2038: Add time64_t support to scheduler and thread APIs
@ 2023-07-17  9:10 Florian Bezdeka
  2023-07-17  9:10 ` [PATCH v2 1/4] cobalt/posix/syscall32: Remove unused mq_fetch_timeout Florian Bezdeka
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Florian Bezdeka @ 2023-07-17  9:10 UTC (permalink / raw)
  To: xenomai, jan.kiszka; +Cc: Florian Bezdeka

Hi all,

this is hopefully the last preparation series necessary to turn on
time64_t support (a.k.a. y2038 support). 

With this series applied the Xenomai specific APIs around scheduler and
thread APIs will support time64_t when requested. The final "turn on by
default" switch will be part of the final y2038 series (which is hopefully
the next one).

The remaining stuff can be found in my y2038 queue at [1].
The Xenomai hackerspace wiki is up to date and represents the current
state of the y2038 work. See [2].

Best regards,
Florian

[1] https://gitlab.com/Xenomai/xenomai-hacker-space/-/commits/florian%2Fy2038
[2] https://gitlab.com/Xenomai/xenomai-hacker-space/-/wikis/y2038/Y2038_Roadmap

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
Changes in v2:
- Removed patches that were already merged into next 
- Instead of introducing new time64_t syscalls the entire uapi around
  thread and sched has been moved to "time64_t always"
- Link to v1: https://lore.kernel.org/r/20230630-florian-y2038-part-four-upstreaming-v1-0-604a089542c2@siemens.com

---
Florian Bezdeka (4):
      cobalt/posix/syscall32: Remove unused mq_fetch_timeout
      y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
      y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex}
      y2038: cobalt/{thread,sched}: Remove obsolete compat handling

 include/cobalt/kernel/compat.h                     |  49 -----
 include/cobalt/uapi/kernel/types.h                 |  54 +----
 include/cobalt/uapi/sched.h                        |  14 +-
 .../arch/arm/include/asm/xenomai/uapi/features.h   |   2 +-
 .../arch/arm64/include/asm/xenomai/uapi/features.h |   2 +-
 .../arch/x86/include/asm/xenomai/syscall32-table.h |   8 -
 .../arch/x86/include/asm/xenomai/uapi/features.h   |   2 +-
 .../cobalt/include/asm-generic/xenomai/syscall.h   |  29 +--
 kernel/cobalt/posix/clock.c                        |  23 +-
 kernel/cobalt/posix/clock.h                        |  28 +--
 kernel/cobalt/posix/compat.c                       |  72 -------
 kernel/cobalt/posix/cond.c                         |   4 +-
 kernel/cobalt/posix/cond.h                         |   2 +-
 kernel/cobalt/posix/event.c                        |   4 +-
 kernel/cobalt/posix/event.h                        |   2 +-
 kernel/cobalt/posix/io.c                           |   4 +-
 kernel/cobalt/posix/io.h                           |   2 +-
 kernel/cobalt/posix/monitor.c                      |   4 +-
 kernel/cobalt/posix/monitor.h                      |   2 +-
 kernel/cobalt/posix/mqueue.c                       |   6 +-
 kernel/cobalt/posix/mqueue.h                       |   4 +-
 kernel/cobalt/posix/mutex.c                        |   4 +-
 kernel/cobalt/posix/mutex.h                        |   2 +-
 kernel/cobalt/posix/sched.c                        |  16 +-
 kernel/cobalt/posix/sem.c                          |   4 +-
 kernel/cobalt/posix/sem.h                          |   2 +-
 kernel/cobalt/posix/signal.c                       |   2 +-
 kernel/cobalt/posix/signal.h                       |   2 +-
 kernel/cobalt/posix/syscall32.c                    | 239 ---------------------
 kernel/cobalt/posix/syscall32.h                    |  45 ----
 kernel/cobalt/posix/thread.c                       |   8 +-
 kernel/cobalt/posix/timer.c                        |  14 +-
 kernel/cobalt/posix/timer.h                        |   6 +-
 kernel/cobalt/posix/timerfd.c                      |  14 +-
 kernel/cobalt/posix/timerfd.h                      |   6 +-
 lib/cobalt/clock.c                                 |   2 +-
 lib/cobalt/internal.h                              |   5 +
 lib/cobalt/timer.c                                 |   4 +-
 lib/cobalt/timerfd.c                               |   4 +-
 39 files changed, 127 insertions(+), 569 deletions(-)
---
base-commit: e1567904ecbac671aa9bf6cc0fa150bf43bfb4e9
change-id: 20230630-florian-y2038-part-four-upstreaming-0c10a5eccfc1

Best regards,
-- 
Florian Bezdeka <florian.bezdeka@siemens.com>


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

* [PATCH v2 1/4] cobalt/posix/syscall32: Remove unused mq_fetch_timeout
  2023-07-17  9:10 [PATCH v2 0/4] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
@ 2023-07-17  9:10 ` Florian Bezdeka
  2023-07-20 16:37   ` Jan Kiszka
  2023-07-17  9:10 ` [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t Florian Bezdeka
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 13+ messages in thread
From: Florian Bezdeka @ 2023-07-17  9:10 UTC (permalink / raw)
  To: xenomai, jan.kiszka; +Cc: Florian Bezdeka

Removal of unused (and broken) code. Using cobalt_get_u_timespec would
have been wrong and sys32_fetch_timespec would have been correct.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 kernel/cobalt/posix/syscall32.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index 780d276b1..c82cc60a2 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -318,12 +318,6 @@ COBALT_SYSCALL32emu(mq_timedreceive64, primary,
 	return ret ?: cobalt_copy_to_user(u_len, &clen, sizeof(*u_len));
 }
 
-static inline int mq_fetch_timeout(struct timespec64 *ts,
-				   const void __user *u_ts)
-{
-	return u_ts == NULL ? -EFAULT : cobalt_get_u_timespec(ts, u_ts);
-}
-
 COBALT_SYSCALL32emu(mq_notify, primary,
 		    (mqd_t fd, const struct compat_sigevent *__user u_cev))
 {

-- 
2.39.2


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

* [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
  2023-07-17  9:10 [PATCH v2 0/4] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
  2023-07-17  9:10 ` [PATCH v2 1/4] cobalt/posix/syscall32: Remove unused mq_fetch_timeout Florian Bezdeka
@ 2023-07-17  9:10 ` Florian Bezdeka
  2023-07-20 16:36   ` Jan Kiszka
  2023-07-20 16:47   ` Jan Kiszka
  2023-07-17  9:10 ` [PATCH v2 3/4] y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex} Florian Bezdeka
  2023-07-17  9:10 ` [PATCH v2 4/4] y2038: cobalt/{thread,sched}: Remove obsolete compat handling Florian Bezdeka
  3 siblings, 2 replies; 13+ messages in thread
From: Florian Bezdeka @ 2023-07-17  9:10 UTC (permalink / raw)
  To: xenomai, jan.kiszka; +Cc: Florian Bezdeka

Instead of implementing time64_t based cobalt services for the
following services we simply break the ABI and make it time64_t aware.

Affected cobalt services:
  - cobalt_thread_create
  - cobalt_thread_setschedparam_ex
  - cobalt_thread_getschedparam_ex
  - cobalt_sched_setconfig_np
  - cobalt_sched_getconfig_np
  - cobalt_sched_setscheduler_ex
  - cobalt_sched_getscheduler_ex

XENOMAI_ABI_REV is incremented on all supported plattforms to express
the ABI breakage.

The memory alignment of some data structures is changed by adding
some anonymous paddings. This allows us to remove some compat specific
services afterwards. The memory layout is identical on all platforms
now.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/cobalt/uapi/kernel/types.h                       |  5 +++++
 include/cobalt/uapi/sched.h                              | 14 +++++++++-----
 .../cobalt/arch/arm/include/asm/xenomai/uapi/features.h  |  2 +-
 .../arch/arm64/include/asm/xenomai/uapi/features.h       |  2 +-
 .../cobalt/arch/x86/include/asm/xenomai/uapi/features.h  |  2 +-
 kernel/cobalt/posix/clock.h                              | 16 ++++++++++------
 kernel/cobalt/posix/sched.c                              | 16 ++++++++--------
 kernel/cobalt/posix/thread.c                             |  8 ++++----
 8 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/include/cobalt/uapi/kernel/types.h b/include/cobalt/uapi/kernel/types.h
index 2c931c29c..495c94506 100644
--- a/include/cobalt/uapi/kernel/types.h
+++ b/include/cobalt/uapi/kernel/types.h
@@ -57,6 +57,11 @@ static inline xnhandle_t xnhandle_get_id(xnhandle_t handle)
 	return handle & ~XN_HANDLE_TRANSIENT_MASK;
 }
 
+struct xn_ts64 {
+	__u64 tv_sec;
+	__u64 tv_nsec;
+};
+
 /*
  * Our representation of time specs at the kernel<->user interface
  * boundary at the moment, until we have fully transitioned to a
diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h
index 14095870f..6b1639feb 100644
--- a/include/cobalt/uapi/sched.h
+++ b/include/cobalt/uapi/sched.h
@@ -33,15 +33,17 @@
 
 struct __sched_ss_param {
 	int __sched_low_priority;
-	struct __user_old_timespec __sched_repl_period;
-	struct __user_old_timespec __sched_init_budget;
+	int: 32;
+	struct xn_ts64 __sched_repl_period;
+	struct xn_ts64 __sched_init_budget;
 	int __sched_max_repl;
+	int: 32;
 };
 
 #define sched_rr_quantum	sched_u.rr.__sched_rr_quantum
 
 struct __sched_rr_param {
-	struct __user_old_timespec __sched_rr_quantum;
+	struct xn_ts64 __sched_rr_quantum;
 };
 
 #ifndef SCHED_TP
@@ -54,9 +56,10 @@ struct __sched_tp_param {
 };
 
 struct sched_tp_window {
-	struct __user_old_timespec offset;
-	struct __user_old_timespec duration;
+	struct xn_ts64 offset;
+	struct xn_ts64 duration;
 	int ptid;
+	int: 32;
 };
 
 enum {
@@ -122,6 +125,7 @@ struct __sched_config_quota {
 
 struct sched_param_ex {
 	int sched_priority;
+	int: 32;
 	union {
 		struct __sched_ss_param ss;
 		struct __sched_rr_param rr;
diff --git a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
index 43b7afb10..fdd5c0e32 100644
--- a/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/arm/include/asm/xenomai/uapi/features.h
@@ -22,7 +22,7 @@
 #define _COBALT_ARM_ASM_UAPI_FEATURES_H
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   18UL
+#define XENOMAI_ABI_REV   19UL
 
 #define XENOMAI_FEAT_DEP (__xn_feat_generic_mask)
 
diff --git a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
index b98a96392..301797748 100644
--- a/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/arm64/include/asm/xenomai/uapi/features.h
@@ -22,7 +22,7 @@
 #define _COBALT_ARM64_ASM_UAPI_FEATURES_H
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   2UL
+#define XENOMAI_ABI_REV   3UL
 
 #define XENOMAI_FEAT_DEP (__xn_feat_generic_mask)
 
diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h b/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h
index 65f8164a0..045adf0c1 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/uapi/features.h
@@ -19,7 +19,7 @@
 #define _COBALT_X86_ASM_UAPI_FEATURES_H
 
 /* The ABI revision level we use on this arch. */
-#define XENOMAI_ABI_REV   18UL
+#define XENOMAI_ABI_REV   19UL
 
 #define XENOMAI_FEAT_DEP  __xn_feat_generic_mask
 
diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
index 38b59e24f..82c26ea08 100644
--- a/kernel/cobalt/posix/clock.h
+++ b/kernel/cobalt/posix/clock.h
@@ -33,11 +33,6 @@ static inline void ns2ts(struct timespec64 *ts, xnticks_t nsecs)
 	ts->tv_sec = xnclock_divrem_billion(nsecs, &ts->tv_nsec);
 }
 
-static inline void u_ns2ts(struct __user_old_timespec *ts, xnticks_t nsecs)
-{
-	ts->tv_sec = xnclock_divrem_billion(nsecs, &ts->tv_nsec);
-}
-
 static inline xnticks_t ts2ns(const struct timespec64 *ts)
 {
 	xnticks_t nsecs = ts->tv_nsec;
@@ -48,7 +43,7 @@ static inline xnticks_t ts2ns(const struct timespec64 *ts)
 	return nsecs;
 }
 
-static inline xnticks_t u_ts2ns(const struct __user_old_timespec *ts)
+static inline xnticks_t xnts64_2ns(const struct xn_ts64 *ts)
 {
 	xnticks_t nsecs = ts->tv_nsec;
 
@@ -76,6 +71,15 @@ static inline void ticks2ts64(struct timespec64 *ts, xnticks_t ticks)
 	ts->tv_nsec = nsecs;
 }
 
+static inline void ticks2xnts64(struct xn_ts64 *ts, xnticks_t ticks)
+{
+	unsigned long nsecs;
+
+	ts->tv_sec = xnclock_divrem_billion(ticks, &nsecs);
+	ts->tv_nsec = nsecs;
+}
+
+
 static inline xnticks_t clock_get_ticks(clockid_t clock_id)
 {
 	return clock_id == CLOCK_REALTIME ?
diff --git a/kernel/cobalt/posix/sched.c b/kernel/cobalt/posix/sched.c
index 994ee88d9..41c935f59 100644
--- a/kernel/cobalt/posix/sched.c
+++ b/kernel/cobalt/posix/sched.c
@@ -73,7 +73,7 @@ cobalt_sched_policy_param(union xnsched_policy_param *param,
 		break;
 	case SCHED_RR:
 		/* if unspecified, use current one. */
-		tslice = u_ts2ns(&param_ex->sched_rr_quantum);
+		tslice = xnts64_2ns(&param_ex->sched_rr_quantum);
 		if (tslice == XN_INFINITE && tslice_r)
 			tslice = *tslice_r;
 		fallthrough;
@@ -92,8 +92,8 @@ cobalt_sched_policy_param(union xnsched_policy_param *param,
 		param->pss.normal_prio = param_ex->sched_priority;
 		param->pss.low_prio = param_ex->sched_ss_low_priority;
 		param->pss.current_prio = param->pss.normal_prio;
-		param->pss.init_budget = u_ts2ns(&param_ex->sched_ss_init_budget);
-		param->pss.repl_period = u_ts2ns(&param_ex->sched_ss_repl_period);
+		param->pss.init_budget = xnts64_2ns(&param_ex->sched_ss_init_budget);
+		param->pss.repl_period = xnts64_2ns(&param_ex->sched_ss_repl_period);
 		param->pss.max_repl = param_ex->sched_ss_max_repl;
 		sched_class = &xnsched_class_sporadic;
 		break;
@@ -280,11 +280,11 @@ int set_tp_config(int cpu, union sched_config *config, size_t len)
 		 * be defined using windows assigned to the pseudo
 		 * partition #-1.
 		 */
-		offset = u_ts2ns(&p->offset);
+		offset = xnts64_2ns(&p->offset);
 		if (offset != next_offset)
 			goto cleanup_and_fail;
 
-		duration = u_ts2ns(&p->duration);
+		duration = xnts64_2ns(&p->duration);
 		if (duration <= 0)
 			goto cleanup_and_fail;
 
@@ -357,11 +357,11 @@ ssize_t get_tp_config(int cpu, void __user *u_config, size_t len,
 	config->tp.nr_windows = gps->pwin_nr;
 	for (n = 0, pp = p = config->tp.windows, pw = w = gps->pwins;
 	     n < gps->pwin_nr; pp = p, p++, pw = w, w++, n++) {
-		u_ns2ts(&p->offset, w->w_offset);
-		u_ns2ts(&pp->duration, w->w_offset - pw->w_offset);
+		ticks2xnts64(&p->offset, w->w_offset);
+		ticks2xnts64(&pp->duration, w->w_offset - pw->w_offset);
 		p->ptid = w->w_part;
 	}
-	u_ns2ts(&pp->duration, gps->tf_duration - pw->w_offset);
+	ticks2xnts64(&pp->duration, gps->tf_duration - pw->w_offset);
 	ret = put_config(SCHED_TP, u_config, len, config, elen);
 	xnfree(config);
 out:
diff --git a/kernel/cobalt/posix/thread.c b/kernel/cobalt/posix/thread.c
index 94a6e394e..46c3f4797 100644
--- a/kernel/cobalt/posix/thread.c
+++ b/kernel/cobalt/posix/thread.c
@@ -302,7 +302,7 @@ int __cobalt_thread_getschedparam_ex(struct cobalt_thread *thread,
 
 	if (base_class == &xnsched_class_rt) {
 		if (xnthread_test_state(base_thread, XNRRB)) {
-			u_ns2ts(&param_ex->sched_rr_quantum, base_thread->rrperiod);
+			ticks2xnts64(&param_ex->sched_rr_quantum, base_thread->rrperiod);
 			*policy_r = SCHED_RR;
 		}
 		goto out;
@@ -318,8 +318,8 @@ int __cobalt_thread_getschedparam_ex(struct cobalt_thread *thread,
 #ifdef CONFIG_XENO_OPT_SCHED_SPORADIC
 	if (base_class == &xnsched_class_sporadic) {
 		param_ex->sched_ss_low_priority = base_thread->pss->param.low_prio;
-		u_ns2ts(&param_ex->sched_ss_repl_period, base_thread->pss->param.repl_period);
-		u_ns2ts(&param_ex->sched_ss_init_budget, base_thread->pss->param.init_budget);
+		ticks2xnts64(&param_ex->sched_ss_repl_period, base_thread->pss->param.repl_period);
+		ticks2xnts64(&param_ex->sched_ss_init_budget, base_thread->pss->param.init_budget);
 		param_ex->sched_ss_max_repl = base_thread->pss->param.max_repl;
 		goto out;
 	}
@@ -930,7 +930,7 @@ const char *cobalt_trace_parse_sched_params(struct trace_seq *p, int policy,
 		break;
 	case SCHED_SPORADIC:
 		trace_seq_printf(p, "priority=%d, low_priority=%d, "
-				 "budget=(%ld.%09ld), period=(%ld.%09ld), "
+				 "budget=(%lld.%09lld), period=(%lld.%09lld), "
 				 "maxrepl=%d",
 				 params->sched_priority,
 				 params->sched_ss_low_priority,

-- 
2.39.2


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

* [PATCH v2 3/4] y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex}
  2023-07-17  9:10 [PATCH v2 0/4] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
  2023-07-17  9:10 ` [PATCH v2 1/4] cobalt/posix/syscall32: Remove unused mq_fetch_timeout Florian Bezdeka
  2023-07-17  9:10 ` [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t Florian Bezdeka
@ 2023-07-17  9:10 ` Florian Bezdeka
  2023-07-17  9:10 ` [PATCH v2 4/4] y2038: cobalt/{thread,sched}: Remove obsolete compat handling Florian Bezdeka
  3 siblings, 0 replies; 13+ messages in thread
From: Florian Bezdeka @ 2023-07-17  9:10 UTC (permalink / raw)
  To: xenomai, jan.kiszka; +Cc: Florian Bezdeka

The types below were "native" types representing 64 bit time_t on 64
bit systems and 32 bit time_t on 32 bit systems. As those types were
xenomai specific types they could not be used for "auto y2038 support"
enablement by using compile time flags.

1:1 type replacements:
  __user_old_timespec    ->  __kernel_old_timespec (still "native")
  __user_old_timeval     ->  __kernel_old_timeval  (still "native")

Type migrations to "32 bit always":
  __user_old_itimerspec  ->  old_itimerspec32
  __user_old_timex       ->  old_timex32

  Affected syscalls will only be used by 32 bit applications. The
  "native" variant will be routed to 64 bit services.

Renamed functions:
  cobalt_get_u_itimerspec -> cobalt_get_itimerspec32
  cobalt_put_u_itimerspec -> cobalt_put_itimerspec32
  cobalt_get_u_timespec   -> cobalt_get_old_timespec
  cobalt_put_u_timespec   -> cobalt_put_old_timespec

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/cobalt/uapi/kernel/types.h                 | 53 ----------------------
 .../cobalt/include/asm-generic/xenomai/syscall.h   | 29 ++++++------
 kernel/cobalt/posix/clock.c                        | 23 +++++-----
 kernel/cobalt/posix/clock.h                        | 12 ++---
 kernel/cobalt/posix/cond.c                         |  4 +-
 kernel/cobalt/posix/cond.h                         |  2 +-
 kernel/cobalt/posix/event.c                        |  4 +-
 kernel/cobalt/posix/event.h                        |  2 +-
 kernel/cobalt/posix/io.c                           |  4 +-
 kernel/cobalt/posix/io.h                           |  2 +-
 kernel/cobalt/posix/monitor.c                      |  4 +-
 kernel/cobalt/posix/monitor.h                      |  2 +-
 kernel/cobalt/posix/mqueue.c                       |  6 +--
 kernel/cobalt/posix/mqueue.h                       |  4 +-
 kernel/cobalt/posix/mutex.c                        |  4 +-
 kernel/cobalt/posix/mutex.h                        |  2 +-
 kernel/cobalt/posix/sem.c                          |  4 +-
 kernel/cobalt/posix/sem.h                          |  2 +-
 kernel/cobalt/posix/signal.c                       |  2 +-
 kernel/cobalt/posix/signal.h                       |  2 +-
 kernel/cobalt/posix/timer.c                        | 14 +++---
 kernel/cobalt/posix/timer.h                        |  6 +--
 kernel/cobalt/posix/timerfd.c                      | 14 +++---
 kernel/cobalt/posix/timerfd.h                      |  6 +--
 lib/cobalt/clock.c                                 |  2 +-
 lib/cobalt/internal.h                              |  5 ++
 lib/cobalt/timer.c                                 |  4 +-
 lib/cobalt/timerfd.c                               |  4 +-
 28 files changed, 90 insertions(+), 132 deletions(-)

diff --git a/include/cobalt/uapi/kernel/types.h b/include/cobalt/uapi/kernel/types.h
index 495c94506..29ef3e7ef 100644
--- a/include/cobalt/uapi/kernel/types.h
+++ b/include/cobalt/uapi/kernel/types.h
@@ -62,57 +62,4 @@ struct xn_ts64 {
 	__u64 tv_nsec;
 };
 
-/*
- * Our representation of time specs at the kernel<->user interface
- * boundary at the moment, until we have fully transitioned to a
- * y2038-safe implementation in libcobalt. Once done, those legacy
- * types will be removed.
- */
-struct __user_old_timespec {
-	long  tv_sec;
-	long  tv_nsec;
-};
-
-struct __user_old_itimerspec {
-	struct __user_old_timespec it_interval;
-	struct __user_old_timespec it_value;
-};
-
-struct __user_old_timeval {
-	long  tv_sec;
-	long  tv_usec;
-};
-
-/* Lifted from include/uapi/linux/timex.h. */
-struct __user_old_timex {
-	unsigned int modes;	/* mode selector */
-	__kernel_long_t offset;	/* time offset (usec) */
-	__kernel_long_t freq;	/* frequency offset (scaled ppm) */
-	__kernel_long_t maxerror;/* maximum error (usec) */
-	__kernel_long_t esterror;/* estimated error (usec) */
-	int status;		/* clock command/status */
-	__kernel_long_t constant;/* pll time constant */
-	__kernel_long_t precision;/* clock precision (usec) (read only) */
-	__kernel_long_t tolerance;/* clock frequency tolerance (ppm)
-				   * (read only)
-				   */
-	struct __user_old_timeval time;	/* (read only, except for ADJ_SETOFFSET) */
-	__kernel_long_t tick;	/* (modified) usecs between clock ticks */
-
-	__kernel_long_t ppsfreq;/* pps frequency (scaled ppm) (ro) */
-	__kernel_long_t jitter; /* pps jitter (us) (ro) */
-	int shift;              /* interval duration (s) (shift) (ro) */
-	__kernel_long_t stabil;            /* pps stability (scaled ppm) (ro) */
-	__kernel_long_t jitcnt; /* jitter limit exceeded (ro) */
-	__kernel_long_t calcnt; /* calibration intervals (ro) */
-	__kernel_long_t errcnt; /* calibration errors (ro) */
-	__kernel_long_t stbcnt; /* stability limit exceeded (ro) */
-
-	int tai;		/* TAI offset (ro) */
-
-	int  :32; int  :32; int  :32; int  :32;
-	int  :32; int  :32; int  :32; int  :32;
-	int  :32; int  :32; int  :32;
-};
-
 #endif /* !_COBALT_UAPI_KERNEL_TYPES_H */
diff --git a/kernel/cobalt/include/asm-generic/xenomai/syscall.h b/kernel/cobalt/include/asm-generic/xenomai/syscall.h
index d61b985fb..facc60bcc 100644
--- a/kernel/cobalt/include/asm-generic/xenomai/syscall.h
+++ b/kernel/cobalt/include/asm-generic/xenomai/syscall.h
@@ -73,10 +73,11 @@ static inline int cobalt_strncpy_from_user(char *dst, const char __user *src,
  * sys32_get_*(), sys32_put_*() instead.
  */
 
-static inline int cobalt_get_u_timespec(struct timespec64 *dst,
-			const struct __user_old_timespec __user *src)
+static inline int
+cobalt_get_old_timespec(struct timespec64 *dst,
+			const struct __kernel_old_timespec __user *src)
 {
-	struct __user_old_timespec u_ts;
+	struct __kernel_old_timespec u_ts;
 	int ret;
 
 	ret = cobalt_copy_from_user(&u_ts, src, sizeof(u_ts));
@@ -89,11 +90,11 @@ static inline int cobalt_get_u_timespec(struct timespec64 *dst,
 	return 0;
 }
 
-static inline int cobalt_put_u_timespec(
-	struct __user_old_timespec __user *dst,
-	const struct timespec64 *src)
+static inline int
+cobalt_put_old_timespec(struct __kernel_old_timespec __user *dst,
+			const struct timespec64 *src)
 {
-	struct __user_old_timespec u_ts;
+	struct __kernel_old_timespec u_ts;
 	int ret;
 
 	u_ts.tv_sec = src->tv_sec;
@@ -106,10 +107,11 @@ static inline int cobalt_put_u_timespec(
 	return 0;
 }
 
-static inline int cobalt_get_u_itimerspec(struct itimerspec64 *dst,
-			const struct __user_old_itimerspec __user *src)
+static inline int
+cobalt_get_itimerspec32(struct itimerspec64 *dst,
+			const struct old_itimerspec32 __user *src)
 {
-	struct __user_old_itimerspec u_its;
+	struct old_itimerspec32 u_its;
 	int ret;
 
 	ret = cobalt_copy_from_user(&u_its, src, sizeof(u_its));
@@ -124,11 +126,10 @@ static inline int cobalt_get_u_itimerspec(struct itimerspec64 *dst,
 	return 0;
 }
 
-static inline int cobalt_put_u_itimerspec(
-	struct __user_old_itimerspec __user *dst,
-	const struct itimerspec64 *src)
+static inline int cobalt_put_itimerspec32(struct old_itimerspec32 __user *dst,
+					  const struct itimerspec64 *src)
 {
-	struct __user_old_itimerspec u_its;
+	struct old_itimerspec32 u_its;
 
 	u_its.it_interval.tv_sec = src->it_interval.tv_sec;
 	u_its.it_interval.tv_nsec = src->it_interval.tv_nsec;
diff --git a/kernel/cobalt/posix/clock.c b/kernel/cobalt/posix/clock.c
index 48cd87aef..845918a4a 100644
--- a/kernel/cobalt/posix/clock.c
+++ b/kernel/cobalt/posix/clock.c
@@ -76,7 +76,7 @@ int __cobalt_clock_getres(clockid_t clock_id, struct timespec64 *ts)
 }
 
 COBALT_SYSCALL(clock_getres, current,
-	       (clockid_t clock_id, struct __user_old_timespec __user *u_ts))
+	       (clockid_t clock_id, struct __kernel_old_timespec __user *u_ts))
 {
 	struct timespec64 ts;
 	int ret;
@@ -85,7 +85,7 @@ COBALT_SYSCALL(clock_getres, current,
 	if (ret)
 		return ret;
 
-	if (u_ts && cobalt_put_u_timespec(u_ts, &ts))
+	if (u_ts && cobalt_put_old_timespec(u_ts, &ts))
 		return -EFAULT;
 
 	trace_cobalt_clock_getres(clock_id, &ts);
@@ -141,7 +141,7 @@ int __cobalt_clock_gettime(clockid_t clock_id, struct timespec64 *ts)
 }
 
 COBALT_SYSCALL(clock_gettime, current,
-	       (clockid_t clock_id, struct __user_old_timespec __user *u_ts))
+	       (clockid_t clock_id, struct __kernel_old_timespec __user *u_ts))
 {
 	struct timespec64 ts;
 	int ret;
@@ -150,7 +150,7 @@ COBALT_SYSCALL(clock_gettime, current,
 	if (ret)
 		return ret;
 
-	if (cobalt_put_u_timespec(u_ts, &ts))
+	if (cobalt_put_old_timespec(u_ts, &ts))
 		return -EFAULT;
 
 	return 0;
@@ -216,11 +216,11 @@ int __cobalt_clock_adjtime(clockid_t clock_id, struct __kernel_timex *tx)
 }
 
 COBALT_SYSCALL(clock_settime, current,
-	       (clockid_t clock_id, const struct __user_old_timespec __user *u_ts))
+	       (clockid_t clock_id, const struct __kernel_old_timespec __user *u_ts))
 {
 	struct timespec64 ts;
 
-	if (cobalt_get_u_timespec(&ts, u_ts))
+	if (cobalt_get_old_timespec(&ts, u_ts))
 		return -EFAULT;
 
 	return __cobalt_clock_settime(clock_id, &ts);
@@ -238,8 +238,9 @@ COBALT_SYSCALL(clock_settime64, current,
 	return __cobalt_clock_settime(clock_id, &ts64);
 }
 
+/* Only used by 32 bit applications without time64_t support */
 COBALT_SYSCALL(clock_adjtime, current,
-	       (clockid_t clock_id, struct __user_old_timex __user *u_tx))
+	       (clockid_t clock_id, struct old_timex32 __user *u_tx))
 {
 	struct __kernel_timex tx;
 	int ret;
@@ -349,8 +350,8 @@ int __cobalt_clock_nanosleep(clockid_t clock_id, int flags,
 
 COBALT_SYSCALL(clock_nanosleep, primary,
 	       (clockid_t clock_id, int flags,
-		const struct __user_old_timespec __user *u_rqt,
-		struct __user_old_timespec __user *u_rmt))
+		const struct __kernel_old_timespec __user *u_rqt,
+		struct __kernel_old_timespec __user *u_rmt))
 {
 	struct timespec64 rqt, rmt, *rmtp = NULL;
 	int ret;
@@ -358,12 +359,12 @@ COBALT_SYSCALL(clock_nanosleep, primary,
 	if (u_rmt)
 		rmtp = &rmt;
 
-	if (cobalt_get_u_timespec(&rqt, u_rqt))
+	if (cobalt_get_old_timespec(&rqt, u_rqt))
 		return -EFAULT;
 
 	ret = __cobalt_clock_nanosleep(clock_id, flags, &rqt, rmtp);
 	if (ret == -EINTR && flags == 0 && rmtp) {
-		if (cobalt_put_u_timespec(u_rmt, rmtp))
+		if (cobalt_put_old_timespec(u_rmt, rmtp))
 			return -EFAULT;
 	}
 
diff --git a/kernel/cobalt/posix/clock.h b/kernel/cobalt/posix/clock.h
index 82c26ea08..12e8f702b 100644
--- a/kernel/cobalt/posix/clock.h
+++ b/kernel/cobalt/posix/clock.h
@@ -115,34 +115,34 @@ int __cobalt_clock_nanosleep(clockid_t clock_id, int flags,
 			     struct timespec64 *rmt);
 
 COBALT_SYSCALL_DECL(clock_getres,
-		    (clockid_t clock_id, struct __user_old_timespec __user *u_ts));
+		    (clockid_t clock_id, struct __kernel_old_timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(clock_getres64,
 		    (clockid_t clock_id, struct __kernel_timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(clock_gettime,
-		    (clockid_t clock_id, struct __user_old_timespec __user *u_ts));
+		    (clockid_t clock_id, struct __kernel_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));
+		    (clockid_t clock_id, const struct __kernel_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));
+		    (clockid_t clock_id, struct old_timex32 __user *u_tx));
 
 COBALT_SYSCALL_DECL(clock_adjtime64,
 		    (clockid_t clock_id, struct __kernel_timex __user *u_tx));
 
 COBALT_SYSCALL_DECL(clock_nanosleep,
 		    (clockid_t clock_id, int flags,
-		     const struct __user_old_timespec __user *u_rqt,
-		     struct __user_old_timespec __user *u_rmt));
+		     const struct __kernel_old_timespec __user *u_rqt,
+		     struct __kernel_old_timespec __user *u_rmt));
 
 COBALT_SYSCALL_DECL(clock_nanosleep64,
 		    (clockid_t clock_id, int flags,
diff --git a/kernel/cobalt/posix/cond.c b/kernel/cobalt/posix/cond.c
index 7b87fe908..cd9cf0cb9 100644
--- a/kernel/cobalt/posix/cond.c
+++ b/kernel/cobalt/posix/cond.c
@@ -273,7 +273,7 @@ struct us_cond_data {
 static inline int cond_fetch_timeout(struct timespec64 *ts,
 				     const void __user *u_ts)
 {
-	return u_ts == NULL ? -EFAULT :	cobalt_get_u_timespec(ts, u_ts);
+	return u_ts == NULL ? -EFAULT :	cobalt_get_old_timespec(ts, u_ts);
 }
 
 static inline int cond_fetch_timeout64(struct timespec64 *ts,
@@ -360,7 +360,7 @@ COBALT_SYSCALL(cond_wait_prologue, nonrestartable,
 		struct cobalt_mutex_shadow __user *u_mx,
 		int __user *u_err,
 		unsigned int timed,
-		struct __user_old_timespec __user *u_ts))
+		struct __kernel_old_timespec __user *u_ts))
 {
 	return __cobalt_cond_wait_prologue(u_cnd, u_mx, u_err, u_ts,
 					   timed ? cond_fetch_timeout : NULL);
diff --git a/kernel/cobalt/posix/cond.h b/kernel/cobalt/posix/cond.h
index c2fdd40e0..1eab5d26b 100644
--- a/kernel/cobalt/posix/cond.h
+++ b/kernel/cobalt/posix/cond.h
@@ -58,7 +58,7 @@ COBALT_SYSCALL_DECL(cond_wait_prologue,
 		     struct cobalt_mutex_shadow __user *u_mx,
 		     int __user *u_err,
 		     unsigned int timed,
-		     struct __user_old_timespec __user *u_ts));
+		     struct __kernel_old_timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(cond_wait_prologue64,
 		    (struct cobalt_cond_shadow __user *u_cnd,
diff --git a/kernel/cobalt/posix/event.c b/kernel/cobalt/posix/event.c
index a5fa45db8..4e9895004 100644
--- a/kernel/cobalt/posix/event.c
+++ b/kernel/cobalt/posix/event.c
@@ -194,14 +194,14 @@ COBALT_SYSCALL(event_wait, primary,
 	       (struct cobalt_event_shadow __user *u_event,
 		unsigned int bits,
 		unsigned int __user *u_bits_r,
-		int mode, const struct __user_old_timespec __user *u_ts))
+		int mode, const struct __kernel_old_timespec __user *u_ts))
 {
 	struct timespec64 ts, *tsp = NULL;
 	int ret;
 
 	if (u_ts) {
 		tsp = &ts;
-		ret = cobalt_get_u_timespec(&ts, u_ts);
+		ret = cobalt_get_old_timespec(&ts, u_ts);
 		if (ret)
 			return ret;
 	}
diff --git a/kernel/cobalt/posix/event.h b/kernel/cobalt/posix/event.h
index a67141f2b..d8c83ed75 100644
--- a/kernel/cobalt/posix/event.h
+++ b/kernel/cobalt/posix/event.h
@@ -51,7 +51,7 @@ COBALT_SYSCALL_DECL(event_wait,
 		     unsigned int bits,
 		     unsigned int __user *u_bits_r,
 		     int mode,
-		     const struct __user_old_timespec __user *u_ts));
+		     const struct __kernel_old_timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(event_wait64,
 		    (struct cobalt_event_shadow __user *u_evtsh,
diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
index 9e6f3edfa..e581ec6db 100644
--- a/kernel/cobalt/posix/io.c
+++ b/kernel/cobalt/posix/io.c
@@ -98,7 +98,7 @@ COBALT_SYSCALL(recvmsg, handover,
 static int get_timespec(struct timespec64 *ts,
 			const void __user *u_ts)
 {
-	return cobalt_get_u_timespec(ts, u_ts);
+	return cobalt_get_old_timespec(ts, u_ts);
 }
 
 static int get_mmsg(struct mmsghdr *mmsg, void __user *u_mmsg)
@@ -116,7 +116,7 @@ static int put_mmsg(void __user **u_mmsg_p, const struct mmsghdr *mmsg)
 
 COBALT_SYSCALL(recvmmsg, primary,
 	       (int fd, struct mmsghdr __user *u_msgvec, unsigned int vlen,
-		unsigned int flags, struct __user_old_timespec __user *u_timeout))
+		unsigned int flags, struct __kernel_old_timespec __user *u_timeout))
 {
 	return __rtdm_fd_recvmmsg(fd, u_msgvec, vlen, flags, u_timeout,
 				  get_mmsg, put_mmsg, get_timespec);
diff --git a/kernel/cobalt/posix/io.h b/kernel/cobalt/posix/io.h
index ca46aa309..106e2d523 100644
--- a/kernel/cobalt/posix/io.h
+++ b/kernel/cobalt/posix/io.h
@@ -51,7 +51,7 @@ COBALT_SYSCALL_DECL(recvmsg,
 
 COBALT_SYSCALL_DECL(recvmmsg,
 		    (int fd, struct mmsghdr __user *u_msgvec, unsigned int vlen,
-		     unsigned int flags, struct __user_old_timespec __user *u_timeout));
+		     unsigned int flags, struct __kernel_old_timespec __user *u_timeout));
 
 COBALT_SYSCALL_DECL(recvmmsg64,
 		    (int fd, struct mmsghdr __user *u_msgvec, unsigned int vlen,
diff --git a/kernel/cobalt/posix/monitor.c b/kernel/cobalt/posix/monitor.c
index c266b8b3b..fb7fb27e9 100644
--- a/kernel/cobalt/posix/monitor.c
+++ b/kernel/cobalt/posix/monitor.c
@@ -296,7 +296,7 @@ out:
 
 COBALT_SYSCALL(monitor_wait, nonrestartable,
 	       (struct cobalt_monitor_shadow __user *u_mon,
-	       int event, const struct __user_old_timespec __user *u_ts,
+	       int event, const struct __kernel_old_timespec __user *u_ts,
 	       int __user *u_ret))
 {
 	struct timespec64 ts, *tsp = NULL;
@@ -304,7 +304,7 @@ COBALT_SYSCALL(monitor_wait, nonrestartable,
 
 	if (u_ts) {
 		tsp = &ts;
-		ret = cobalt_get_u_timespec(&ts, u_ts);
+		ret = cobalt_get_old_timespec(&ts, u_ts);
 		if (ret)
 			return ret;
 	}
diff --git a/kernel/cobalt/posix/monitor.h b/kernel/cobalt/posix/monitor.h
index 3c76a036b..0cf53c768 100644
--- a/kernel/cobalt/posix/monitor.h
+++ b/kernel/cobalt/posix/monitor.h
@@ -58,7 +58,7 @@ COBALT_SYSCALL_DECL(monitor_exit,
 
 COBALT_SYSCALL_DECL(monitor_wait,
 		    (struct cobalt_monitor_shadow __user *u_monsh,
-		     int event, const struct __user_old_timespec __user *u_ts,
+		     int event, const struct __kernel_old_timespec __user *u_ts,
 		     int __user *u_ret));
 
 COBALT_SYSCALL_DECL(monitor_wait64,
diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c
index 4487e23de..878fb521b 100644
--- a/kernel/cobalt/posix/mqueue.c
+++ b/kernel/cobalt/posix/mqueue.c
@@ -921,7 +921,7 @@ COBALT_SYSCALL(mq_getattr, current,
 static inline int mq_fetch_timeout(struct timespec64 *ts,
 				   const void __user *u_ts)
 {
-	return u_ts == NULL ? -EFAULT : cobalt_get_u_timespec(ts, u_ts);
+	return u_ts == NULL ? -EFAULT : cobalt_get_old_timespec(ts, u_ts);
 }
 
 static inline int mq_fetch_timeout64(struct timespec64 *ts,
@@ -976,7 +976,7 @@ out:
 
 COBALT_SYSCALL(mq_timedsend, primary,
 	       (mqd_t uqd, const void __user *u_buf, size_t len,
-		unsigned int prio, const struct __user_old_timespec __user *u_ts))
+		unsigned int prio, const struct __kernel_old_timespec __user *u_ts))
 {
 	return __cobalt_mq_timedsend(uqd, u_buf, len, prio,
 				     u_ts, u_ts ? mq_fetch_timeout : NULL);
@@ -1054,7 +1054,7 @@ COBALT_SYSCALL(mq_timedreceive, primary,
 	       (mqd_t uqd, void __user *u_buf,
 		ssize_t __user *u_len,
 		unsigned int __user *u_prio,
-		const struct __user_old_timespec __user *u_ts))
+		const struct __kernel_old_timespec __user *u_ts))
 {
 	ssize_t len;
 	int ret;
diff --git a/kernel/cobalt/posix/mqueue.h b/kernel/cobalt/posix/mqueue.h
index 755623f47..7cf45c3dc 100644
--- a/kernel/cobalt/posix/mqueue.h
+++ b/kernel/cobalt/posix/mqueue.h
@@ -66,7 +66,7 @@ COBALT_SYSCALL_DECL(mq_getattr, (mqd_t uqd, struct mq_attr __user *u_attr));
 
 COBALT_SYSCALL_DECL(mq_timedsend,
 		    (mqd_t uqd, const void __user *u_buf, size_t len,
-		     unsigned int prio, const struct __user_old_timespec __user *u_ts));
+		     unsigned int prio, const struct __kernel_old_timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(mq_timedsend64,
 		    (mqd_t uqd, const void __user *u_buf, size_t len,
@@ -76,7 +76,7 @@ COBALT_SYSCALL_DECL(mq_timedsend64,
 COBALT_SYSCALL_DECL(mq_timedreceive,
 		    (mqd_t uqd, void __user *u_buf, ssize_t __user *u_len,
 		     unsigned int __user *u_prio,
-		     const struct __user_old_timespec __user *u_ts));
+		     const struct __kernel_old_timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(mq_timedreceive64,
 		    (mqd_t uqd, void __user *u_buf, ssize_t __user *u_len,
diff --git a/kernel/cobalt/posix/mutex.c b/kernel/cobalt/posix/mutex.c
index 2bdb66d17..65882081e 100644
--- a/kernel/cobalt/posix/mutex.c
+++ b/kernel/cobalt/posix/mutex.c
@@ -355,7 +355,7 @@ COBALT_SYSCALL(mutex_lock, primary,
 static inline int mutex_fetch_timeout(struct timespec64 *ts,
 				      const void __user *u_ts)
 {
-	return u_ts == NULL ? -EFAULT : cobalt_get_u_timespec(ts, u_ts);
+	return u_ts == NULL ? -EFAULT : cobalt_get_old_timespec(ts, u_ts);
 }
 
 static inline int mutex_fetch_timeout64(struct timespec64 *ts,
@@ -366,7 +366,7 @@ static inline int mutex_fetch_timeout64(struct timespec64 *ts,
 
 COBALT_SYSCALL(mutex_timedlock, primary,
 	       (struct cobalt_mutex_shadow __user *u_mx,
-		const struct __user_old_timespec __user *u_ts))
+		const struct __kernel_old_timespec __user *u_ts))
 {
 	return __cobalt_mutex_timedlock_break(u_mx, u_ts, mutex_fetch_timeout);
 }
diff --git a/kernel/cobalt/posix/mutex.h b/kernel/cobalt/posix/mutex.h
index 800515a69..4e977fd07 100644
--- a/kernel/cobalt/posix/mutex.h
+++ b/kernel/cobalt/posix/mutex.h
@@ -62,7 +62,7 @@ COBALT_SYSCALL_DECL(mutex_lock,
 
 COBALT_SYSCALL_DECL(mutex_timedlock,
 		    (struct cobalt_mutex_shadow __user *u_mx,
-		     const struct __user_old_timespec __user *u_ts));
+		     const struct __kernel_old_timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(mutex_timedlock64,
 		    (struct cobalt_mutex_shadow __user *u_mx,
diff --git a/kernel/cobalt/posix/sem.c b/kernel/cobalt/posix/sem.c
index aca03a555..e53bcad9b 100644
--- a/kernel/cobalt/posix/sem.c
+++ b/kernel/cobalt/posix/sem.c
@@ -458,13 +458,13 @@ COBALT_SYSCALL(sem_wait, primary,
 
 COBALT_SYSCALL(sem_timedwait, primary,
 	       (struct cobalt_sem_shadow __user *u_sem,
-		const struct __user_old_timespec __user *u_ts))
+		const struct __kernel_old_timespec __user *u_ts))
 {
 	struct timespec64 ts64;
 	int ret = 1;
 
 	if (u_ts)
-		ret = cobalt_get_u_timespec(&ts64, u_ts);
+		ret = cobalt_get_old_timespec(&ts64, u_ts);
 
 	return __cobalt_sem_timedwait(u_sem, ret ? NULL : &ts64);
 }
diff --git a/kernel/cobalt/posix/sem.h b/kernel/cobalt/posix/sem.h
index e1e4d68f0..ae0d929e0 100644
--- a/kernel/cobalt/posix/sem.h
+++ b/kernel/cobalt/posix/sem.h
@@ -89,7 +89,7 @@ COBALT_SYSCALL_DECL(sem_wait,
 
 COBALT_SYSCALL_DECL(sem_timedwait,
 		    (struct cobalt_sem_shadow __user *u_sem,
-		     const struct __user_old_timespec __user *u_ts));
+		     const struct __kernel_old_timespec __user *u_ts));
 
 COBALT_SYSCALL_DECL(sem_timedwait64,
 		    (struct cobalt_sem_shadow __user *u_sem,
diff --git a/kernel/cobalt/posix/signal.c b/kernel/cobalt/posix/signal.c
index ced534079..1842aa5e8 100644
--- a/kernel/cobalt/posix/signal.c
+++ b/kernel/cobalt/posix/signal.c
@@ -426,7 +426,7 @@ int __cobalt_sigtimedwait(sigset_t *set,
 COBALT_SYSCALL(sigtimedwait, nonrestartable,
 	       (const sigset_t __user *u_set,
 		struct siginfo __user *u_si,
-		const struct __user_old_timespec __user *u_timeout))
+		const struct __kernel_old_timespec __user *u_timeout))
 {
 	struct timespec64 timeout;
 	sigset_t set;
diff --git a/kernel/cobalt/posix/signal.h b/kernel/cobalt/posix/signal.h
index 0b5d11e81..227086756 100644
--- a/kernel/cobalt/posix/signal.h
+++ b/kernel/cobalt/posix/signal.h
@@ -94,7 +94,7 @@ COBALT_SYSCALL_DECL(sigwait,
 COBALT_SYSCALL_DECL(sigtimedwait,
 		    (const sigset_t __user *u_set,
 		     struct siginfo __user *u_si,
-		     const struct __user_old_timespec __user *u_timeout));
+		     const struct __kernel_old_timespec __user *u_timeout));
 
 COBALT_SYSCALL_DECL(sigtimedwait64,
 		    (const sigset_t __user *u_set,
diff --git a/kernel/cobalt/posix/timer.c b/kernel/cobalt/posix/timer.c
index 0f111a42c..3107698ca 100644
--- a/kernel/cobalt/posix/timer.c
+++ b/kernel/cobalt/posix/timer.c
@@ -469,10 +469,11 @@ COBALT_SYSCALL(timer_create, current,
 	return __cobalt_timer_create(clock, evp, u_tm);
 }
 
+/* Only used by 32 bit applications without time64_t support */
 COBALT_SYSCALL(timer_settime, primary,
 	       (timer_t tm, int flags,
-		const struct __user_old_itimerspec __user *u_newval,
-		struct __user_old_itimerspec __user *u_oldval))
+		const struct old_itimerspec32 __user *u_newval,
+		struct old_itimerspec32 __user *u_oldval))
 {
 	struct itimerspec64 newv, oldv, *oldvp = &oldv;
 	int ret;
@@ -480,14 +481,14 @@ COBALT_SYSCALL(timer_settime, primary,
 	if (u_oldval == NULL)
 		oldvp = NULL;
 
-	if (cobalt_get_u_itimerspec(&newv, u_newval))
+	if (cobalt_get_itimerspec32(&newv, u_newval))
 		return -EFAULT;
 
 	ret = __cobalt_timer_settime(tm, flags, &newv, oldvp);
 	if (ret)
 		return ret;
 
-	if (oldvp && cobalt_put_u_itimerspec(u_oldval, oldvp)) {
+	if (oldvp && cobalt_put_itimerspec32(u_oldval, oldvp)) {
 		__cobalt_timer_settime(tm, flags, oldvp, NULL);
 		return -EFAULT;
 	}
@@ -521,8 +522,9 @@ COBALT_SYSCALL(timer_settime64, primary,
 	return 0;
 }
 
+/* Only used by 32 bit applications without time64_t support */
 COBALT_SYSCALL(timer_gettime, current,
-	       (timer_t tm, struct __user_old_itimerspec __user *u_val))
+	       (timer_t tm, struct old_itimerspec32 __user *u_val))
 {
 	struct itimerspec64 val;
 	int ret;
@@ -531,7 +533,7 @@ COBALT_SYSCALL(timer_gettime, current,
 	if (ret)
 		return ret;
 
-	return cobalt_put_u_itimerspec(u_val, &val);
+	return cobalt_put_itimerspec32(u_val, &val);
 }
 
 COBALT_SYSCALL(timer_gettime64, current,
diff --git a/kernel/cobalt/posix/timer.h b/kernel/cobalt/posix/timer.h
index 864c780e8..96df80334 100644
--- a/kernel/cobalt/posix/timer.h
+++ b/kernel/cobalt/posix/timer.h
@@ -75,8 +75,8 @@ COBALT_SYSCALL_DECL(timer_delete, (timer_t tm));
 
 COBALT_SYSCALL_DECL(timer_settime,
 		    (timer_t tm, int flags,
-		     const struct __user_old_itimerspec __user *u_newval,
-		     struct __user_old_itimerspec __user *u_oldval));
+		     const struct old_itimerspec32 __user *u_newval,
+		     struct old_itimerspec32 __user *u_oldval));
 
 COBALT_SYSCALL_DECL(timer_settime64,
 		    (timer_t tm, int flags,
@@ -84,7 +84,7 @@ COBALT_SYSCALL_DECL(timer_settime64,
 		     struct __kernel_itimerspec __user *u_oldval));
 
 COBALT_SYSCALL_DECL(timer_gettime,
-		    (timer_t tm, struct __user_old_itimerspec __user *u_val));
+		    (timer_t tm, struct old_itimerspec32 __user *u_val));
 
 COBALT_SYSCALL_DECL(timer_gettime64,
 		    (timer_t tm, struct __kernel_itimerspec __user *u_val));
diff --git a/kernel/cobalt/posix/timerfd.c b/kernel/cobalt/posix/timerfd.c
index ae7578d29..4839a0861 100644
--- a/kernel/cobalt/posix/timerfd.c
+++ b/kernel/cobalt/posix/timerfd.c
@@ -279,15 +279,16 @@ out:
 	return ret;
 }
 
+/* Only used by 32 bit applications without time64_t support */
 COBALT_SYSCALL(timerfd_settime, primary,
 	       (int fd, int flags,
-		const struct __user_old_itimerspec __user *new_value,
-		struct __user_old_itimerspec __user *old_value))
+		const struct old_itimerspec32 __user *new_value,
+		struct old_itimerspec32 __user *old_value))
 {
 	struct itimerspec64 ovalue, value;
 	int ret;
 
-	ret = cobalt_get_u_itimerspec(&value, new_value);
+	ret = cobalt_get_itimerspec32(&value, new_value);
 	if (ret)
 		return ret;
 
@@ -296,7 +297,7 @@ COBALT_SYSCALL(timerfd_settime, primary,
 		return ret;
 
 	if (old_value) {
-		ret = cobalt_put_u_itimerspec(old_value, &ovalue);
+		ret = cobalt_put_itimerspec32(old_value, &ovalue);
 		value.it_value.tv_sec = 0;
 		value.it_value.tv_nsec = 0;
 		__cobalt_timerfd_settime(fd, flags, &value, NULL);
@@ -349,15 +350,16 @@ int __cobalt_timerfd_gettime(int fd, struct itimerspec64 *value)
 	return 0;
 }
 
+/* Only used by 32 bit applications without time64_t support */
 COBALT_SYSCALL(timerfd_gettime, current,
-	       (int fd, struct __user_old_itimerspec __user *curr_value))
+	       (int fd, struct old_itimerspec32 __user *curr_value))
 {
 	struct itimerspec64 value;
 	int ret;
 
 	ret = __cobalt_timerfd_gettime(fd, &value);
 
-	return ret ?: cobalt_put_u_itimerspec(curr_value, &value);
+	return ret ?: cobalt_put_itimerspec32(curr_value, &value);
 }
 
 COBALT_SYSCALL(timerfd_gettime64, current,
diff --git a/kernel/cobalt/posix/timerfd.h b/kernel/cobalt/posix/timerfd.h
index b82dac748..004985f46 100644
--- a/kernel/cobalt/posix/timerfd.h
+++ b/kernel/cobalt/posix/timerfd.h
@@ -33,8 +33,8 @@ COBALT_SYSCALL_DECL(timerfd_create,
 
 COBALT_SYSCALL_DECL(timerfd_settime,
 		    (int fd, int flags,
-		     const struct __user_old_itimerspec __user *new_value,
-		     struct __user_old_itimerspec __user *old_value));
+		     const struct old_itimerspec32 __user *new_value,
+		     struct old_itimerspec32 __user *old_value));
 
 COBALT_SYSCALL_DECL(timerfd_settime64,
 		    (int fd, int flags,
@@ -42,7 +42,7 @@ COBALT_SYSCALL_DECL(timerfd_settime64,
 		     struct __kernel_itimerspec __user *old_value));
 
 COBALT_SYSCALL_DECL(timerfd_gettime,
-		    (int fd, struct __user_old_itimerspec __user *curr_value));
+		    (int fd, struct old_itimerspec32 __user *curr_value));
 
 COBALT_SYSCALL_DECL(timerfd_gettime64,
 		    (int fd, struct __kernel_itimerspec __user *curr_value));
diff --git a/lib/cobalt/clock.c b/lib/cobalt/clock.c
index 490426499..dbfcd4d76 100644
--- a/lib/cobalt/clock.c
+++ b/lib/cobalt/clock.c
@@ -309,7 +309,7 @@ COBALT_IMPL(int, clock_adjtime, (clockid_t clock_id, struct timex *tx))
 {
 	int ret;
 
-#ifdef __USE_TIME_BITS64
+#ifdef XN_USE_TIME64_SYSCALL
 	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_adjtime64, clock_id, tx);
 #else
 	ret = -XENOMAI_SYSCALL2(sc_cobalt_clock_adjtime, clock_id, tx);
diff --git a/lib/cobalt/internal.h b/lib/cobalt/internal.h
index acb3989f1..00f51fa23 100644
--- a/lib/cobalt/internal.h
+++ b/lib/cobalt/internal.h
@@ -25,6 +25,11 @@
 #include <cobalt/sys/cobalt.h>
 #include "current.h"
 
+#if defined(__USE_TIME_BITS64) || __WORDSIZE == 64 ||                          \
+	(defined(__SYSCALL_WORDSIZE) && __SYSCALL_WORDSIZE == 64)
+#define XN_USE_TIME64_SYSCALL
+#endif
+
 extern void *cobalt_umm_private;
 
 extern void *cobalt_umm_shared;
diff --git a/lib/cobalt/timer.c b/lib/cobalt/timer.c
index d8955832e..d86d01417 100644
--- a/lib/cobalt/timer.c
+++ b/lib/cobalt/timer.c
@@ -166,7 +166,7 @@ COBALT_IMPL(int, timer_settime, (timer_t timerid,
 {
 	int ret;
 
-#ifdef __USE_TIME_BITS64
+#ifdef XN_USE_TIME64_SYSCALL
 	long sc_nr = sc_cobalt_timer_settime64;
 #else
 	long sc_nr = sc_cobalt_timer_settime;
@@ -214,7 +214,7 @@ COBALT_IMPL(int, timer_gettime, (timer_t timerid, struct itimerspec *value))
 {
 	int ret;
 
-#ifdef __USE_TIME_BITS64
+#ifdef XN_USE_TIME64_SYSCALL
 	long sc_nr = sc_cobalt_timer_gettime64;
 #else
 	long sc_nr = sc_cobalt_timer_gettime;
diff --git a/lib/cobalt/timerfd.c b/lib/cobalt/timerfd.c
index c0e64929a..5e7db928f 100644
--- a/lib/cobalt/timerfd.c
+++ b/lib/cobalt/timerfd.c
@@ -41,7 +41,7 @@ COBALT_IMPL(int, timerfd_settime,
 {
 	int ret;
 
-#ifdef __USE_TIME_BITS64
+#ifdef XN_USE_TIME64_SYSCALL
 	long sc_nr = sc_cobalt_timerfd_settime64;
 #else
 	long sc_nr = sc_cobalt_timerfd_settime;
@@ -59,7 +59,7 @@ COBALT_IMPL(int, timerfd_gettime, (int fd, struct itimerspec *curr_value))
 {
 	int ret;
 
-#ifdef __USE_TIME_BITS64
+#ifdef XN_USE_TIME64_SYSCALL
 	long sc_nr = sc_cobalt_timerfd_gettime64;
 #else
 	long sc_nr = sc_cobalt_timerfd_gettime;

-- 
2.39.2


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

* [PATCH v2 4/4] y2038: cobalt/{thread,sched}: Remove obsolete compat handling
  2023-07-17  9:10 [PATCH v2 0/4] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
                   ` (2 preceding siblings ...)
  2023-07-17  9:10 ` [PATCH v2 3/4] y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex} Florian Bezdeka
@ 2023-07-17  9:10 ` Florian Bezdeka
  3 siblings, 0 replies; 13+ messages in thread
From: Florian Bezdeka @ 2023-07-17  9:10 UTC (permalink / raw)
  To: xenomai, jan.kiszka; +Cc: Florian Bezdeka

Remove the compat specific handling of the following cobalt services:
  - thread_create
  - thread_setschedparam_ex
  - thread_getschedparam_ex
  - sched_weightprio
  - sched_setconfig_np
  - sched_getconfig_np
  - sched_setscheduler_ex
  - sched_getscheduler_ex

All necessary helper functions and compat specific re-decleration of
affected data structures have been removed.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/cobalt/kernel/compat.h                     |  49 -----
 .../arch/x86/include/asm/xenomai/syscall32-table.h |   8 -
 kernel/cobalt/posix/compat.c                       |  72 -------
 kernel/cobalt/posix/syscall32.c                    | 233 ---------------------
 kernel/cobalt/posix/syscall32.h                    |  45 ----
 5 files changed, 407 deletions(-)

diff --git a/include/cobalt/kernel/compat.h b/include/cobalt/kernel/compat.h
index 275735df5..d064cada4 100644
--- a/include/cobalt/kernel/compat.h
+++ b/include/cobalt/kernel/compat.h
@@ -27,27 +27,6 @@
 
 struct mq_attr;
 
-struct __compat_sched_ss_param {
-	int __sched_low_priority;
-	struct old_timespec32 __sched_repl_period;
-	struct old_timespec32 __sched_init_budget;
-	int __sched_max_repl;
-};
-
-struct __compat_sched_rr_param {
-	struct old_timespec32 __sched_rr_quantum;
-};
-
-struct compat_sched_param_ex {
-	int sched_priority;
-	union {
-		struct __compat_sched_ss_param ss;
-		struct __compat_sched_rr_param rr;
-		struct __sched_tp_param tp;
-		struct __sched_quota_param quota;
-	} sched_u;
-};
-
 struct compat_mq_attr {
 	compat_long_t mq_flags;
 	compat_long_t mq_maxmsg;
@@ -55,26 +34,6 @@ struct compat_mq_attr {
 	compat_long_t mq_curmsgs;
 };
 
-struct compat_sched_tp_window {
-	struct old_timespec32 offset;
-	struct old_timespec32 duration;
-	int ptid;
-};
-
-struct __compat_sched_config_tp {
-	int op;
-	int nr_windows;
-	struct compat_sched_tp_window windows[0];
-};
-
-union compat_sched_config {
-	struct __compat_sched_config_tp tp;
-	struct __sched_config_quota quota;
-};
-
-#define compat_sched_tp_confsz(nr_win) \
-  (sizeof(struct __compat_sched_config_tp) + nr_win * sizeof(struct compat_sched_tp_window))
-
 typedef struct {
 	compat_ulong_t fds_bits[__FD_SETSIZE / (8 * sizeof(compat_long_t))];
 } compat_fd_set;
@@ -116,14 +75,6 @@ int sys32_get_fdset(fd_set *fds, const compat_fd_set __user *cfds,
 int sys32_put_fdset(compat_fd_set __user *cfds, const fd_set *fds,
 		    size_t fdsize);
 
-int sys32_get_param_ex(int policy,
-		       struct sched_param_ex *p,
-		       const struct compat_sched_param_ex __user *u_cp);
-
-int sys32_put_param_ex(int policy,
-		       struct compat_sched_param_ex __user *u_cp,
-		       const struct sched_param_ex *p);
-
 int sys32_get_mqattr(struct mq_attr *ap,
 		     const struct compat_mq_attr __user *u_cap);
 
diff --git a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
index 3986b227b..3d64c46a7 100644
--- a/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
+++ b/kernel/cobalt/arch/x86/include/asm/xenomai/syscall32-table.h
@@ -24,9 +24,6 @@
  * table. Only preprocessor stuff and syscall entries here.
  */
 
-__COBALT_CALL32emu_THUNK(thread_create)
-__COBALT_CALL32emu_THUNK(thread_setschedparam_ex)
-__COBALT_CALL32emu_THUNK(thread_getschedparam_ex)
 __COBALT_CALL32emu_THUNK(thread_setschedprio)
 __COBALT_CALL32emu_THUNK(sem_open)
 __COBALT_CALL32emu_THUNK(sem_timedwait)
@@ -41,11 +38,6 @@ __COBALT_CALL32emu_THUNK(mq_getattr)
 __COBALT_CALL32emu_THUNK(mq_timedsend)
 __COBALT_CALL32emu_THUNK(mq_timedreceive)
 __COBALT_CALL32emu_THUNK(mq_notify)
-__COBALT_CALL32emu_THUNK(sched_weightprio)
-__COBALT_CALL32emu_THUNK(sched_setconfig_np)
-__COBALT_CALL32emu_THUNK(sched_getconfig_np)
-__COBALT_CALL32emu_THUNK(sched_setscheduler_ex)
-__COBALT_CALL32emu_THUNK(sched_getscheduler_ex)
 __COBALT_CALL32emu_THUNK(timer_create)
 __COBALT_CALL32emu_THUNK(timer_settime)
 __COBALT_CALL32emu_THUNK(timer_gettime)
diff --git a/kernel/cobalt/posix/compat.c b/kernel/cobalt/posix/compat.c
index c7fc4fc33..080eda449 100644
--- a/kernel/cobalt/posix/compat.c
+++ b/kernel/cobalt/posix/compat.c
@@ -206,78 +206,6 @@ int sys32_put_fdset(compat_fd_set __user *cfds, const fd_set *fds,
 	return 0;
 }
 
-int sys32_get_param_ex(int policy,
-		       struct sched_param_ex *p,
-		       const struct compat_sched_param_ex __user *u_cp)
-{
-	struct compat_sched_param_ex cpex;
-
-	if (u_cp == NULL || cobalt_copy_from_user(&cpex, u_cp, sizeof(cpex)))
-		return -EFAULT;
-
-	p->sched_priority = cpex.sched_priority;
-
-	switch (policy) {
-	case SCHED_SPORADIC:
-		p->sched_ss_low_priority = cpex.sched_ss_low_priority;
-		p->sched_ss_max_repl = cpex.sched_ss_max_repl;
-		p->sched_ss_repl_period.tv_sec = cpex.sched_ss_repl_period.tv_sec;
-		p->sched_ss_repl_period.tv_nsec = cpex.sched_ss_repl_period.tv_nsec;
-		p->sched_ss_init_budget.tv_sec = cpex.sched_ss_init_budget.tv_sec;
-		p->sched_ss_init_budget.tv_nsec = cpex.sched_ss_init_budget.tv_nsec;
-		break;
-	case SCHED_RR:
-		p->sched_rr_quantum.tv_sec = cpex.sched_rr_quantum.tv_sec;
-		p->sched_rr_quantum.tv_nsec = cpex.sched_rr_quantum.tv_nsec;
-		break;
-	case SCHED_TP:
-		p->sched_tp_partition = cpex.sched_tp_partition;
-		break;
-	case SCHED_QUOTA:
-		p->sched_quota_group = cpex.sched_quota_group;
-		break;
-	}
-
-	return 0;
-}
-EXPORT_SYMBOL_GPL(sys32_get_param_ex);
-
-int sys32_put_param_ex(int policy,
-		       struct compat_sched_param_ex __user *u_cp,
-		       const struct sched_param_ex *p)
-{
-	struct compat_sched_param_ex cpex;
-
-	if (u_cp == NULL)
-		return -EFAULT;
-
-	cpex.sched_priority = p->sched_priority;
-
-	switch (policy) {
-	case SCHED_SPORADIC:
-		cpex.sched_ss_low_priority = p->sched_ss_low_priority;
-		cpex.sched_ss_max_repl = p->sched_ss_max_repl;
-		cpex.sched_ss_repl_period.tv_sec = p->sched_ss_repl_period.tv_sec;
-		cpex.sched_ss_repl_period.tv_nsec = p->sched_ss_repl_period.tv_nsec;
-		cpex.sched_ss_init_budget.tv_sec = p->sched_ss_init_budget.tv_sec;
-		cpex.sched_ss_init_budget.tv_nsec = p->sched_ss_init_budget.tv_nsec;
-		break;
-	case SCHED_RR:
-		cpex.sched_rr_quantum.tv_sec = p->sched_rr_quantum.tv_sec;
-		cpex.sched_rr_quantum.tv_nsec = p->sched_rr_quantum.tv_nsec;
-		break;
-	case SCHED_TP:
-		cpex.sched_tp_partition = p->sched_tp_partition;
-		break;
-	case SCHED_QUOTA:
-		cpex.sched_quota_group = p->sched_quota_group;
-		break;
-	}
-
-	return cobalt_copy_to_user(u_cp, &cpex, sizeof(cpex));
-}
-EXPORT_SYMBOL_GPL(sys32_put_param_ex);
-
 int sys32_get_mqattr(struct mq_attr *ap,
 		     const struct compat_mq_attr __user *u_cap)
 {
diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
index c82cc60a2..793bde138 100644
--- a/kernel/cobalt/posix/syscall32.c
+++ b/kernel/cobalt/posix/syscall32.c
@@ -37,58 +37,6 @@
 #include "io.h"
 #include "../debug.h"
 
-COBALT_SYSCALL32emu(thread_create, init,
-		    (compat_ulong_t pth,
-		     int policy,
-		     const struct compat_sched_param_ex __user *u_param_ex,
-		     int xid,
-		     __u32 __user *u_winoff))
-{
-	struct sched_param_ex param_ex;
-	int ret;
-
-	ret = sys32_get_param_ex(policy, &param_ex, u_param_ex);
-	if (ret)
-		return ret;
-
-	return __cobalt_thread_create(pth, policy, &param_ex, xid, u_winoff);
-}
-
-COBALT_SYSCALL32emu(thread_setschedparam_ex, conforming,
-		    (compat_ulong_t pth,
-		     int policy,
-		     const struct compat_sched_param_ex __user *u_param_ex,
-		     __u32 __user *u_winoff,
-		     int __user *u_promoted))
-{
-	struct sched_param_ex param_ex;
-	int ret;
-
-	ret = sys32_get_param_ex(policy, &param_ex, u_param_ex);
-	if (ret)
-		return ret;
-
-	return cobalt_thread_setschedparam_ex(pth, policy, &param_ex,
-					      u_winoff, u_promoted);
-}
-
-COBALT_SYSCALL32emu(thread_getschedparam_ex, current,
-		    (compat_ulong_t pth,
-		     int __user *u_policy,
-		     struct compat_sched_param_ex __user *u_param))
-{
-	struct sched_param_ex param_ex;
-	int ret, policy;
-
-	ret = cobalt_thread_getschedparam_ex(pth, &policy, &param_ex);
-	if (ret)
-		return ret;
-
-	ret = cobalt_copy_to_user(u_policy, &policy, sizeof(policy));
-
-	return ret ?: sys32_put_param_ex(policy, u_param, &param_ex);
-}
-
 COBALT_SYSCALL32emu(thread_setschedprio, conforming,
 		    (compat_ulong_t pth,
 		     int prio,
@@ -333,187 +281,6 @@ COBALT_SYSCALL32emu(mq_notify, primary,
 	return __cobalt_mq_notify(fd, u_cev ? &sev : NULL);
 }
 
-COBALT_SYSCALL32emu(sched_weightprio, current,
-		    (int policy,
-		     const struct compat_sched_param_ex __user *u_param))
-{
-	struct sched_param_ex param_ex;
-	int ret;
-
-	ret = sys32_get_param_ex(policy, &param_ex, u_param);
-	if (ret)
-		return ret;
-
-	return __cobalt_sched_weightprio(policy, &param_ex);
-}
-
-static union sched_config *
-sys32_fetch_config(int policy, const void __user *u_config, size_t *len)
-{
-	union compat_sched_config *cbuf;
-	union sched_config *buf;
-	int ret, n;
-
-	if (u_config == NULL)
-		return ERR_PTR(-EFAULT);
-
-	if (policy == SCHED_QUOTA && *len < sizeof(cbuf->quota))
-		return ERR_PTR(-EINVAL);
-
-	cbuf = xnmalloc(*len);
-	if (cbuf == NULL)
-		return ERR_PTR(-ENOMEM);
-
-	ret = cobalt_copy_from_user(cbuf, u_config, *len);
-	if (ret) {
-		buf = ERR_PTR(ret);
-		goto out;
-	}
-
-	switch (policy) {
-	case SCHED_TP:
-		*len = sched_tp_confsz(cbuf->tp.nr_windows);
-		break;
-	case SCHED_QUOTA:
-		break;
-	default:
-		buf = ERR_PTR(-EINVAL);
-		goto out;
-	}
-
-	buf = xnmalloc(*len);
-	if (buf == NULL) {
-		buf = ERR_PTR(-ENOMEM);
-		goto out;
-	}
-
-	if (policy == SCHED_QUOTA)
-		memcpy(&buf->quota, &cbuf->quota, sizeof(cbuf->quota));
-	else {
-		buf->tp.op = cbuf->tp.op;
-		buf->tp.nr_windows = cbuf->tp.nr_windows;
-		for (n = 0; n < buf->tp.nr_windows; n++) {
-			buf->tp.windows[n].ptid = cbuf->tp.windows[n].ptid;
-			buf->tp.windows[n].offset.tv_sec = cbuf->tp.windows[n].offset.tv_sec;
-			buf->tp.windows[n].offset.tv_nsec = cbuf->tp.windows[n].offset.tv_nsec;
-			buf->tp.windows[n].duration.tv_sec = cbuf->tp.windows[n].duration.tv_sec;
-			buf->tp.windows[n].duration.tv_nsec = cbuf->tp.windows[n].duration.tv_nsec;
-		}
-	}
-out:
-	xnfree(cbuf);
-
-	return buf;
-}
-
-static int sys32_ack_config(int policy, const union sched_config *config,
-			    void __user *u_config)
-{
-	union compat_sched_config __user *u_p = u_config;
-
-	if (policy != SCHED_QUOTA)
-		return 0;
-
-	return u_config == NULL ? -EFAULT :
-		cobalt_copy_to_user(&u_p->quota.info, &config->quota.info,
-				       sizeof(u_p->quota.info));
-}
-
-static ssize_t sys32_put_config(int policy,
-				void __user *u_config, size_t u_len,
-				const union sched_config *config, size_t len)
-{
-	union compat_sched_config __user *u_p = u_config;
-	int n, ret;
-
-	if (u_config == NULL)
-		return -EFAULT;
-
-	if (policy == SCHED_QUOTA) {
-		if (u_len < sizeof(u_p->quota))
-			return -EINVAL;
-		return cobalt_copy_to_user(&u_p->quota.info, &config->quota.info,
-					      sizeof(u_p->quota.info)) ?:
-			sizeof(u_p->quota.info);
-	}
-
-	/* SCHED_TP */
-
-	if (u_len < compat_sched_tp_confsz(config->tp.nr_windows))
-		return -ENOSPC;
-
-	__xn_put_user(config->tp.op, &u_p->tp.op);
-	__xn_put_user(config->tp.nr_windows, &u_p->tp.nr_windows);
-
-	for (n = 0, ret = 0; n < config->tp.nr_windows; n++) {
-		ret |= __xn_put_user(config->tp.windows[n].ptid,
-				     &u_p->tp.windows[n].ptid);
-		ret |= __xn_put_user(config->tp.windows[n].offset.tv_sec,
-				     &u_p->tp.windows[n].offset.tv_sec);
-		ret |= __xn_put_user(config->tp.windows[n].offset.tv_nsec,
-				     &u_p->tp.windows[n].offset.tv_nsec);
-		ret |= __xn_put_user(config->tp.windows[n].duration.tv_sec,
-				     &u_p->tp.windows[n].duration.tv_sec);
-		ret |= __xn_put_user(config->tp.windows[n].duration.tv_nsec,
-				     &u_p->tp.windows[n].duration.tv_nsec);
-	}
-
-	return ret ?: u_len;
-}
-
-COBALT_SYSCALL32emu(sched_setconfig_np, conforming,
-		    (int cpu, int policy,
-		     union compat_sched_config __user *u_config,
-		     size_t len))
-{
-	return __cobalt_sched_setconfig_np(cpu, policy, u_config, len,
-					   sys32_fetch_config, sys32_ack_config);
-}
-
-COBALT_SYSCALL32emu(sched_getconfig_np, conformin,
-		    (int cpu, int policy,
-		     union compat_sched_config __user *u_config,
-		     size_t len))
-{
-	return __cobalt_sched_getconfig_np(cpu, policy, u_config, len,
-					   sys32_fetch_config, sys32_put_config);
-}
-
-COBALT_SYSCALL32emu(sched_setscheduler_ex, conforming,
-		    (compat_pid_t pid,
-		     int policy,
-		     const struct compat_sched_param_ex __user *u_param_ex,
-		     __u32 __user *u_winoff,
-		     int __user *u_promoted))
-{
-	struct sched_param_ex param_ex;
-	int ret;
-
-	ret = sys32_get_param_ex(policy, &param_ex, u_param_ex);
-	if (ret)
-		return ret;
-
-	return cobalt_sched_setscheduler_ex(pid, policy, &param_ex,
-					    u_winoff, u_promoted);
-}
-
-COBALT_SYSCALL32emu(sched_getscheduler_ex, current,
-		    (compat_pid_t pid,
-		     int __user *u_policy,
-		     struct compat_sched_param_ex __user *u_param))
-{
-	struct sched_param_ex param_ex;
-	int ret, policy;
-
-	ret = cobalt_sched_getscheduler_ex(pid, &policy, &param_ex);
-	if (ret)
-		return ret;
-
-	ret = cobalt_copy_to_user(u_policy, &policy, sizeof(policy));
-
-	return ret ?: sys32_put_param_ex(policy, u_param, &param_ex);
-}
-
 COBALT_SYSCALL32emu(timer_create, current,
 		    (clockid_t clock,
 		     const struct compat_sigevent __user *u_sev,
diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
index 3df6224b7..abe7e4404 100644
--- a/kernel/cobalt/posix/syscall32.h
+++ b/kernel/cobalt/posix/syscall32.h
@@ -26,25 +26,6 @@ struct cobalt_cond_shadow;
 struct cobalt_sem_shadow;
 struct cobalt_monitor_shadow;
 
-COBALT_SYSCALL32emu_DECL(thread_create,
-			 (compat_ulong_t pth,
-			  int policy,
-			  const struct compat_sched_param_ex __user *u_param_ex,
-			  int xid,
-			  __u32 __user *u_winoff));
-
-COBALT_SYSCALL32emu_DECL(thread_setschedparam_ex,
-			 (compat_ulong_t pth,
-			  int policy,
-			  const struct compat_sched_param_ex __user *u_param,
-			  __u32 __user *u_winoff,
-			  int __user *u_promoted));
-
-COBALT_SYSCALL32emu_DECL(thread_getschedparam_ex,
-			 (compat_ulong_t pth,
-			  int __user *u_policy,
-			  struct compat_sched_param_ex __user *u_param));
-
 COBALT_SYSCALL32emu_DECL(thread_setschedprio,
 			 (compat_ulong_t pth,
 			  int prio,
@@ -110,32 +91,6 @@ COBALT_SYSCALL32emu_DECL(mq_timedreceive64,
 COBALT_SYSCALL32emu_DECL(mq_notify,
 			 (mqd_t fd, const struct compat_sigevent *__user u_cev));
 
-COBALT_SYSCALL32emu_DECL(sched_weightprio,
-			 (int policy,
-			  const struct compat_sched_param_ex __user *u_param));
-
-COBALT_SYSCALL32emu_DECL(sched_setconfig_np,
-			 (int cpu, int policy,
-			  union compat_sched_config __user *u_config,
-			  size_t len));
-
-COBALT_SYSCALL32emu_DECL(sched_getconfig_np,
-			 (int cpu, int policy,
-			  union compat_sched_config __user *u_config,
-			  size_t len));
-
-COBALT_SYSCALL32emu_DECL(sched_setscheduler_ex,
-			 (compat_pid_t pid,
-			  int policy,
-			  const struct compat_sched_param_ex __user *u_param,
-			  __u32 __user *u_winoff,
-			  int __user *u_promoted));
-
-COBALT_SYSCALL32emu_DECL(sched_getscheduler_ex,
-			 (compat_pid_t pid,
-			  int __user *u_policy,
-			  struct compat_sched_param_ex __user *u_param));
-
 COBALT_SYSCALL32emu_DECL(timer_create,
 			 (clockid_t clock,
 			  const struct compat_sigevent __user *u_sev,

-- 
2.39.2


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

* Re: [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
  2023-07-17  9:10 ` [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t Florian Bezdeka
@ 2023-07-20 16:36   ` Jan Kiszka
  2023-07-21 12:43     ` Florian Bezdeka
  2023-07-20 16:47   ` Jan Kiszka
  1 sibling, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2023-07-20 16:36 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 17.07.23 11:10, Florian Bezdeka wrote:
> Instead of implementing time64_t based cobalt services for the
> following services we simply break the ABI and make it time64_t aware.
> 
> Affected cobalt services:
>   - cobalt_thread_create
>   - cobalt_thread_setschedparam_ex
>   - cobalt_thread_getschedparam_ex
>   - cobalt_sched_setconfig_np
>   - cobalt_sched_getconfig_np
>   - cobalt_sched_setscheduler_ex
>   - cobalt_sched_getscheduler_ex
> 
> XENOMAI_ABI_REV is incremented on all supported plattforms to express
> the ABI breakage.
> 
> The memory alignment of some data structures is changed by adding
> some anonymous paddings. This allows us to remove some compat specific
> services afterwards. The memory layout is identical on all platforms
> now.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>  include/cobalt/uapi/kernel/types.h                       |  5 +++++
>  include/cobalt/uapi/sched.h                              | 14 +++++++++-----
>  .../cobalt/arch/arm/include/asm/xenomai/uapi/features.h  |  2 +-
>  .../arch/arm64/include/asm/xenomai/uapi/features.h       |  2 +-
>  .../cobalt/arch/x86/include/asm/xenomai/uapi/features.h  |  2 +-
>  kernel/cobalt/posix/clock.h                              | 16 ++++++++++------
>  kernel/cobalt/posix/sched.c                              | 16 ++++++++--------
>  kernel/cobalt/posix/thread.c                             |  8 ++++----
>  8 files changed, 39 insertions(+), 26 deletions(-)
> 
> diff --git a/include/cobalt/uapi/kernel/types.h b/include/cobalt/uapi/kernel/types.h
> index 2c931c29c..495c94506 100644
> --- a/include/cobalt/uapi/kernel/types.h
> +++ b/include/cobalt/uapi/kernel/types.h
> @@ -57,6 +57,11 @@ static inline xnhandle_t xnhandle_get_id(xnhandle_t handle)
>  	return handle & ~XN_HANDLE_TRANSIENT_MASK;
>  }
>  
> +struct xn_ts64 {
> +	__u64 tv_sec;
> +	__u64 tv_nsec;
> +};
> +
>  /*
>   * Our representation of time specs at the kernel<->user interface
>   * boundary at the moment, until we have fully transitioned to a
> diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h
> index 14095870f..6b1639feb 100644
> --- a/include/cobalt/uapi/sched.h
> +++ b/include/cobalt/uapi/sched.h
> @@ -33,15 +33,17 @@
>  
>  struct __sched_ss_param {
>  	int __sched_low_priority;
> -	struct __user_old_timespec __sched_repl_period;
> -	struct __user_old_timespec __sched_init_budget;
> +	int: 32;
> +	struct xn_ts64 __sched_repl_period;
> +	struct xn_ts64 __sched_init_budget;
>  	int __sched_max_repl;
> +	int: 32;
>  };
>  
>  #define sched_rr_quantum	sched_u.rr.__sched_rr_quantum
>  
>  struct __sched_rr_param {
> -	struct __user_old_timespec __sched_rr_quantum;
> +	struct xn_ts64 __sched_rr_quantum;
>  };
>  
>  #ifndef SCHED_TP
> @@ -54,9 +56,10 @@ struct __sched_tp_param {
>  };
>  
>  struct sched_tp_window {
> -	struct __user_old_timespec offset;
> -	struct __user_old_timespec duration;
> +	struct xn_ts64 offset;
> +	struct xn_ts64 duration;
>  	int ptid;
> +	int: 32;
>  };
>  
>  enum {
> @@ -122,6 +125,7 @@ struct __sched_config_quota {
>  
>  struct sched_param_ex {
>  	int sched_priority;
> +	int: 32;

Having these two lines back-to-back looks strange: Why do we specify 32
bits explicitly for the padding, why don't we have to specify that for
the sched_priority, and why don't we use the __u32/__s32 types here?
Same applies to the other structs touched.

Jan

-- 
Siemens AG, Technology
Linux Expert Center


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

* Re: [PATCH v2 1/4] cobalt/posix/syscall32: Remove unused mq_fetch_timeout
  2023-07-17  9:10 ` [PATCH v2 1/4] cobalt/posix/syscall32: Remove unused mq_fetch_timeout Florian Bezdeka
@ 2023-07-20 16:37   ` Jan Kiszka
  2023-07-27 15:56     ` Florian Bezdeka
  0 siblings, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2023-07-20 16:37 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 17.07.23 11:10, Florian Bezdeka wrote:
> Removal of unused (and broken) code. Using cobalt_get_u_timespec would
> have been wrong and sys32_fetch_timespec would have been correct.
> 
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> ---
>  kernel/cobalt/posix/syscall32.c | 6 ------
>  1 file changed, 6 deletions(-)
> 
> diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
> index 780d276b1..c82cc60a2 100644
> --- a/kernel/cobalt/posix/syscall32.c
> +++ b/kernel/cobalt/posix/syscall32.c
> @@ -318,12 +318,6 @@ COBALT_SYSCALL32emu(mq_timedreceive64, primary,
>  	return ret ?: cobalt_copy_to_user(u_len, &clen, sizeof(*u_len));
>  }
>  
> -static inline int mq_fetch_timeout(struct timespec64 *ts,
> -				   const void __user *u_ts)
> -{
> -	return u_ts == NULL ? -EFAULT : cobalt_get_u_timespec(ts, u_ts);
> -}
> -
>  COBALT_SYSCALL32emu(mq_notify, primary,
>  		    (mqd_t fd, const struct compat_sigevent *__user u_cev))
>  {
> 

Applying this cleanup already.

Thanks,
Jan

-- 
Siemens AG, Technology
Linux Expert Center


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

* Re: [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
  2023-07-17  9:10 ` [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t Florian Bezdeka
  2023-07-20 16:36   ` Jan Kiszka
@ 2023-07-20 16:47   ` Jan Kiszka
  2023-07-21 12:51     ` Florian Bezdeka
  1 sibling, 1 reply; 13+ messages in thread
From: Jan Kiszka @ 2023-07-20 16:47 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 17.07.23 11:10, Florian Bezdeka wrote:
> Instead of implementing time64_t based cobalt services for the
> following services we simply break the ABI and make it time64_t aware.
> 
> Affected cobalt services:
>   - cobalt_thread_create
>   - cobalt_thread_setschedparam_ex
>   - cobalt_thread_getschedparam_ex
>   - cobalt_sched_setconfig_np
>   - cobalt_sched_getconfig_np
>   - cobalt_sched_setscheduler_ex
>   - cobalt_sched_getscheduler_ex
> 
> XENOMAI_ABI_REV is incremented on all supported plattforms to express
> the ABI breakage.
> 
> The memory alignment of some data structures is changed by adding
> some anonymous paddings. This allows us to remove some compat specific
> services afterwards. The memory layout is identical on all platforms
> now.

While the cleanups are enormous, I think we need to make sure that we
are not causing subtle issues to applications.

I first thought we are only breaking the ABI for internal communication
kernel<->libcobalt. But some structs you touch here are used by
applications as well, aren't they? And then we are now exposing 64-bit
time types to them. Will they be fine with that? Recompilation is
needed, that is clear, but will applications not supporting 64-bit time
types yet nevertheless be able to use the 64-bit extended structures
without major code changes?

Jan

-- 
Siemens AG, Technology
Linux Expert Center


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

* Re: [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
  2023-07-20 16:36   ` Jan Kiszka
@ 2023-07-21 12:43     ` Florian Bezdeka
  2023-07-26  5:38       ` Jan Kiszka
  0 siblings, 1 reply; 13+ messages in thread
From: Florian Bezdeka @ 2023-07-21 12:43 UTC (permalink / raw)
  To: Jan Kiszka, xenomai

On Thu, 2023-07-20 at 18:36 +0200, Jan Kiszka wrote:
> On 17.07.23 11:10, Florian Bezdeka wrote:
> > Instead of implementing time64_t based cobalt services for the
> > following services we simply break the ABI and make it time64_t aware.
> > 
> > Affected cobalt services:
> >   - cobalt_thread_create
> >   - cobalt_thread_setschedparam_ex
> >   - cobalt_thread_getschedparam_ex
> >   - cobalt_sched_setconfig_np
> >   - cobalt_sched_getconfig_np
> >   - cobalt_sched_setscheduler_ex
> >   - cobalt_sched_getscheduler_ex
> > 
> > XENOMAI_ABI_REV is incremented on all supported plattforms to express
> > the ABI breakage.
> > 
> > The memory alignment of some data structures is changed by adding
> > some anonymous paddings. This allows us to remove some compat specific
> > services afterwards. The memory layout is identical on all platforms
> > now.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> >  include/cobalt/uapi/kernel/types.h                       |  5 +++++
> >  include/cobalt/uapi/sched.h                              | 14 +++++++++-----
> >  .../cobalt/arch/arm/include/asm/xenomai/uapi/features.h  |  2 +-
> >  .../arch/arm64/include/asm/xenomai/uapi/features.h       |  2 +-
> >  .../cobalt/arch/x86/include/asm/xenomai/uapi/features.h  |  2 +-
> >  kernel/cobalt/posix/clock.h                              | 16 ++++++++++------
> >  kernel/cobalt/posix/sched.c                              | 16 ++++++++--------
> >  kernel/cobalt/posix/thread.c                             |  8 ++++----
> >  8 files changed, 39 insertions(+), 26 deletions(-)
> > 
> > diff --git a/include/cobalt/uapi/kernel/types.h b/include/cobalt/uapi/kernel/types.h
> > index 2c931c29c..495c94506 100644
> > --- a/include/cobalt/uapi/kernel/types.h
> > +++ b/include/cobalt/uapi/kernel/types.h
> > @@ -57,6 +57,11 @@ static inline xnhandle_t xnhandle_get_id(xnhandle_t handle)
> >  	return handle & ~XN_HANDLE_TRANSIENT_MASK;
> >  }
> >  
> > +struct xn_ts64 {
> > +	__u64 tv_sec;
> > +	__u64 tv_nsec;
> > +};
> > +
> >  /*
> >   * Our representation of time specs at the kernel<->user interface
> >   * boundary at the moment, until we have fully transitioned to a
> > diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h
> > index 14095870f..6b1639feb 100644
> > --- a/include/cobalt/uapi/sched.h
> > +++ b/include/cobalt/uapi/sched.h
> > @@ -33,15 +33,17 @@
> >  
> >  struct __sched_ss_param {
> >  	int __sched_low_priority;
> > -	struct __user_old_timespec __sched_repl_period;
> > -	struct __user_old_timespec __sched_init_budget;
> > +	int: 32;
> > +	struct xn_ts64 __sched_repl_period;
> > +	struct xn_ts64 __sched_init_budget;
> >  	int __sched_max_repl;
> > +	int: 32;
> >  };
> >  
> >  #define sched_rr_quantum	sched_u.rr.__sched_rr_quantum
> >  
> >  struct __sched_rr_param {
> > -	struct __user_old_timespec __sched_rr_quantum;
> > +	struct xn_ts64 __sched_rr_quantum;
> >  };
> >  
> >  #ifndef SCHED_TP
> > @@ -54,9 +56,10 @@ struct __sched_tp_param {
> >  };
> >  
> >  struct sched_tp_window {
> > -	struct __user_old_timespec offset;
> > -	struct __user_old_timespec duration;
> > +	struct xn_ts64 offset;
> > +	struct xn_ts64 duration;
> >  	int ptid;
> > +	int: 32;
> >  };
> >  
> >  enum {
> > @@ -122,6 +125,7 @@ struct __sched_config_quota {
> >  
> >  struct sched_param_ex {
> >  	int sched_priority;
> > +	int: 32;
> 
> Having these two lines back-to-back looks strange: Why do we specify 32
> bits explicitly for the padding, why don't we have to specify that for
> the sched_priority, and why don't we use the __u32/__s32 types here?
> Same applies to the other structs touched.

AFAICT there is no difference in the data type used for the padding. We
could switch to __u32/__32 as long as the produced memory layout is the
same on all architectures. As this "member" does not have a name
(=anonymous) it really shouldn't make any difference.

I'm not sure if I get the part about "why don't we have to specify that
for the sched_priority" right. After the padding in sched_param_ex two
64 bit values (__u64 as part of struct xn_ts64) will follow. 

64 bit values are 8 byte aligned on 64 bit systems but 4 byte aligned
on 32 bit systems. To get the same memory layout (for being able to
handle compat syscalls with the same data types) I added the "anonymous
padding". The padding has an impact on 32 bit systems only.

The other structs touched have the same reasoning behind.
__sched_ss_param and sched_tp_window will be extended to the next 8
byte boundary on 64 bit systems automatically, so we have to "fill them
up" with a trailing padding.

Does that answer your questions? Any follow up necessary?

Florian

> 
> Jan
> 
> -- 
> Siemens AG, Technology
> Linux Expert Center


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

* Re: [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
  2023-07-20 16:47   ` Jan Kiszka
@ 2023-07-21 12:51     ` Florian Bezdeka
  2023-07-26  5:30       ` Jan Kiszka
  0 siblings, 1 reply; 13+ messages in thread
From: Florian Bezdeka @ 2023-07-21 12:51 UTC (permalink / raw)
  To: Jan Kiszka, xenomai

On Thu, 2023-07-20 at 18:47 +0200, Jan Kiszka wrote:
> On 17.07.23 11:10, Florian Bezdeka wrote:
> > Instead of implementing time64_t based cobalt services for the
> > following services we simply break the ABI and make it time64_t aware.
> > 
> > Affected cobalt services:
> >   - cobalt_thread_create
> >   - cobalt_thread_setschedparam_ex
> >   - cobalt_thread_getschedparam_ex
> >   - cobalt_sched_setconfig_np
> >   - cobalt_sched_getconfig_np
> >   - cobalt_sched_setscheduler_ex
> >   - cobalt_sched_getscheduler_ex
> > 
> > XENOMAI_ABI_REV is incremented on all supported plattforms to express
> > the ABI breakage.
> > 
> > The memory alignment of some data structures is changed by adding
> > some anonymous paddings. This allows us to remove some compat specific
> > services afterwards. The memory layout is identical on all platforms
> > now.
> 
> While the cleanups are enormous, I think we need to make sure that we
> are not causing subtle issues to applications.
> 
> I first thought we are only breaking the ABI for internal communication
> kernel<->libcobalt. But some structs you touch here are used by
> applications as well, aren't they? And then we are now exposing 64-bit
> time types to them. Will they be fine with that? Recompilation is
> needed, that is clear, but will applications not supporting 64-bit time
> types yet nevertheless be able to use the 64-bit extended structures
> without major code changes?

Recompiling is necessary, no question. That should be OK as this is
targeting the next/master branch exclusively.

We never had any time_t in this API. We used our own data type (struct
__user_old_timespec) in the past. This is why this "auto-conversion"
with glibc support does not work here. If we would like to have that we
would have to use struct timespec and we are back to v1 of this series.

Userspace code should use struct sched_param_ex and friends which will
now hold struct xn_ts64 instead of our previously used struct with
identical member names, so no problem expected. The testsuite stayed as
is right now, that's a good sign.

struct sched_param_ex is part of the uapi, and hopefully only used
there. Even if an application decided to use it internally as well that
should work. Different memory layout but everything else should be
backward compatible - only a recompile away.

Florian

> 
> Jan
> 
> -- 
> Siemens AG, Technology
> Linux Expert Center


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

* Re: [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
  2023-07-21 12:51     ` Florian Bezdeka
@ 2023-07-26  5:30       ` Jan Kiszka
  0 siblings, 0 replies; 13+ messages in thread
From: Jan Kiszka @ 2023-07-26  5:30 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 21.07.23 14:51, Florian Bezdeka wrote:
> On Thu, 2023-07-20 at 18:47 +0200, Jan Kiszka wrote:
>> On 17.07.23 11:10, Florian Bezdeka wrote:
>>> Instead of implementing time64_t based cobalt services for the
>>> following services we simply break the ABI and make it time64_t aware.
>>>
>>> Affected cobalt services:
>>>   - cobalt_thread_create
>>>   - cobalt_thread_setschedparam_ex
>>>   - cobalt_thread_getschedparam_ex
>>>   - cobalt_sched_setconfig_np
>>>   - cobalt_sched_getconfig_np
>>>   - cobalt_sched_setscheduler_ex
>>>   - cobalt_sched_getscheduler_ex
>>>
>>> XENOMAI_ABI_REV is incremented on all supported plattforms to express
>>> the ABI breakage.
>>>
>>> The memory alignment of some data structures is changed by adding
>>> some anonymous paddings. This allows us to remove some compat specific
>>> services afterwards. The memory layout is identical on all platforms
>>> now.
>>
>> While the cleanups are enormous, I think we need to make sure that we
>> are not causing subtle issues to applications.
>>
>> I first thought we are only breaking the ABI for internal communication
>> kernel<->libcobalt. But some structs you touch here are used by
>> applications as well, aren't they? And then we are now exposing 64-bit
>> time types to them. Will they be fine with that? Recompilation is
>> needed, that is clear, but will applications not supporting 64-bit time
>> types yet nevertheless be able to use the 64-bit extended structures
>> without major code changes?
> 
> Recompiling is necessary, no question. That should be OK as this is
> targeting the next/master branch exclusively.
> 
> We never had any time_t in this API. We used our own data type (struct
> __user_old_timespec) in the past. This is why this "auto-conversion"
> with glibc support does not work here. If we would like to have that we
> would have to use struct timespec and we are back to v1 of this series.
> 
> Userspace code should use struct sched_param_ex and friends which will
> now hold struct xn_ts64 instead of our previously used struct with
> identical member names, so no problem expected. The testsuite stayed as
> is right now, that's a good sign.
> 
> struct sched_param_ex is part of the uapi, and hopefully only used
> there. Even if an application decided to use it internally as well that
> should work. Different memory layout but everything else should be
> backward compatible - only a recompile away.

OK, I think now we can go this way.

Jan

-- 
Siemens AG, Technology
Linux Expert Center


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

* Re: [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
  2023-07-21 12:43     ` Florian Bezdeka
@ 2023-07-26  5:38       ` Jan Kiszka
  0 siblings, 0 replies; 13+ messages in thread
From: Jan Kiszka @ 2023-07-26  5:38 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai

On 21.07.23 14:43, Florian Bezdeka wrote:
> On Thu, 2023-07-20 at 18:36 +0200, Jan Kiszka wrote:
>> On 17.07.23 11:10, Florian Bezdeka wrote:
>>> Instead of implementing time64_t based cobalt services for the
>>> following services we simply break the ABI and make it time64_t aware.
>>>
>>> Affected cobalt services:
>>>   - cobalt_thread_create
>>>   - cobalt_thread_setschedparam_ex
>>>   - cobalt_thread_getschedparam_ex
>>>   - cobalt_sched_setconfig_np
>>>   - cobalt_sched_getconfig_np
>>>   - cobalt_sched_setscheduler_ex
>>>   - cobalt_sched_getscheduler_ex
>>>
>>> XENOMAI_ABI_REV is incremented on all supported plattforms to express
>>> the ABI breakage.
>>>
>>> The memory alignment of some data structures is changed by adding
>>> some anonymous paddings. This allows us to remove some compat specific
>>> services afterwards. The memory layout is identical on all platforms
>>> now.
>>>
>>> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
>>> ---
>>>  include/cobalt/uapi/kernel/types.h                       |  5 +++++
>>>  include/cobalt/uapi/sched.h                              | 14 +++++++++-----
>>>  .../cobalt/arch/arm/include/asm/xenomai/uapi/features.h  |  2 +-
>>>  .../arch/arm64/include/asm/xenomai/uapi/features.h       |  2 +-
>>>  .../cobalt/arch/x86/include/asm/xenomai/uapi/features.h  |  2 +-
>>>  kernel/cobalt/posix/clock.h                              | 16 ++++++++++------
>>>  kernel/cobalt/posix/sched.c                              | 16 ++++++++--------
>>>  kernel/cobalt/posix/thread.c                             |  8 ++++----
>>>  8 files changed, 39 insertions(+), 26 deletions(-)
>>>
>>> diff --git a/include/cobalt/uapi/kernel/types.h b/include/cobalt/uapi/kernel/types.h
>>> index 2c931c29c..495c94506 100644
>>> --- a/include/cobalt/uapi/kernel/types.h
>>> +++ b/include/cobalt/uapi/kernel/types.h
>>> @@ -57,6 +57,11 @@ static inline xnhandle_t xnhandle_get_id(xnhandle_t handle)
>>>  	return handle & ~XN_HANDLE_TRANSIENT_MASK;
>>>  }
>>>  
>>> +struct xn_ts64 {
>>> +	__u64 tv_sec;
>>> +	__u64 tv_nsec;
>>> +};
>>> +
>>>  /*
>>>   * Our representation of time specs at the kernel<->user interface
>>>   * boundary at the moment, until we have fully transitioned to a
>>> diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h
>>> index 14095870f..6b1639feb 100644
>>> --- a/include/cobalt/uapi/sched.h
>>> +++ b/include/cobalt/uapi/sched.h
>>> @@ -33,15 +33,17 @@
>>>  
>>>  struct __sched_ss_param {
>>>  	int __sched_low_priority;
>>> -	struct __user_old_timespec __sched_repl_period;
>>> -	struct __user_old_timespec __sched_init_budget;
>>> +	int: 32;
>>> +	struct xn_ts64 __sched_repl_period;
>>> +	struct xn_ts64 __sched_init_budget;
>>>  	int __sched_max_repl;
>>> +	int: 32;
>>>  };
>>>  
>>>  #define sched_rr_quantum	sched_u.rr.__sched_rr_quantum
>>>  
>>>  struct __sched_rr_param {
>>> -	struct __user_old_timespec __sched_rr_quantum;
>>> +	struct xn_ts64 __sched_rr_quantum;
>>>  };
>>>  
>>>  #ifndef SCHED_TP
>>> @@ -54,9 +56,10 @@ struct __sched_tp_param {
>>>  };
>>>  
>>>  struct sched_tp_window {
>>> -	struct __user_old_timespec offset;
>>> -	struct __user_old_timespec duration;
>>> +	struct xn_ts64 offset;
>>> +	struct xn_ts64 duration;
>>>  	int ptid;
>>> +	int: 32;
>>>  };
>>>  
>>>  enum {
>>> @@ -122,6 +125,7 @@ struct __sched_config_quota {
>>>  
>>>  struct sched_param_ex {
>>>  	int sched_priority;
>>> +	int: 32;
>>
>> Having these two lines back-to-back looks strange: Why do we specify 32
>> bits explicitly for the padding, why don't we have to specify that for
>> the sched_priority, and why don't we use the __u32/__s32 types here?
>> Same applies to the other structs touched.
> 
> AFAICT there is no difference in the data type used for the padding. We
> could switch to __u32/__32 as long as the produced memory layout is the
> same on all architectures. As this "member" does not have a name
> (=anonymous) it really shouldn't make any difference.
> 
> I'm not sure if I get the part about "why don't we have to specify that
> for the sched_priority" right. After the padding in sched_param_ex two
> 64 bit values (__u64 as part of struct xn_ts64) will follow. 

"int" is not "int:32" by definition. I may just be on our current target
platforms.

> 
> 64 bit values are 8 byte aligned on 64 bit systems but 4 byte aligned
> on 32 bit systems. To get the same memory layout (for being able to
> handle compat syscalls with the same data types) I added the "anonymous
> padding". The padding has an impact on 32 bit systems only.
> 
> The other structs touched have the same reasoning behind.
> __sched_ss_param and sched_tp_window will be extended to the next 8
> byte boundary on 64 bit systems automatically, so we have to "fill them
> up" with a trailing padding.
> 
> Does that answer your questions? Any follow up necessary?
> 

I would still vote for explicitly sized types in structs we have under
our full control, where we don't need to be compatible with types
outside our space.

Jan

-- 
Siemens AG, Technology
Linux Expert Center


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

* Re: [PATCH v2 1/4] cobalt/posix/syscall32: Remove unused mq_fetch_timeout
  2023-07-20 16:37   ` Jan Kiszka
@ 2023-07-27 15:56     ` Florian Bezdeka
  0 siblings, 0 replies; 13+ messages in thread
From: Florian Bezdeka @ 2023-07-27 15:56 UTC (permalink / raw)
  To: Jan Kiszka, xenomai

On Thu, 2023-07-20 at 18:37 +0200, Jan Kiszka wrote:
> On 17.07.23 11:10, Florian Bezdeka wrote:
> > Removal of unused (and broken) code. Using cobalt_get_u_timespec would
> > have been wrong and sys32_fetch_timespec would have been correct.
> > 
> > Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
> > ---
> >  kernel/cobalt/posix/syscall32.c | 6 ------
> >  1 file changed, 6 deletions(-)
> > 
> > diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
> > index 780d276b1..c82cc60a2 100644
> > --- a/kernel/cobalt/posix/syscall32.c
> > +++ b/kernel/cobalt/posix/syscall32.c
> > @@ -318,12 +318,6 @@ COBALT_SYSCALL32emu(mq_timedreceive64, primary,
> >  	return ret ?: cobalt_copy_to_user(u_len, &clen, sizeof(*u_len));
> >  }
> >  
> > -static inline int mq_fetch_timeout(struct timespec64 *ts,
> > -				   const void __user *u_ts)
> > -{
> > -	return u_ts == NULL ? -EFAULT : cobalt_get_u_timespec(ts, u_ts);
> > -}
> > -
> >  COBALT_SYSCALL32emu(mq_notify, primary,
> >  		    (mqd_t fd, const struct compat_sigevent *__user u_cev))
> >  {
> > 
> 
> Applying this cleanup already.

That's not yet visible on source.denx.de. Missing git push?

Regards,
Florian

> 
> Thanks,
> Jan
> 
> -- 
> Siemens AG, Technology
> Linux Expert Center


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

end of thread, other threads:[~2023-07-27 16:06 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-17  9:10 [PATCH v2 0/4] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
2023-07-17  9:10 ` [PATCH v2 1/4] cobalt/posix/syscall32: Remove unused mq_fetch_timeout Florian Bezdeka
2023-07-20 16:37   ` Jan Kiszka
2023-07-27 15:56     ` Florian Bezdeka
2023-07-17  9:10 ` [PATCH v2 2/4] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t Florian Bezdeka
2023-07-20 16:36   ` Jan Kiszka
2023-07-21 12:43     ` Florian Bezdeka
2023-07-26  5:38       ` Jan Kiszka
2023-07-20 16:47   ` Jan Kiszka
2023-07-21 12:51     ` Florian Bezdeka
2023-07-26  5:30       ` Jan Kiszka
2023-07-17  9:10 ` [PATCH v2 3/4] y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex} Florian Bezdeka
2023-07-17  9:10 ` [PATCH v2 4/4] y2038: cobalt/{thread,sched}: Remove obsolete compat handling Florian Bezdeka

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).