Refactoring ipc syscall for s390x and SPARC, so it matches glibc implementation
Signed-off-by: Matus Kysel <mkysel@tachyum.com>
---
linux-user/syscall.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 97de9fb5c9..990412733b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -814,9 +814,14 @@ safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags,
const struct timespec *, req, struct timespec *, rem)
#endif
#ifdef __NR_ipc
+#ifdef __s390x__
+safe_syscall5(int, ipc, int, call, long, first, long, second, long, third,
+ void *, ptr)
+#else
safe_syscall6(int, ipc, int, call, long, first, long, second, long, third,
void *, ptr, long, fifth)
#endif
+#endif
#ifdef __NR_msgsnd
safe_syscall4(int, msgsnd, int, msgid, const void *, msgp, size_t, sz,
int, flags)
@@ -4053,8 +4058,13 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
#endif
#ifdef __NR_ipc
if (ret == -TARGET_ENOSYS) {
+#ifdef __s390x__
+ ret = get_errno(safe_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg,
+ host_mb));
+#else
ret = get_errno(safe_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg,
host_mb, 0));
+#endif
}
#endif
g_free(host_mb);
@@ -4063,6 +4073,20 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
return ret;
}
+#ifdef __NR_ipc
+#if defined(__sparc__)
+/* SPARC for msgrcv it does not use the kludge on final 2 arguments. */
+#define MSGRCV_ARGS(__msgp, __msgtyp) __msgp, __msgtyp
+#elif defined(__s390x__)
+/* The s390 sys_ipc variant has only five parameters. */
+#define MSGRCV_ARGS(__msgp, __msgtyp) \
+ ((long int[]){(long int)__msgp, __msgtyp})
+#else
+#define MSGRCV_ARGS(__msgp, __msgtyp) \
+ ((long int[]){(long int)__msgp, __msgtyp}), 0
+#endif
+#endif
+
static inline abi_long do_msgrcv(int msqid, abi_long msgp,
ssize_t msgsz, abi_long msgtyp,
int msgflg)
@@ -4091,7 +4115,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
#ifdef __NR_ipc
if (ret == -TARGET_ENOSYS) {
ret = get_errno(safe_ipc(IPCOP_CALL(1, IPCOP_msgrcv), msqid, msgsz,
- msgflg, host_mb, msgtyp));
+ msgflg, MSGRCV_ARGS(host_mb, msgtyp)));
}
#endif
--
2.17.1
Le 26/06/2020 à 14:46, Matus Kysel a écrit :
> Refactoring ipc syscall for s390x and SPARC, so it matches glibc implementation
>
> Signed-off-by: Matus Kysel <mkysel@tachyum.com>
> ---
> linux-user/syscall.c | 26 +++++++++++++++++++++++++-
> 1 file changed, 25 insertions(+), 1 deletion(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 97de9fb5c9..990412733b 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -814,9 +814,14 @@ safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags,
> const struct timespec *, req, struct timespec *, rem)
> #endif
> #ifdef __NR_ipc
> +#ifdef __s390x__
> +safe_syscall5(int, ipc, int, call, long, first, long, second, long, third,
> + void *, ptr)
> +#else
> safe_syscall6(int, ipc, int, call, long, first, long, second, long, third,
> void *, ptr, long, fifth)
> #endif
> +#endif
> #ifdef __NR_msgsnd
> safe_syscall4(int, msgsnd, int, msgid, const void *, msgp, size_t, sz,
> int, flags)
> @@ -4053,8 +4058,13 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
> #endif
> #ifdef __NR_ipc
> if (ret == -TARGET_ENOSYS) {
> +#ifdef __s390x__
> + ret = get_errno(safe_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg,
> + host_mb));
> +#else
> ret = get_errno(safe_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg,
> host_mb, 0));
> +#endif
> }
> #endif
> g_free(host_mb);
> @@ -4063,6 +4073,20 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
> return ret;
> }
>
> +#ifdef __NR_ipc
> +#if defined(__sparc__)
> +/* SPARC for msgrcv it does not use the kludge on final 2 arguments. */
> +#define MSGRCV_ARGS(__msgp, __msgtyp) __msgp, __msgtyp
> +#elif defined(__s390x__)
> +/* The s390 sys_ipc variant has only five parameters. */
> +#define MSGRCV_ARGS(__msgp, __msgtyp) \
> + ((long int[]){(long int)__msgp, __msgtyp})
> +#else
> +#define MSGRCV_ARGS(__msgp, __msgtyp) \
> + ((long int[]){(long int)__msgp, __msgtyp}), 0
> +#endif
> +#endif
> +
> static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> ssize_t msgsz, abi_long msgtyp,
> int msgflg)
> @@ -4091,7 +4115,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
> #ifdef __NR_ipc
> if (ret == -TARGET_ENOSYS) {
> ret = get_errno(safe_ipc(IPCOP_CALL(1, IPCOP_msgrcv), msqid, msgsz,
> - msgflg, host_mb, msgtyp));
> + msgflg, MSGRCV_ARGS(host_mb, msgtyp)));
> }
> #endif
>
>
This patch breaks build because there is safe_ipc() that is not updated
to use only 5 arguments with s390x. This is updated in the next patch so
the build in the end works, but it breaks bisect so you should fix that.
Otherwise:
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Thanks,
Laurent
Le 10/07/2020 à 14:46, Laurent Vivier a écrit :
> Le 26/06/2020 à 14:46, Matus Kysel a écrit :
>> Refactoring ipc syscall for s390x and SPARC, so it matches glibc implementation
>>
>> Signed-off-by: Matus Kysel <mkysel@tachyum.com>
>> ---
>> linux-user/syscall.c | 26 +++++++++++++++++++++++++-
>> 1 file changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index 97de9fb5c9..990412733b 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -814,9 +814,14 @@ safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags,
>> const struct timespec *, req, struct timespec *, rem)
>> #endif
>> #ifdef __NR_ipc
>> +#ifdef __s390x__
>> +safe_syscall5(int, ipc, int, call, long, first, long, second, long, third,
>> + void *, ptr)
>> +#else
>> safe_syscall6(int, ipc, int, call, long, first, long, second, long, third,
>> void *, ptr, long, fifth)
>> #endif
>> +#endif
>> #ifdef __NR_msgsnd
>> safe_syscall4(int, msgsnd, int, msgid, const void *, msgp, size_t, sz,
>> int, flags)
>> @@ -4053,8 +4058,13 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
>> #endif
>> #ifdef __NR_ipc
>> if (ret == -TARGET_ENOSYS) {
>> +#ifdef __s390x__
>> + ret = get_errno(safe_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg,
>> + host_mb));
>> +#else
>> ret = get_errno(safe_ipc(IPCOP_msgsnd, msqid, msgsz, msgflg,
>> host_mb, 0));
>> +#endif
>> }
>> #endif
>> g_free(host_mb);
>> @@ -4063,6 +4073,20 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
>> return ret;
>> }
>>
>> +#ifdef __NR_ipc
>> +#if defined(__sparc__)
>> +/* SPARC for msgrcv it does not use the kludge on final 2 arguments. */
>> +#define MSGRCV_ARGS(__msgp, __msgtyp) __msgp, __msgtyp
>> +#elif defined(__s390x__)
>> +/* The s390 sys_ipc variant has only five parameters. */
>> +#define MSGRCV_ARGS(__msgp, __msgtyp) \
>> + ((long int[]){(long int)__msgp, __msgtyp})
>> +#else
>> +#define MSGRCV_ARGS(__msgp, __msgtyp) \
>> + ((long int[]){(long int)__msgp, __msgtyp}), 0
>> +#endif
>> +#endif
>> +
>> static inline abi_long do_msgrcv(int msqid, abi_long msgp,
>> ssize_t msgsz, abi_long msgtyp,
>> int msgflg)
>> @@ -4091,7 +4115,7 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
>> #ifdef __NR_ipc
>> if (ret == -TARGET_ENOSYS) {
>> ret = get_errno(safe_ipc(IPCOP_CALL(1, IPCOP_msgrcv), msqid, msgsz,
>> - msgflg, host_mb, msgtyp));
>> + msgflg, MSGRCV_ARGS(host_mb, msgtyp)));
>> }
>> #endif
>>
>>
>
> This patch breaks build because there is safe_ipc() that is not updated
> to use only 5 arguments with s390x. This is updated in the next patch so
> the build in the end works, but it breaks bisect so you should fix that.
>
> Otherwise:
>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
>
> Thanks,
> Laurent
>
I have merged PATH 1 and 2 and applied to my linux-user-for-5.1 branch.
Thanks,
Laurent
© 2016 - 2026 Red Hat, Inc.