y2038: cobalt/posix/io: Adding recvmmsg64
PATCH v4 1/3 y2038: cobalt/posix/io: Adding recvmmsg64
Add a syscall specific for recvmmsg64 with 64bit time_t.
---
v2:
1, adjust indentation, different files have different indentation, see
./kernel/cobalt/posix/io.h ./kernel/cobalt/posix/syscall32.h
I followed the function definition around mine
2, remove duplicated helper get_timespec64_xeno
get_timespec64 is defined in vanilla kernel, that's why suffix _xeno, but it still looks weired, it does nothing but just call cobalt_get_timespec64, so why not call cobalt_get_timespec64 directly with a little change of its definition.
v3:
1, undo #2 in v2, instead, introduce __rtdm_fd_recvmmsg64
--- include/cobalt/kernel/rtdm/fd.h | 5 +++++ include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/io.c | 9 +++++++++ kernel/cobalt/posix/io.h | 5 +++++ kernel/cobalt/posix/syscall32.c | 9 +++++++++ kernel/cobalt/posix/syscall32.h | 6 ++++++ kernel/cobalt/rtdm/fd.c | 19 ++++++++++++++++++- 7 files changed, 53 insertions(+), 1 deletion(-)
include/cobalt/kernel/rtdm/fd.h +5 -0
@@ -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);
include/cobalt/uapi/syscall.h +1 -0
@@ -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 */
kernel/cobalt/posix/io.c +9 -0
@@ -26,6 +26,7 @@#include "internal.h" #include "clock.h" #include "io.h" +#include <cobalt/kernel/time.h> COBALT_SYSCALL (open, lostage, (const char __user *u_path, int oflag))
@@ -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)) {
kernel/cobalt/posix/io.h +5 -0
@@ -58,6 +58,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));
kernel/cobalt/posix/syscall32.c +9 -0
@@ -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)) {
kernel/cobalt/posix/syscall32.h +6 -0
@@ -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));
kernel/cobalt/rtdm/fd.c +18 -1
@@ -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,22 @@ 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;
Signature · 1 line
2.7.4
Hi Song!
Quoted 14 lines · Song Chen
Add a syscall specific for recvmmsg64 with 64bit
time_t.---
v2:
1, adjust indentation, different files have different indentation, see
./kernel/cobalt/posix/io.h./kernel/cobalt/posix/syscall32.h
I followed the function definition around mine
2, remove duplicated helperget_timespec64_xeno
get_timespec64is defined in vanilla kernel, that's why suffix_xeno, but it still looks weired, it does nothing but just callcobalt_get_timespec64, so why not callcobalt_get_timespec64directly with a little change of its definition.
Quoted 4 lines
v3:
1, undo #2 in v2, instead, introduce__rtdm_fd_recvmmsg64Signed-off-by Song Chen <[email protected]>
That's the wrong place for the Signed-off-by tag. I will fix that up (as well as some code formatting issues this patch has) during pre- merge. The problem here is that the Signed-off-by tag is not part of the commit message, so it's not getting part of the git history.
No further action required on your side but please note the comments below.
Quoted 51 lines
--- include/cobalt/kernel/rtdm/fd.h | 5 +++++ include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/io.c | 9 +++++++++ kernel/cobalt/posix/io.h | 5 +++++ kernel/cobalt/posix/syscall32.c | 9 +++++++++ kernel/cobalt/posix/syscall32.h | 6 ++++++ kernel/cobalt/rtdm/fd.c | 19 ++++++++++++++++++- 7 files changed, 53 insertions(+), 1 deletion(-)include/cobalt/kernel/rtdm/fd.h +5
-0@@ -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);include/cobalt/uapi/syscall.h +1
-0@@ -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 */ kernel/cobalt/posix/io.c +1
-0@@ -26,6 +26,7 @@#include "internal.h" #include "clock.h" #include "io.h" +#include <cobalt/kernel/time.h> COBALT_SYSCALL (open, lostage, (const char __user *u_path, int oflag))
kernel/cobalt/posix/io.c COBALT_SYSCALL(recvmmsg, primary, · line 130
Quoted 9 lines
kernel/cobalt/posix/io.c +6
-0@@ -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);
Style: Arguments are not aligned.
Quoted 10 lines
kernel/cobalt/posix/io.c +2
-0+} +COBALT_SYSCALL (sendmsg, handover, (int fd, struct user_msghdr __user *umsg, int flags)) {kernel/cobalt/posix/io.h +0
-0
kernel/cobalt/posix/io.h COBALT_SYSCALL_DECL(recvmmsg, · line 62
Quoted 5 lines
kernel/cobalt/posix/io.h +2
-0@@ -58,6 +58,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,
Style: Arguments or brackets are not aligned in the way other COBALT_SYSCALL_DECL usage in this file are.
Quoted 11 lines
kernel/cobalt/posix/io.h +3
-0+unsigned int flags, + struct __kernel_timespec __user *u_timeout)); +COBALT_SYSCALL_DECL (sendmsg, (int fd, struct user_msghdr __user *umsg, int flags));kernel/cobalt/posix/syscall32.c +0
-0
kernel/cobalt/posix/syscall32.c COBALT_SYSCALL32emu(recvmmsg, primary, · line 866
Quoted 7 lines
kernel/cobalt/posix/syscall32.c +4
-0@@ -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))
Style: See other COBALT_SYSCALL32emu usages in the same file. Alignement...
kernel/cobalt/posix/syscall32.c COBALT_SYSCALL32emu(recvmmsg, primary, · line 869
Quoted 3 lines
kernel/cobalt/posix/syscall32.c +3
-0+{ +return __rtdm_fd_recvmmsg64 (ufd, u_msgvec, vlen, flags, u_timeout, + get_mmsg32, put_mmsg32);
Style: arguments not aligned
Quoted 47 lines
kernel/cobalt/posix/syscall32.c +2
-0+} +COBALT_SYSCALL32emu (sendmsg, handover, (int fd, struct compat_msghdr __user *umsg, int flags)) {kernel/cobalt/posix/syscall32.h +6
-0@@ -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));kernel/cobalt/rtdm/fd.c +2
-1@@ -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,22 @@ out:return ret; }
kernel/cobalt/rtdm/fd.c out: · line 766
Quoted 10 lines
kernel/cobalt/rtdm/fd.c +10
-0+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))
Style: Arguments not aligned.
Quoted 9 lines
kernel/cobalt/rtdm/fd.c +6
-0+{ +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;
Quoted 49 lines · Song Chen
Add a syscall specific for recvmmsg64 with 64bit
time_t.---
v2:
1, adjust indentation, different files have different indentation, see
./kernel/cobalt/posix/io.h./kernel/cobalt/posix/syscall32.h
I followed the function definition around mine
2, remove duplicated helperget_timespec64_xeno
get_timespec64is defined in vanilla kernel, that's why suffix_xeno, but it still looks weired, it does nothing but just callcobalt_get_timespec64, so why not callcobalt_get_timespec64directly with a little change of its definition.v3:
1, undo #2 in v2, instead, introduce__rtdm_fd_recvmmsg64Signed-off-by Song Chen <[email protected]>--- include/cobalt/kernel/rtdm/fd.h | 5 +++++ include/cobalt/uapi/syscall.h | 1 + kernel/cobalt/posix/io.c | 9 +++++++++ kernel/cobalt/posix/io.h | 5 +++++ kernel/cobalt/posix/syscall32.c | 9 +++++++++ kernel/cobalt/posix/syscall32.h | 6 ++++++ kernel/cobalt/rtdm/fd.c | 19 ++++++++++++++++++- 7 files changed, 53 insertions(+), 1 deletion(-)include/cobalt/kernel/rtdm/fd.h +5
-0@@ -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);include/cobalt/uapi/syscall.h +0
-0
include/cobalt/uapi/syscall.h line 137
Quoted 4 lines
include/cobalt/uapi/syscall.h +1
-0@@ -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
Whenever you add something here don't forget to update the definition of __cobalt_syscall_name in cobalt-posix.h (tracing infrastructure)
I will fix that up for recmmsg64 but please make sure it's not missing in further y2038 patches. It takes some time to debug that...
Quoted 127 lines
include/cobalt/uapi/syscall.h +0
-0#define __NR_COBALT_SYSCALLS 128/* Power of 2 */ kernel/cobalt/posix/io.c +9
-0@@ -26,6 +26,7 @@#include "internal.h" #include "clock.h" #include "io.h" +#include <cobalt/kernel/time.h> COBALT_SYSCALL (open, lostage, (const char __user *u_path, int oflag))@@ -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)) {kernel/cobalt/posix/io.h +5
-0@@ -58,6 +58,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));kernel/cobalt/posix/syscall32.c +9
-0@@ -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)) {kernel/cobalt/posix/syscall32.h +6
-0@@ -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));kernel/cobalt/rtdm/fd.c +18
-1@@ -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,22 @@ 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;