From: Filip Bozuta <Filip.Bozuta@syrmia.com>
To: qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>,
Laurent Vivier <laurent@vivier.eu>,
Filip Bozuta <Filip.Bozuta@syrmia.com>
Subject: [PATCH 3/3] linux-user: Add support for 'recvmmsg_time64()'
Date: Fri, 31 Jul 2020 21:06:37 +0200 [thread overview]
Message-ID: <20200731190637.66698-4-Filip.Bozuta@syrmia.com> (raw)
In-Reply-To: <20200731190637.66698-1-Filip.Bozuta@syrmia.com>
This patch introduces functionality for syscall:
*recvmmsg_time64
This syscall is a 2038 safe variant for syscall:
int recvmmsg(int sockfd, struct mmsghdr *msgvec, unsigned int vlen,
int flags, struct timespec *timeout)
--receive multiple messages on a socket--
man page: https://man7.org/linux/man-pages/man2/recvmmsg.2.html
Implementation notes:
Function 'do_sendrecvmmsg()' in 'syscall.c' was changed with the
addition of a new argument 'time64' which represents a flag by
which the function knows what kind of 'struct timespec' converting
function to call ('target_to_host_timespec() or
'target_to_host_timespec64()'). It is 0 in case of 'TARGET_NR_recvmmsg'
and 1 in case of 'TARGET_NR_recvmmsg_time64'.
In 'do_socketcall()', the 'TARGET_ABI_BITS' was checked to know
what value for 'time64' argument to pass (0 if 'TARGET_ABI_BITS == 32'
and 1 otherwise).
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
---
linux-user/syscall.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 420d7e7334..ed9c2cb7ab 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3217,7 +3217,7 @@ static abi_long do_sendrecvmsg(int fd, abi_ulong target_msg,
static abi_long do_sendrecvmmsg(int fd, abi_ulong target_msgvec_addr,
unsigned int vlen, unsigned int flags,
- abi_long timeout, int send)
+ abi_long timeout, int time64, int send)
{
struct mmsghdr *host_msgvec;
struct target_mmsghdr *target_msgvec;
@@ -3277,7 +3277,10 @@ static abi_long do_sendrecvmmsg(int fd, abi_ulong target_msgvec_addr,
ret = get_errno(safe_sendmmsg(fd, host_msgvec, i, flags));
} else {
if (timeout) {
- if (target_to_host_timespec(&ts, timeout)) {
+ if (!time64 && target_to_host_timespec(&ts, timeout)) {
+ return -TARGET_EFAULT;
+ }
+ if (time64 && target_to_host_timespec64(&ts, timeout)) {
return -TARGET_EFAULT;
}
ret = get_errno(safe_recvmmsg(fd, host_msgvec, i, flags, &ts));
@@ -3619,10 +3622,14 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
return do_sendrecvmsg(a[0], a[1], a[2], 0);
case TARGET_SYS_ACCEPT4: /* sockfd, addr, addrlen, flags */
return do_accept4(a[0], a[1], a[2], a[3]);
- case TARGET_SYS_RECVMMSG: /* sockfd, msgvec, vlen, timeout, flags */
- return do_sendrecvmmsg(a[0], a[1], a[2], a[3], a[4], 0);
+ case TARGET_SYS_RECVMMSG: /* sockfd, msgvec, vlen, flags, timeout, */
+#if TARGET_ABI_BITS == 32
+ return do_sendrecvmmsg(a[0], a[1], a[2], a[3], a[4], 0, 0);
+#else
+ return do_sendrecvmmsg(a[0], a[1], a[2], a[3], a[4], 1, 0);
+#endif
case TARGET_SYS_SENDMMSG: /* sockfd, msgvec, vlen, flags */
- return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0, 1);
+ return do_sendrecvmmsg(a[0], a[1], a[2], a[3], 0, 0, 1);
default:
qemu_log_mask(LOG_UNIMP, "Unsupported socketcall: %d\n", num);
return -TARGET_EINVAL;
@@ -9426,11 +9433,15 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_sendmmsg
case TARGET_NR_sendmmsg:
- return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0, 1);
+ return do_sendrecvmmsg(arg1, arg2, arg3, arg4, 0, 0, 1);
#endif
#ifdef TARGET_NR_recvmmsg
case TARGET_NR_recvmmsg:
- return do_sendrecvmmsg(arg1, arg2, arg3, arg4, arg5, 0);
+ return do_sendrecvmmsg(arg1, arg2, arg3, arg4, arg5, 0, 0);
+#endif
+#ifdef TARGET_NR_recvmmsg_time64
+ case TARGET_NR_recvmmsg_time64:
+ return do_sendrecvmmsg(arg1, arg2, arg3, arg4, arg5, 1, 0);
#endif
#ifdef TARGET_NR_sendto
case TARGET_NR_sendto:
--
2.25.1
prev parent reply other threads:[~2020-07-31 19:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-31 19:06 [PATCH 0/3] linux-user: Introducing support for 'recvmmsg_time64()' Filip Bozuta
2020-07-31 19:06 ` [PATCH 1/3] linux-user: Modify 'sendmmsg()' and 'recvmmsg()' implementation Filip Bozuta
2020-08-24 20:11 ` Laurent Vivier
2020-07-31 19:06 ` [PATCH 2/3] linux-user: Fix " Filip Bozuta
2020-07-31 19:06 ` Filip Bozuta [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=20200731190637.66698-4-Filip.Bozuta@syrmia.com \
--to=filip.bozuta@syrmia.com \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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 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).