Commit c071af28 authored by Song Chen's avatar Song Chen Committed by Jan Kiszka
Browse files

y2038: cobalt/posix/mutex: Adding mutex_timedlock64



Add a syscall specific for mutex_timedlock with 64bit time_t.
Signed-off-by: default avatarSong Chen <chensong_2000@189.cn>
[Florian: Rearranged code, coding style fixes, tracing]
Signed-off-by: default avatarFlorian Bezdeka <florian.bezdeka@siemens.com>
[Jan: use correct syscall declaration macro]
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent a69d878b
......@@ -128,6 +128,7 @@
#define sc_cobalt_clock_nanosleep64 105
#define sc_cobalt_clock_getres64 106
#define sc_cobalt_clock_adjtime64 107
#define sc_cobalt_mutex_timedlock64 108
#define __NR_COBALT_SYSCALLS 128 /* Power of 2 */
......
......@@ -21,6 +21,7 @@
#include "mutex.h"
#include "cond.h"
#include "clock.h"
#include <cobalt/kernel/time.h>
static int cobalt_mutex_init_inner(struct cobalt_mutex_shadow *shadow,
struct cobalt_mutex *mutex,
......@@ -76,7 +77,7 @@ int __cobalt_mutex_acquire_unchecked(struct xnthread *cur,
int ret;
if (ts) {
if (ts->tv_nsec >= ONE_BILLION)
if (!timespec64_valid(ts))
return -EINVAL;
ret = xnsynch_acquire(&mutex->synchbase, ts2ns(ts) + 1, XN_REALTIME);
} else
......@@ -357,6 +358,19 @@ static inline int mutex_fetch_timeout(struct timespec64 *ts,
return u_ts == NULL ? -EFAULT : cobalt_get_u_timespec(ts, u_ts);
}
static inline int mutex_fetch_timeout64(struct timespec64 *ts,
const void __user *u_ts)
{
return u_ts == NULL ? -EFAULT : cobalt_get_timespec64(ts, u_ts);
}
int __cobalt_mutex_timedlock64(struct cobalt_mutex_shadow __user *u_mx,
const void __user *u_ts)
{
return __cobalt_mutex_timedlock_break(u_mx, u_ts,
mutex_fetch_timeout64);
}
COBALT_SYSCALL(mutex_timedlock, primary,
(struct cobalt_mutex_shadow __user *u_mx,
const struct __user_old_timespec __user *u_ts))
......@@ -364,6 +378,13 @@ COBALT_SYSCALL(mutex_timedlock, primary,
return __cobalt_mutex_timedlock_break(u_mx, u_ts, mutex_fetch_timeout);
}
COBALT_SYSCALL(mutex_timedlock64, primary,
(struct cobalt_mutex_shadow __user *u_mx,
const struct __kernel_timespec __user *u_ts))
{
return __cobalt_mutex_timedlock64(u_mx, u_ts);
}
COBALT_SYSCALL(mutex_unlock, nonrestartable,
(struct cobalt_mutex_shadow __user *u_mx))
{
......
......@@ -40,6 +40,9 @@ int __cobalt_mutex_timedlock_break(struct cobalt_mutex_shadow __user *u_mx,
int (*fetch_timeout)(struct timespec64 *ts,
const void __user *u_ts));
int __cobalt_mutex_timedlock64(struct cobalt_mutex_shadow __user *u_mx,
const void __user *u_ts);
int __cobalt_mutex_acquire_unchecked(struct xnthread *cur,
struct cobalt_mutex *mutex,
const struct timespec64 *ts);
......@@ -64,6 +67,10 @@ COBALT_SYSCALL_DECL(mutex_timedlock,
(struct cobalt_mutex_shadow __user *u_mx,
const struct __user_old_timespec __user *u_ts));
COBALT_SYSCALL_DECL(mutex_timedlock64,
(struct cobalt_mutex_shadow __user *u_mx,
const struct __kernel_timespec __user *u_ts));
COBALT_SYSCALL_DECL(mutex_unlock,
(struct cobalt_mutex_shadow __user *u_mx));
......
......@@ -267,6 +267,13 @@ COBALT_SYSCALL32emu(mutex_timedlock, primary,
return __cobalt_mutex_timedlock_break(u_mx, u_ts, sys32_fetch_timeout);
}
COBALT_SYSCALL32emu(mutex_timedlock64, primary,
(struct cobalt_mutex_shadow __user *u_mx,
const struct __kernel_timespec __user *u_ts))
{
return __cobalt_mutex_timedlock64(u_mx, u_ts);
}
COBALT_SYSCALL32emu(cond_wait_prologue, nonrestartable,
(struct cobalt_cond_shadow __user *u_cnd,
struct cobalt_mutex_shadow __user *u_mx,
......
......@@ -98,6 +98,10 @@ COBALT_SYSCALL32emu_DECL(mutex_timedlock,
(struct cobalt_mutex_shadow __user *u_mx,
const struct old_timespec32 __user *u_ts));
COBALT_SYSCALL32emu_DECL(mutex_timedlock64,
(struct cobalt_mutex_shadow __user *u_mx,
const struct __kernel_timespec __user *u_ts));
COBALT_SYSCALL32emu_DECL(cond_wait_prologue,
(struct cobalt_cond_shadow __user *u_cnd,
struct cobalt_mutex_shadow __user *u_mx,
......
......@@ -160,7 +160,9 @@
__cobalt_symbolic_syscall(clock_settime64), \
__cobalt_symbolic_syscall(clock_nanosleep64), \
__cobalt_symbolic_syscall(clock_getres64), \
__cobalt_symbolic_syscall(clock_adjtime64))
__cobalt_symbolic_syscall(clock_adjtime64), \
__cobalt_symbolic_syscall(mutex_timedlock64))
DECLARE_EVENT_CLASS(cobalt_syscall_entry,
TP_PROTO(unsigned int nr),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment