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

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 v3:
- Added fixes for compat issue around struct rtser_config (rtdm)
- Move to types with fixed size, Patch 5
- Align struct xn_ts64 with struct __kernel_timespec (__u64 vs __s64)
- Link to v2: https://lore.kernel.org/r/20230630-florian-y2038-part-four-upstreaming-v2-0-b4e888eca2d9@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 (7):
      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
      cobalt/uapi: Move to data types with fixed sizes
      include/rtdm/serial.h: Move to data types with fixed sizes
      include/rtdm/serial.h: Fix compat support of struct rtser_config

 include/cobalt/kernel/compat.h                     |  49 -----
 include/cobalt/uapi/event.h                        |   6 +-
 include/cobalt/uapi/kernel/types.h                 |  54 +----
 include/cobalt/uapi/sched.h                        |  52 ++---
 include/cobalt/uapi/sem.h                          |   6 +-
 include/cobalt/uapi/thread.h                       |   4 +-
 include/rtdm/uapi/serial.h                         |  35 +--
 .../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 +-
 43 files changed, 174 insertions(+), 611 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] 10+ messages in thread

* [PATCH v3 1/7] cobalt/posix/syscall32: Remove unused mq_fetch_timeout
  2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
@ 2023-08-01  9:29 ` Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 2/7] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t Florian Bezdeka
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Florian Bezdeka @ 2023-08-01  9:29 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] 10+ messages in thread

* [PATCH v3 2/7] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t
  2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 1/7] cobalt/posix/syscall32: Remove unused mq_fetch_timeout Florian Bezdeka
@ 2023-08-01  9:29 ` Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 3/7] y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex} Florian Bezdeka
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Florian Bezdeka @ 2023-08-01  9:29 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..eefc5a764 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 {
+	__s64 tv_sec;
+	__s64 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] 10+ messages in thread

* [PATCH v3 3/7] y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex}
  2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 1/7] cobalt/posix/syscall32: Remove unused mq_fetch_timeout Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 2/7] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t Florian Bezdeka
@ 2023-08-01  9:29 ` Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 4/7] y2038: cobalt/{thread,sched}: Remove obsolete compat handling Florian Bezdeka
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Florian Bezdeka @ 2023-08-01  9:29 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 eefc5a764..04ba76c6e 100644
--- a/include/cobalt/uapi/kernel/types.h
+++ b/include/cobalt/uapi/kernel/types.h
@@ -62,57 +62,4 @@ struct xn_ts64 {
 	__s64 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] 10+ messages in thread

* [PATCH v3 4/7] y2038: cobalt/{thread,sched}: Remove obsolete compat handling
  2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
                   ` (2 preceding siblings ...)
  2023-08-01  9:29 ` [PATCH v3 3/7] y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex} Florian Bezdeka
@ 2023-08-01  9:29 ` Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 5/7] cobalt/uapi: Move to data types with fixed sizes Florian Bezdeka
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Florian Bezdeka @ 2023-08-01  9:29 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] 10+ messages in thread

* [PATCH v3 5/7] cobalt/uapi: Move to data types with fixed sizes
  2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
                   ` (3 preceding siblings ...)
  2023-08-01  9:29 ` [PATCH v3 4/7] y2038: cobalt/{thread,sched}: Remove obsolete compat handling Florian Bezdeka
@ 2023-08-01  9:29 ` Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 6/7] include/rtdm/serial.h: " Florian Bezdeka
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Florian Bezdeka @ 2023-08-01  9:29 UTC (permalink / raw)
  To: xenomai, jan.kiszka; +Cc: Florian Bezdeka

While making the Xenomai thread and sched UAPI y2038 safe a valid point
came up during review phase: We assume that int is 32 bit.

This assumption is currently true for all supported platforms but to
be correct we should use the corresponding kernel data types with fixed
sizes.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/cobalt/uapi/event.h  |  6 +++---
 include/cobalt/uapi/sched.h  | 38 +++++++++++++++++++-------------------
 include/cobalt/uapi/sem.h    |  6 +++---
 include/cobalt/uapi/thread.h |  4 ++--
 4 files changed, 27 insertions(+), 27 deletions(-)

diff --git a/include/cobalt/uapi/event.h b/include/cobalt/uapi/event.h
index 8710e8e25..5abf55632 100644
--- a/include/cobalt/uapi/event.h
+++ b/include/cobalt/uapi/event.h
@@ -45,9 +45,9 @@ struct cobalt_event_shadow {
 };
 
 struct cobalt_event_info {
-	unsigned int value;
-	int flags;
-	int nrwait;
+	__u32 value;
+	__s32 flags;
+	__s32 nrwait;
 };
 
 typedef struct cobalt_event_shadow cobalt_event_t;
diff --git a/include/cobalt/uapi/sched.h b/include/cobalt/uapi/sched.h
index 6b1639feb..4fe1d8ee9 100644
--- a/include/cobalt/uapi/sched.h
+++ b/include/cobalt/uapi/sched.h
@@ -32,11 +32,11 @@
 #endif	/* !SCHED_SPORADIC */
 
 struct __sched_ss_param {
-	int __sched_low_priority;
+	__s32 __sched_low_priority;
 	int: 32;
 	struct xn_ts64 __sched_repl_period;
 	struct xn_ts64 __sched_init_budget;
-	int __sched_max_repl;
+	__s32 __sched_max_repl;
 	int: 32;
 };
 
@@ -52,13 +52,13 @@ struct __sched_rr_param {
 #endif	/* !SCHED_TP */
 
 struct __sched_tp_param {
-	int __sched_partition;
+	__s32 __sched_partition;
 };
 
 struct sched_tp_window {
 	struct xn_ts64 offset;
 	struct xn_ts64 duration;
-	int ptid;
+	__s32 ptid;
 	int: 32;
 };
 
@@ -70,8 +70,8 @@ enum {
 };
 	
 struct __sched_config_tp {
-	int op;
-	int nr_windows;
+	__s32 op;
+	__s32 nr_windows;
 	struct sched_tp_window windows[0];
 };
 
@@ -84,7 +84,7 @@ struct __sched_config_tp {
 #endif	/* !SCHED_QUOTA */
 
 struct __sched_quota_param {
-	int __sched_group;
+	__s32 __sched_group;
 };
 
 enum {
@@ -96,35 +96,35 @@ enum {
 };
 
 struct __sched_config_quota {
-	int op;
+	__s32 op;
 	union {
 		struct {
-			int pshared;
+			__s32 pshared;
 		} add;
 		struct {
-			int tgid;
+			__s32 tgid;
 		} remove;
 		struct {
-			int tgid;
-			int quota;
-			int quota_peak;
+			__s32 tgid;
+			__s32 quota;
+			__s32 quota_peak;
 		} set;
 		struct {
-			int tgid;
+			__s32 tgid;
 		} get;
 	};
 	struct __sched_quota_info {
-		int tgid;
-		int quota;
-		int quota_peak;
-		int quota_sum;
+		__s32 tgid;
+		__s32 quota;
+		__s32 quota_peak;
+		__s32 quota_sum;
 	} info;
 };
 
 #define sched_quota_confsz()  sizeof(struct __sched_config_quota)
 
 struct sched_param_ex {
-	int sched_priority;
+	__s32 sched_priority;
 	int: 32;
 	union {
 		struct __sched_ss_param ss;
diff --git a/include/cobalt/uapi/sem.h b/include/cobalt/uapi/sem.h
index 01a9b552f..ae8e967a9 100644
--- a/include/cobalt/uapi/sem.h
+++ b/include/cobalt/uapi/sem.h
@@ -40,9 +40,9 @@ union cobalt_sem_union {
 };
 
 struct cobalt_sem_info {
-	unsigned int value;
-	int flags;
-	int nrwait;
+	__u32 value;
+	__s32 flags;
+	__s32 nrwait;
 };
 
 #define SEM_FIFO       0x1
diff --git a/include/cobalt/uapi/thread.h b/include/cobalt/uapi/thread.h
index 07602db9f..3facbfb99 100644
--- a/include/cobalt/uapi/thread.h
+++ b/include/cobalt/uapi/thread.h
@@ -46,8 +46,8 @@ struct cobalt_threadstat {
 	__u64 xsc;
 	__u32 status;
 	__u32 pf;
-	int cpu;
-	int cprio;
+	__s32 cpu;
+	__s32 cprio;
 	char name[XNOBJECT_NAME_LEN];
 	char personality[XNOBJECT_NAME_LEN];
 };

-- 
2.39.2


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

* [PATCH v3 6/7] include/rtdm/serial.h: Move to data types with fixed sizes
  2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
                   ` (4 preceding siblings ...)
  2023-08-01  9:29 ` [PATCH v3 5/7] cobalt/uapi: Move to data types with fixed sizes Florian Bezdeka
@ 2023-08-01  9:29 ` Florian Bezdeka
  2023-08-01  9:29 ` [PATCH v3 7/7] include/rtdm/serial.h: Fix compat support of struct rtser_config Florian Bezdeka
  2023-08-09  6:47 ` [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Jan Kiszka
  7 siblings, 0 replies; 10+ messages in thread
From: Florian Bezdeka @ 2023-08-01  9:29 UTC (permalink / raw)
  To: xenomai, jan.kiszka; +Cc: Florian Bezdeka

This is a preparation for making struct rtser_config compat aware.

Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/rtdm/uapi/serial.h | 32 +++++++++++++++++---------------
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/include/rtdm/uapi/serial.h b/include/rtdm/uapi/serial.h
index 9ac691b72..843c940b3 100644
--- a/include/rtdm/uapi/serial.h
+++ b/include/rtdm/uapi/serial.h
@@ -23,6 +23,8 @@
 #ifndef _RTDM_UAPI_SERIAL_H
 #define _RTDM_UAPI_SERIAL_H
 
+#include <linux/types.h>
+
 #define RTSER_PROFILE_VER		3
 
 /*!
@@ -198,27 +200,27 @@
  */
 typedef struct rtser_config {
 	/** mask specifying valid fields, see @ref RTSER_SET_xxx */
-	int		config_mask;
+	__s32		config_mask;
 
 	/** baud rate, default @ref RTSER_DEF_BAUD */
-	int		baud_rate;
+	__s32		baud_rate;
 
 	/** number of parity bits, see @ref RTSER_xxx_PARITY */
-	int		parity;
+	__s32		parity;
 
 	/** number of data bits, see @ref RTSER_xxx_BITS */
-	int		data_bits;
+	__s32		data_bits;
 
 	/** number of stop bits, see @ref RTSER_xxx_STOPB */
-	int		stop_bits;
+	__s32		stop_bits;
 
 	/** handshake mechanisms, see @ref RTSER_xxx_HAND */
-	int		handshake;
+	__s32		handshake;
 
 	/** reception FIFO interrupt threshold, see @ref RTSER_FIFO_xxx */
-	int		fifo_depth;
+	__s32		fifo_depth;
 
-	int		reserved;
+	__s32		reserved;
 
 	/** reception timeout, see @ref RTSER_TIMEOUT_xxx for special
 	 *  values */
@@ -232,14 +234,14 @@ typedef struct rtser_config {
 	nanosecs_rel_t	event_timeout;
 
 	/** enable timestamp history, see @ref RTSER_xxx_TIMESTAMP_HISTORY */
-	int		timestamp_history;
+	__s32		timestamp_history;
 
 	/** event mask to be used with @ref RTSER_RTIOC_WAIT_EVENT, see
 	 *  @ref RTSER_EVENT_xxx */
-	int		event_mask;
+	__s32		event_mask;
 
 	/** enable RS485 mode, see @ref RTSER_RS485_xxx */
-	int		rs485;
+	__s32		rs485;
 } rtser_config_t;
 
 /**
@@ -247,10 +249,10 @@ typedef struct rtser_config {
  */
 typedef struct rtser_status {
 	/** line status register, see @ref RTSER_LSR_xxx */
-	int		line_status;
+	__s32		line_status;
 
 	/** modem status register, see @ref RTSER_MSR_xxx */
-	int		modem_status;
+	__s32		modem_status;
 } rtser_status_t;
 
 /**
@@ -258,10 +260,10 @@ typedef struct rtser_status {
  */
 typedef struct rtser_event {
 	/** signalled events, see @ref RTSER_EVENT_xxx */
-	int		events;
+	__s32		events;
 
 	/** number of pending input characters */
-	int		rx_pending;
+	__s32		rx_pending;
 
 	/** last interrupt timestamp */
 	nanosecs_abs_t	last_timestamp;

-- 
2.39.2


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

* [PATCH v3 7/7] include/rtdm/serial.h: Fix compat support of struct rtser_config
  2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
                   ` (5 preceding siblings ...)
  2023-08-01  9:29 ` [PATCH v3 6/7] include/rtdm/serial.h: " Florian Bezdeka
@ 2023-08-01  9:29 ` Florian Bezdeka
  2023-08-01 20:49   ` Richard Weinberger
  2023-08-09  6:47 ` [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Jan Kiszka
  7 siblings, 1 reply; 10+ messages in thread
From: Florian Bezdeka @ 2023-08-01  9:29 UTC (permalink / raw)
  To: xenomai, jan.kiszka; +Cc: Florian Bezdeka, Richard Weinberger

This is a backward compatibility breaking change for compat (32 bit)
applications. We already bumped the ABI revision so we already force
recompiling all applications.

On 32bits:
struct rtser_config {
        int                        config_mask;          /*     0     4 */
        int                        baud_rate;            /*     4     4 */
        int                        parity;               /*     8     4 */
        int                        data_bits;            /*    12     4 */
        int                        stop_bits;            /*    16     4 */
        int                        handshake;            /*    20     4 */
        int                        fifo_depth;           /*    24     4 */
        int                        reserved;             /*    28     4 */
        nanosecs_rel_t             rx_timeout;           /*    32     8 */
        nanosecs_rel_t             tx_timeout;           /*    40     8 */
        nanosecs_rel_t             event_timeout;        /*    48     8 */
        int                        timestamp_history;    /*    56     4 */
        int                        event_mask;           /*    60     4 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        int                        rs485;                /*    64     4 */

        /* size: 68, cachelines: 2, members: 14 */
        /* last cacheline: 4 bytes */
} __attribute__((__packed__));

Note: I don't know why pahole reports this struct as packed. It is not.

and 64:
struct rtser_config {
        int                        config_mask;          /*     0     4 */
        int                        baud_rate;            /*     4     4 */
        int                        parity;               /*     8     4 */
        int                        data_bits;            /*    12     4 */
        int                        stop_bits;            /*    16     4 */
        int                        handshake;            /*    20     4 */
        int                        fifo_depth;           /*    24     4 */
        int                        reserved;             /*    28     4 */
        nanosecs_rel_t             rx_timeout;           /*    32     8 */
        nanosecs_rel_t             tx_timeout;           /*    40     8 */
        nanosecs_rel_t             event_timeout;        /*    48     8 */
        int                        timestamp_history;    /*    56     4 */
        int                        event_mask;           /*    60     4 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        int                        rs485;                /*    64     4 */

        /* size: 72, cachelines: 2, members: 14 */
        /* padding: 4 */
        /* last cacheline: 8 bytes */
};

While nanosecs_rel_t is in both case int64_t, gcc adds different tail padding to the struct.

Link: https://lore.kernel.org/all/601440741.237005.1668456855365.JavaMail.zimbra@nod.at/
Reported-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>
---
 include/rtdm/uapi/serial.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/rtdm/uapi/serial.h b/include/rtdm/uapi/serial.h
index 843c940b3..7a250a92d 100644
--- a/include/rtdm/uapi/serial.h
+++ b/include/rtdm/uapi/serial.h
@@ -242,6 +242,9 @@ typedef struct rtser_config {
 
 	/** enable RS485 mode, see @ref RTSER_RS485_xxx */
 	__s32		rs485;
+
+	/* anonymous padding for compat support */
+	int: 32;
 } rtser_config_t;
 
 /**

-- 
2.39.2


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

* Re: [PATCH v3 7/7] include/rtdm/serial.h: Fix compat support of struct rtser_config
  2023-08-01  9:29 ` [PATCH v3 7/7] include/rtdm/serial.h: Fix compat support of struct rtser_config Florian Bezdeka
@ 2023-08-01 20:49   ` Richard Weinberger
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Weinberger @ 2023-08-01 20:49 UTC (permalink / raw)
  To: Florian Bezdeka; +Cc: xenomai, Jan Kiszka

----- Ursprüngliche Mail -----
> Von: "Florian Bezdeka" <florian.bezdeka@siemens.com>
> An: "xenomai" <xenomai@lists.linux.dev>, "Jan Kiszka" <jan.kiszka@siemens.com>
> CC: "Florian Bezdeka" <florian.bezdeka@siemens.com>, "richard" <richard@nod.at>
> Gesendet: Dienstag, 1. August 2023 11:29:41
> Betreff: [PATCH v3 7/7] include/rtdm/serial.h: Fix compat support of struct rtser_config

> This is a backward compatibility breaking change for compat (32 bit)
> applications. We already bumped the ABI revision so we already force
> recompiling all applications.
> 
> On 32bits:
> struct rtser_config {
>        int                        config_mask;          /*     0     4 */
>        int                        baud_rate;            /*     4     4 */
>        int                        parity;               /*     8     4 */
>        int                        data_bits;            /*    12     4 */
>        int                        stop_bits;            /*    16     4 */
>        int                        handshake;            /*    20     4 */
>        int                        fifo_depth;           /*    24     4 */
>        int                        reserved;             /*    28     4 */
>        nanosecs_rel_t             rx_timeout;           /*    32     8 */
>        nanosecs_rel_t             tx_timeout;           /*    40     8 */
>        nanosecs_rel_t             event_timeout;        /*    48     8 */
>        int                        timestamp_history;    /*    56     4 */
>        int                        event_mask;           /*    60     4 */
>        /* --- cacheline 1 boundary (64 bytes) --- */
>        int                        rs485;                /*    64     4 */
> 
>        /* size: 68, cachelines: 2, members: 14 */
>        /* last cacheline: 4 bytes */
> } __attribute__((__packed__));
> 
> Note: I don't know why pahole reports this struct as packed. It is not.
> 
> and 64:
> struct rtser_config {
>        int                        config_mask;          /*     0     4 */
>        int                        baud_rate;            /*     4     4 */
>        int                        parity;               /*     8     4 */
>        int                        data_bits;            /*    12     4 */
>        int                        stop_bits;            /*    16     4 */
>        int                        handshake;            /*    20     4 */
>        int                        fifo_depth;           /*    24     4 */
>        int                        reserved;             /*    28     4 */
>        nanosecs_rel_t             rx_timeout;           /*    32     8 */
>        nanosecs_rel_t             tx_timeout;           /*    40     8 */
>        nanosecs_rel_t             event_timeout;        /*    48     8 */
>        int                        timestamp_history;    /*    56     4 */
>        int                        event_mask;           /*    60     4 */
>        /* --- cacheline 1 boundary (64 bytes) --- */
>        int                        rs485;                /*    64     4 */
> 
>        /* size: 72, cachelines: 2, members: 14 */
>        /* padding: 4 */
>        /* last cacheline: 8 bytes */
> };
> 
> While nanosecs_rel_t is in both case int64_t, gcc adds different tail padding to
> the struct.
> 
> Link:
> https://lore.kernel.org/all/601440741.237005.1668456855365.JavaMail.zimbra@nod.at/
> Reported-by: Richard Weinberger <richard@nod.at>
> Signed-off-by: Florian Bezdeka <florian.bezdeka@siemens.com>

Reviewed-by: Richard Weinberger <richard@nod.at>

Thanks,
//richard

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

* Re: [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs
  2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
                   ` (6 preceding siblings ...)
  2023-08-01  9:29 ` [PATCH v3 7/7] include/rtdm/serial.h: Fix compat support of struct rtser_config Florian Bezdeka
@ 2023-08-09  6:47 ` Jan Kiszka
  7 siblings, 0 replies; 10+ messages in thread
From: Jan Kiszka @ 2023-08-09  6:47 UTC (permalink / raw)
  To: Florian Bezdeka, xenomai; +Cc: Richard Weinberger

On 01.08.23 11:29, Florian Bezdeka wrote:
> 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 v3:
> - Added fixes for compat issue around struct rtser_config (rtdm)
> - Move to types with fixed size, Patch 5
> - Align struct xn_ts64 with struct __kernel_timespec (__u64 vs __s64)
> - Link to v2: https://lore.kernel.org/r/20230630-florian-y2038-part-four-upstreaming-v2-0-b4e888eca2d9@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 (7):
>       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
>       cobalt/uapi: Move to data types with fixed sizes
>       include/rtdm/serial.h: Move to data types with fixed sizes
>       include/rtdm/serial.h: Fix compat support of struct rtser_config
> 
>  include/cobalt/kernel/compat.h                     |  49 -----
>  include/cobalt/uapi/event.h                        |   6 +-
>  include/cobalt/uapi/kernel/types.h                 |  54 +----
>  include/cobalt/uapi/sched.h                        |  52 ++---
>  include/cobalt/uapi/sem.h                          |   6 +-
>  include/cobalt/uapi/thread.h                       |   4 +-
>  include/rtdm/uapi/serial.h                         |  35 +--
>  .../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 +-
>  43 files changed, 174 insertions(+), 611 deletions(-)
> ---
> base-commit: e1567904ecbac671aa9bf6cc0fa150bf43bfb4e9
> change-id: 20230630-florian-y2038-part-four-upstreaming-0c10a5eccfc1
> 
> Best regards,

Thanks, applied to next.

Jan

-- 
Siemens AG, Technology
Linux Expert Center


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

end of thread, other threads:[~2023-08-09  6:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01  9:29 [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Florian Bezdeka
2023-08-01  9:29 ` [PATCH v3 1/7] cobalt/posix/syscall32: Remove unused mq_fetch_timeout Florian Bezdeka
2023-08-01  9:29 ` [PATCH v3 2/7] y2038: cobalt/uapi: Migrate struct sched_param_ex to time64_t Florian Bezdeka
2023-08-01  9:29 ` [PATCH v3 3/7] y2038: cobalt/uapi: Remove __user_old_{timespec,itimerspec,timeval,timex} Florian Bezdeka
2023-08-01  9:29 ` [PATCH v3 4/7] y2038: cobalt/{thread,sched}: Remove obsolete compat handling Florian Bezdeka
2023-08-01  9:29 ` [PATCH v3 5/7] cobalt/uapi: Move to data types with fixed sizes Florian Bezdeka
2023-08-01  9:29 ` [PATCH v3 6/7] include/rtdm/serial.h: " Florian Bezdeka
2023-08-01  9:29 ` [PATCH v3 7/7] include/rtdm/serial.h: Fix compat support of struct rtser_config Florian Bezdeka
2023-08-01 20:49   ` Richard Weinberger
2023-08-09  6:47 ` [PATCH v3 0/7] y2038: Add time64_t support to scheduler and thread APIs Jan Kiszka

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