[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/18] linux-user: Add support for 'rt_sigtimedwait_time64()' and
From: |
Laurent Vivier |
Subject: |
[PULL 17/18] linux-user: Add support for 'rt_sigtimedwait_time64()' and 'sched_rr_get_interval_time64()' |
Date: |
Thu, 27 Aug 2020 21:20:17 +0200 |
From: Filip Bozuta <Filip.Bozuta@syrmia.com>
This patch implements functionality for following time64 syscalls:
*rt_sigtimedwait_time64()
This is a year 2038 safe variant of syscall:
int rt_sigtimedwait(const sigset_t *set, siginfo_t *info,
const struct timespec *timeout, size_t sigsetsize)
--synchronously wait for queued signals--
man page: https://man7.org/linux/man-pages/man2/rt_sigtimedwait.2.html
*sched_rr_get_interval_time64()
This is a year 2038 safe variant of syscall:
int sched_rr_get_interval(pid_t pid, struct timespec *tp)
--get the SCHED_RR interval for the named process--
man page: https://man7.org/linux/man-pages/man2/sched_rr_get_interval.2.html
Implementation notes:
These syscalls were implemented in similar ways like
'rt_sigtimedwait()' and 'sched_rr_get_interval()' except
that functions 'target_to_host_timespec64()' and
'host_to_target_timespec64()' were used to convert values
of 'struct timespec' between host and target.
Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20200824192116.65562-3-Filip.Bozuta@syrmia.com>
[lv: add missing defined(TARGET_NR_rt_sigtimedwait_time64)]
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
linux-user/syscall.c | 58 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 82414c08d655..9d7376734ad4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -764,7 +764,7 @@ safe_syscall6(ssize_t, recvfrom, int, fd, void *, buf,
size_t, len,
safe_syscall3(ssize_t, sendmsg, int, fd, const struct msghdr *, msg, int,
flags)
safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags)
safe_syscall2(int, flock, int, fd, int, operation)
-#ifdef TARGET_NR_rt_sigtimedwait
+#if defined(TARGET_NR_rt_sigtimedwait) ||
defined(TARGET_NR_rt_sigtimedwait_time64)
safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *,
uinfo,
const struct timespec *, uts, size_t, sigsetsize)
#endif
@@ -1241,7 +1241,8 @@ static inline abi_long target_to_host_timespec(struct
timespec *host_ts,
defined(TARGET_NR_mq_timedsend_time64) || \
defined(TARGET_NR_mq_timedreceive_time64) || \
(defined(TARGET_NR_timerfd_settime64) && defined(CONFIG_TIMERFD)) || \
- defined(TARGET_NR_clock_nanosleep_time64)
+ defined(TARGET_NR_clock_nanosleep_time64) || \
+ defined(TARGET_NR_rt_sigtimedwait_time64)
static inline abi_long target_to_host_timespec64(struct timespec *host_ts,
abi_ulong target_addr)
{
@@ -9042,6 +9043,48 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
}
}
return ret;
+#endif
+#ifdef TARGET_NR_rt_sigtimedwait_time64
+ case TARGET_NR_rt_sigtimedwait_time64:
+ {
+ sigset_t set;
+ struct timespec uts, *puts;
+ siginfo_t uinfo;
+
+ if (arg4 != sizeof(target_sigset_t)) {
+ return -TARGET_EINVAL;
+ }
+
+ p = lock_user(VERIFY_READ, arg1, sizeof(target_sigset_t), 1);
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ target_to_host_sigset(&set, p);
+ unlock_user(p, arg1, 0);
+ if (arg3) {
+ puts = &uts;
+ if (target_to_host_timespec64(puts, arg3)) {
+ return -TARGET_EFAULT;
+ }
+ } else {
+ puts = NULL;
+ }
+ ret = get_errno(safe_rt_sigtimedwait(&set, &uinfo, puts,
+ SIGSET_T_SIZE));
+ if (!is_error(ret)) {
+ if (arg2) {
+ p = lock_user(VERIFY_WRITE, arg2,
+ sizeof(target_siginfo_t), 0);
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ host_to_target_siginfo(p, &uinfo);
+ unlock_user(p, arg2, sizeof(target_siginfo_t));
+ }
+ ret = host_to_target_signal(ret);
+ }
+ }
+ return ret;
#endif
case TARGET_NR_rt_sigqueueinfo:
{
@@ -10566,6 +10609,17 @@ static abi_long do_syscall1(void *cpu_env, int num,
abi_long arg1,
}
return ret;
#endif
+#ifdef TARGET_NR_sched_rr_get_interval_time64
+ case TARGET_NR_sched_rr_get_interval_time64:
+ {
+ struct timespec ts;
+ ret = get_errno(sched_rr_get_interval(arg1, &ts));
+ if (!is_error(ret)) {
+ ret = host_to_target_timespec64(arg2, &ts);
+ }
+ }
+ return ret;
+#endif
#if defined(TARGET_NR_nanosleep)
case TARGET_NR_nanosleep:
{
--
2.26.2
- [PULL 01/18] linux-user: Fix 'semop()' and 'semtimedop()' implementation, (continued)
- [PULL 01/18] linux-user: Fix 'semop()' and 'semtimedop()' implementation, Laurent Vivier, 2020/08/27
- [PULL 02/18] linux-user: Fix 'clock_nanosleep()' implementation, Laurent Vivier, 2020/08/27
- [PULL 07/18] linux-user: Add an api to print enumareted argument values with strace, Laurent Vivier, 2020/08/27
- [PULL 03/18] linux-user: syscall: ioctls: support DRM_IOCTL_I915_GETPARAM, Laurent Vivier, 2020/08/27
- [PULL 04/18] linux-user: Make cpu_env accessible in strace.c, Laurent Vivier, 2020/08/27
- [PULL 05/18] linux-user: Add strace support for printing arguments of truncate()/ftruncate() and getsid(), Laurent Vivier, 2020/08/27
- [PULL 09/18] linux-user: Add generic 'termbits.h' for some archs, Laurent Vivier, 2020/08/27
- [PULL 14/18] linux-user: fix target_to_host_timespec64(), Laurent Vivier, 2020/08/27
- [PULL 08/18] linux-user: Add strace support for printing arguments of some clock and time functions, Laurent Vivier, 2020/08/27
- [PULL 06/18] linux-user: Add strace support for printing arguments of syscalls used to lock and unlock memory, Laurent Vivier, 2020/08/27
- [PULL 17/18] linux-user: Add support for 'rt_sigtimedwait_time64()' and 'sched_rr_get_interval_time64()',
Laurent Vivier <=
- [PULL 12/18] linux-user: detect mismatched ELF ABI in qemu-mips[n32][el], Laurent Vivier, 2020/08/27
- [PULL 15/18] linux-user: Add support for 'mq_timedsend_time64()' and 'mq_timedreceive_time64()', Laurent Vivier, 2020/08/27
- [PULL 11/18] linux-user: Add strace support for printing arguments for ioctls used for terminals and serial lines, Laurent Vivier, 2020/08/27
- [PULL 16/18] linux-user: Add support for 'clock_nanosleep_time64()' and 'clock_adjtime64()', Laurent Vivier, 2020/08/27
- [PULL 10/18] linux-user: Add missing termbits types and values definitions, Laurent Vivier, 2020/08/27
- [PULL 13/18] linux-user: Fix 'mq_timedsend()' and 'mq_timedreceive()', Laurent Vivier, 2020/08/27
- [PULL 18/18] linux-user: Add support for utimensat_time64() and semtimedop_time64(), Laurent Vivier, 2020/08/27
- Re: [PULL 00/18] Linux user for 5.2 patches, Peter Maydell, 2020/08/28
- [PULL 00/18] Linux user for 5.2 patches, Laurent Vivier, 2020/08/28