* [PATCH] linux-user: support of semtimedop syscall
@ 2020-05-11 16:39 Matus Kysel
2020-05-11 18:59 ` Laurent Vivier
0 siblings, 1 reply; 2+ messages in thread
From: Matus Kysel @ 2020-05-11 16:39 UTC (permalink / raw)
Cc: open list:All patches CC here, Riku Voipio, Laurent Vivier,
Matus Kysel
We should add support of semtimedop syscall as new version of
glibc 2.31 uses semop based on semtimedop (commit: https://gitlab.com/freedesktop-sdk/mirrors/sourceware/glibc/-/commit/765cdd0bffd77960ae852104fc4ea5edcdb8aed3 ).
Signed-off-by: Matus Kysel <mkysel@tachyum.com>
---
linux-user/syscall.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3a924c0004..cb3978a2a5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3879,21 +3879,32 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf,
return 0;
}
-static inline abi_long do_semop(int semid, abi_long ptr, unsigned nsops)
+static inline abi_long do_semtimedop(int semid,
+ abi_long ptr,
+ unsigned nsops,
+ abi_long timeout)
{
struct sembuf sops[nsops];
+ struct timespec ts, *pts = NULL;
abi_long ret;
+ if (timeout) {
+ pts = &ts;
+ if (target_to_host_timespec(pts, timeout)) {
+ return -TARGET_EFAULT;
+ }
+ }
+
if (target_to_host_sembuf(sops, ptr, nsops))
return -TARGET_EFAULT;
ret = -TARGET_ENOSYS;
#ifdef __NR_semtimedop
- ret = get_errno(safe_semtimedop(semid, sops, nsops, NULL));
+ ret = get_errno(safe_semtimedop(semid, sops, nsops, pts));
#endif
#ifdef __NR_ipc
if (ret == -TARGET_ENOSYS) {
- ret = get_errno(safe_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, 0));
+ ret = get_errno(safe_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, pts));
}
#endif
return ret;
@@ -4373,7 +4384,8 @@ static abi_long do_ipc(CPUArchState *cpu_env,
switch (call) {
case IPCOP_semop:
- ret = do_semop(first, ptr, second);
+ case IPCOP_semtimedop:
+ ret = do_semtimedop(first, ptr, second, third);
break;
case IPCOP_semget:
@@ -9608,7 +9620,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_semop
case TARGET_NR_semop:
- return do_semop(arg1, arg2, arg3);
+ return do_semtimedop(arg1, arg2, arg3, 0);
+#endif
+#ifdef TARGET_NR_semtimedop
+ case TARGET_NR_semtimedop:
+ return do_semtimedop(arg1, arg2, arg3, arg4);
#endif
#ifdef TARGET_NR_semctl
case TARGET_NR_semctl:
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] linux-user: support of semtimedop syscall
2020-05-11 16:39 [PATCH] linux-user: support of semtimedop syscall Matus Kysel
@ 2020-05-11 18:59 ` Laurent Vivier
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2020-05-11 18:59 UTC (permalink / raw)
To: Matus Kysel; +Cc: Riku Voipio, open list:All patches CC here
Le 11/05/2020 à 18:39, Matus Kysel a écrit :
> We should add support of semtimedop syscall as new version of
> glibc 2.31 uses semop based on semtimedop (commit: https://gitlab.com/freedesktop-sdk/mirrors/sourceware/glibc/-/commit/765cdd0bffd77960ae852104fc4ea5edcdb8aed3 ).
>
> Signed-off-by: Matus Kysel <mkysel@tachyum.com>
> ---
> linux-user/syscall.c | 26 +++++++++++++++++++++-----
> 1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 3a924c0004..cb3978a2a5 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -3879,21 +3879,32 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf,
> return 0;
> }
>
> -static inline abi_long do_semop(int semid, abi_long ptr, unsigned nsops)
You should add around this function:
#if defined(TARGET_NR_ipc) || defined(TARGET_NR_semop) ||
defined(TARGET_NR_semtimedop)
> +static inline abi_long do_semtimedop(int semid,
> + abi_long ptr,
> + unsigned nsops,
> + abi_long timeout)
> {
> struct sembuf sops[nsops];
> + struct timespec ts, *pts = NULL;
> abi_long ret;
>
> + if (timeout) {
> + pts = &ts;
> + if (target_to_host_timespec(pts, timeout)) {
You should add the same #ifdef around target_to_host_timespec().
> + return -TARGET_EFAULT;
> + }
> + }
> +
> if (target_to_host_sembuf(sops, ptr, nsops))
> return -TARGET_EFAULT;
>
> ret = -TARGET_ENOSYS;
> #ifdef __NR_semtimedop
> - ret = get_errno(safe_semtimedop(semid, sops, nsops, NULL));
> + ret = get_errno(safe_semtimedop(semid, sops, nsops, pts));
> #endif
> #ifdef __NR_ipc
> if (ret == -TARGET_ENOSYS) {
> - ret = get_errno(safe_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, 0));
> + ret = get_errno(safe_ipc(IPCOP_semtimedop, semid, nsops, 0, sops, pts));
> }
> #endif
> return ret;
> @@ -4373,7 +4384,8 @@ static abi_long do_ipc(CPUArchState *cpu_env,
>
> switch (call) {
> case IPCOP_semop:
> - ret = do_semop(first, ptr, second);
> + case IPCOP_semtimedop:
> + ret = do_semtimedop(first, ptr, second, third);
Are you sure "third" is NULL in case of IPCOP_semop?
You should explicitly keep
ret = do_semtimedop(first, ptr, second, NULL);
for IPCOP_semop.
> break;
>
> case IPCOP_semget:
> @@ -9608,7 +9620,11 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
> #endif
> #ifdef TARGET_NR_semop
> case TARGET_NR_semop:
> - return do_semop(arg1, arg2, arg3);
> + return do_semtimedop(arg1, arg2, arg3, 0);
> +#endif
> +#ifdef TARGET_NR_semtimedop
> + case TARGET_NR_semtimedop:
> + return do_semtimedop(arg1, arg2, arg3, arg4);
> #endif
> #ifdef TARGET_NR_semctl
> case TARGET_NR_semctl:
>
Thanks,
LAurent
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-11 19:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-11 16:39 [PATCH] linux-user: support of semtimedop syscall Matus Kysel
2020-05-11 18:59 ` Laurent Vivier
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).