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

y2038: cobalt/posix/io: Adding recvmmsg64



Add a syscall specific for recvmmsg64 with 64bit time_t.
Signed-off-by: default avatarSong Chen <chensong_2000@189.cn>
[Florian: Fixed some style issues]
[Florian: Added Song's Signed-off back (malformed patch received)]
[Florian: Fixed tracing infrastructure]
Signed-off-by: default avatarFlorian Bezdeka <florian.bezdeka@siemens.com>
[Jan: reordered include statement]
Signed-off-by: Jan Kiszka's avatarJan Kiszka <jan.kiszka@siemens.com>
parent 6ed84370
......@@ -382,6 +382,11 @@ int __rtdm_fd_recvmmsg(int ufd, void __user *u_msgvec, unsigned int vlen,
int (*put_mmsg)(void __user **u_mmsg_p, const struct mmsghdr *mmsg),
int (*get_timespec)(struct timespec64 *ts, const void __user *u_ts));
int __rtdm_fd_recvmmsg64(int ufd, void __user *u_msgvec, unsigned int vlen,
unsigned int flags, void __user *u_timeout,
int (*get_mmsg)(struct mmsghdr *mmsg, void __user *u_mmsg),
int (*put_mmsg)(void __user **u_mmsg_p, const struct mmsghdr *mmsg));
ssize_t rtdm_fd_sendmsg(int ufd, const struct user_msghdr *msg,
int flags);
......
......@@ -134,6 +134,7 @@
#define sc_cobalt_sigtimedwait64 111
#define sc_cobalt_monitor_wait64 112
#define sc_cobalt_event_wait64 113
#define sc_cobalt_recvmmsg64 114
#define __NR_COBALT_SYSCALLS 128 /* Power of 2 */
......
......@@ -21,6 +21,7 @@
#include <linux/fs.h>
#include <cobalt/kernel/compat.h>
#include <cobalt/kernel/ppd.h>
#include <cobalt/kernel/time.h>
#include <xenomai/rtdm/internal.h>
#include "process.h"
#include "internal.h"
......@@ -121,6 +122,14 @@ COBALT_SYSCALL(recvmmsg, primary,
get_mmsg, put_mmsg, get_timespec);
}
COBALT_SYSCALL(recvmmsg64, primary,
(int fd, struct mmsghdr __user *u_msgvec, unsigned int vlen,
unsigned int flags, struct __kernel_timespec __user *u_timeout))
{
return __rtdm_fd_recvmmsg64(fd, u_msgvec, vlen, flags, u_timeout,
get_mmsg, put_mmsg);
}
COBALT_SYSCALL(sendmsg, handover,
(int fd, struct user_msghdr __user *umsg, int flags))
{
......
......@@ -53,6 +53,11 @@ COBALT_SYSCALL_DECL(recvmmsg,
(int fd, struct mmsghdr __user *u_msgvec, unsigned int vlen,
unsigned int flags, struct __user_old_timespec __user *u_timeout));
COBALT_SYSCALL_DECL(recvmmsg64,
(int fd, struct mmsghdr __user *u_msgvec, unsigned int vlen,
unsigned int flags,
struct __kernel_timespec __user *u_timeout));
COBALT_SYSCALL_DECL(sendmsg,
(int fd, struct user_msghdr __user *umsg, int flags));
......
......@@ -860,6 +860,15 @@ COBALT_SYSCALL32emu(recvmmsg, primary,
get_timespec32);
}
COBALT_SYSCALL32emu(recvmmsg64, primary,
(int ufd, struct compat_mmsghdr __user *u_msgvec,
unsigned int vlen, unsigned int flags,
struct __kernel_timespec *u_timeout))
{
return __rtdm_fd_recvmmsg64(ufd, u_msgvec, vlen, flags, u_timeout,
get_mmsg32, put_mmsg32);
}
COBALT_SYSCALL32emu(sendmsg, handover,
(int fd, struct compat_msghdr __user *umsg, int flags))
{
......
......@@ -253,6 +253,12 @@ COBALT_SYSCALL32emu_DECL(recvmmsg,
unsigned int vlen,
unsigned int flags, struct old_timespec32 *u_timeout));
COBALT_SYSCALL32emu_DECL(recvmmsg64,
(int fd, struct compat_mmsghdr __user *u_msgvec,
unsigned int vlen,
unsigned int flags,
struct __kernel_timespec *u_timeout));
COBALT_SYSCALL32emu_DECL(sendmsg,
(int fd, struct compat_msghdr __user *umsg,
int flags));
......
......@@ -28,6 +28,7 @@
#include <cobalt/kernel/registry.h>
#include <cobalt/kernel/lock.h>
#include <cobalt/kernel/ppd.h>
#include <cobalt/kernel/time.h>
#include <pipeline/inband_work.h>
#include <trace/events/cobalt-rtdm.h>
#include <rtdm/fd.h>
......@@ -689,7 +690,7 @@ int __rtdm_fd_recvmmsg(int ufd, void __user *u_msgvec, unsigned int vlen,
if (ret)
goto fail;
if ((unsigned long)ts.tv_nsec >= ONE_BILLION) {
if (!timespec64_valid(&ts)) {
ret = -EINVAL;
goto fail;
}
......@@ -753,6 +754,24 @@ out:
return ret;
}
static inline int __rtdm_fetch_timeout64(struct timespec64 *ts,
const void __user *u_ts)
{
return u_ts == NULL ? -EFAULT : cobalt_get_timespec64(ts, u_ts);
}
int __rtdm_fd_recvmmsg64(int ufd, void __user *u_msgvec, unsigned int vlen,
unsigned int flags, void __user *u_timeout,
int (*get_mmsg)(struct mmsghdr *mmsg,
void __user *u_mmsg),
int (*put_mmsg)(void __user **u_mmsg_p,
const struct mmsghdr *mmsg))
{
return __rtdm_fd_recvmmsg(ufd, u_msgvec, vlen, flags, u_timeout,
get_mmsg, put_mmsg, __rtdm_fetch_timeout64);
}
ssize_t rtdm_fd_sendmsg(int ufd, const struct user_msghdr *msg, int flags)
{
struct rtdm_fd *fd;
......
......@@ -166,7 +166,8 @@
__cobalt_symbolic_syscall(mq_timedreceive64), \
__cobalt_symbolic_syscall(sigtimedwait64), \
__cobalt_symbolic_syscall(monitor_wait64), \
__cobalt_symbolic_syscall(event_wait64))
__cobalt_symbolic_syscall(event_wait64), \
__cobalt_symbolic_syscall(recvmmsg64))
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