All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bezdeka, Florian" <florian.bezdeka@siemens.com>
To: "xenomai@xenomai.org" <xenomai@xenomai.org>,
	"chensong_2000@189.cn" <chensong_2000@189.cn>
Subject: Re: [PATCH v4 1/3] y2038: cobalt/posix/io: Adding recvmmsg64
Date: Mon, 4 Oct 2021 15:03:43 +0000	[thread overview]
Message-ID: <9ac4286e981103498e54c837b19dc9914fd5c5ed.camel@siemens.com> (raw)
In-Reply-To: <1632968534-18561-1-git-send-email-chensong_2000@189.cn>

On Thu, 2021-09-30 at 10:22 +0800, Song Chen wrote:
> 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
> 
> Signed-off-by: Song Chen <chensong_2000@189.cn>
> ---
>  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(-)
> 
> diff --git a/include/cobalt/kernel/rtdm/fd.h b/include/cobalt/kernel/rtdm/fd.h
> index 37a09c4..4dc67e5 100644
> --- a/include/cobalt/kernel/rtdm/fd.h
> +++ b/include/cobalt/kernel/rtdm/fd.h
> @@ -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);
>  
> diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h
> index 16edce1..1523ddd 100644
> --- a/include/cobalt/uapi/syscall.h
> +++ b/include/cobalt/uapi/syscall.h
> @@ -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...

>  
>  #define __NR_COBALT_SYSCALLS			128 /* Power of 2 */
>  
> diff --git a/kernel/cobalt/posix/io.c b/kernel/cobalt/posix/io.c
> index 0c17f55..595bf67 100644
> --- a/kernel/cobalt/posix/io.c
> +++ b/kernel/cobalt/posix/io.c
> @@ -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))
>  {
> diff --git a/kernel/cobalt/posix/io.h b/kernel/cobalt/posix/io.h
> index d9f29fa..842db08 100644
> --- a/kernel/cobalt/posix/io.h
> +++ b/kernel/cobalt/posix/io.h
> @@ -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));
>  
> diff --git a/kernel/cobalt/posix/syscall32.c b/kernel/cobalt/posix/syscall32.c
> index 2d88fac..15a2d22 100644
> --- a/kernel/cobalt/posix/syscall32.c
> +++ b/kernel/cobalt/posix/syscall32.c
> @@ -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))
>  {
> diff --git a/kernel/cobalt/posix/syscall32.h b/kernel/cobalt/posix/syscall32.h
> index 3eb6657..72e32f4 100644
> --- a/kernel/cobalt/posix/syscall32.h
> +++ b/kernel/cobalt/posix/syscall32.h
> @@ -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));
> diff --git a/kernel/cobalt/rtdm/fd.c b/kernel/cobalt/rtdm/fd.c
> index 8e4e15e..91c3757 100644
> --- a/kernel/cobalt/rtdm/fd.c
> +++ b/kernel/cobalt/rtdm/fd.c
> @@ -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;


      parent reply	other threads:[~2021-10-04 15:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-30  2:22 [PATCH v4 1/3] y2038: cobalt/posix/io: Adding recvmmsg64 Song Chen
2021-10-01 10:15 ` Bezdeka, Florian
2021-10-04 15:03 ` Bezdeka, Florian [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9ac4286e981103498e54c837b19dc9914fd5c5ed.camel@siemens.com \
    --to=florian.bezdeka@siemens.com \
    --cc=chensong_2000@189.cn \
    --cc=xenomai@xenomai.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.