* [PATCH v3] linux-user: Adjust child_tidptr on set_tid_address() syscall
@ 2022-05-28 10:52 Helge Deller
2022-06-21 18:26 ` Laurent Vivier
2022-06-21 18:33 ` Laurent Vivier
0 siblings, 2 replies; 3+ messages in thread
From: Helge Deller @ 2022-05-28 10:52 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Richard Henderson
Keep track of the new child tidptr given by a set_tid_address() syscall.
Do not call the host set_tid_address() syscall because we are emulating
the behaviour of writing to child_tidptr in the exit() path.
Signed-off-by: Helge Deller<deller@gmx.de>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
--
v3:
- Respin of the patch because the v2 version was mungled in-between the
mail of the v1 version. Now it's possible to get correct patch with b4
- Rephrased commit message
- Added Richard's Reviewed-by
v2:
- was mungled in v1 mail thread
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f55cdebee5..1166e9f014 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -320,9 +320,6 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
#ifdef __NR_exit_group
_syscall1(int,exit_group,int,error_code)
#endif
-#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
-_syscall1(int,set_tid_address,int *,tidptr)
-#endif
#if defined(__NR_futex)
_syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -12200,9 +12197,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
}
#endif
-#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
+#if defined(TARGET_NR_set_tid_address)
case TARGET_NR_set_tid_address:
- return get_errno(set_tid_address((int *)g2h(cpu, arg1)));
+ {
+ TaskState *ts = cpu->opaque;
+ ts->child_tidptr = arg1;
+ /* do not call host set_tid_address() syscall, instead return tid() */
+ return get_errno(sys_gettid());
+ }
#endif
case TARGET_NR_tkill:
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] linux-user: Adjust child_tidptr on set_tid_address() syscall
2022-05-28 10:52 [PATCH v3] linux-user: Adjust child_tidptr on set_tid_address() syscall Helge Deller
@ 2022-06-21 18:26 ` Laurent Vivier
2022-06-21 18:33 ` Laurent Vivier
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2022-06-21 18:26 UTC (permalink / raw)
To: Helge Deller, qemu-devel; +Cc: Richard Henderson
Le 28/05/2022 à 12:52, Helge Deller a écrit :
> Keep track of the new child tidptr given by a set_tid_address() syscall.
>
> Do not call the host set_tid_address() syscall because we are emulating
> the behaviour of writing to child_tidptr in the exit() path.
>
> Signed-off-by: Helge Deller<deller@gmx.de>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
> --
> v3:
> - Respin of the patch because the v2 version was mungled in-between the
> mail of the v1 version. Now it's possible to get correct patch with b4
> - Rephrased commit message
> - Added Richard's Reviewed-by
> v2:
> - was mungled in v1 mail thread
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index f55cdebee5..1166e9f014 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -320,9 +320,6 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
> #ifdef __NR_exit_group
> _syscall1(int,exit_group,int,error_code)
> #endif
> -#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
> -_syscall1(int,set_tid_address,int *,tidptr)
> -#endif
> #if defined(__NR_futex)
> _syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
> const struct timespec *,timeout,int *,uaddr2,int,val3)
> @@ -12200,9 +12197,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
> }
> #endif
>
> -#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
> +#if defined(TARGET_NR_set_tid_address)
> case TARGET_NR_set_tid_address:
> - return get_errno(set_tid_address((int *)g2h(cpu, arg1)));
> + {
> + TaskState *ts = cpu->opaque;
> + ts->child_tidptr = arg1;
> + /* do not call host set_tid_address() syscall, instead return tid() */
> + return get_errno(sys_gettid());
> + }
> #endif
>
> case TARGET_NR_tkill:
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] linux-user: Adjust child_tidptr on set_tid_address() syscall
2022-05-28 10:52 [PATCH v3] linux-user: Adjust child_tidptr on set_tid_address() syscall Helge Deller
2022-06-21 18:26 ` Laurent Vivier
@ 2022-06-21 18:33 ` Laurent Vivier
1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2022-06-21 18:33 UTC (permalink / raw)
To: Helge Deller, qemu-devel; +Cc: Richard Henderson
Le 28/05/2022 à 12:52, Helge Deller a écrit :
> Keep track of the new child tidptr given by a set_tid_address() syscall.
>
> Do not call the host set_tid_address() syscall because we are emulating
> the behaviour of writing to child_tidptr in the exit() path.
>
> Signed-off-by: Helge Deller<deller@gmx.de>
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>
> --
> v3:
> - Respin of the patch because the v2 version was mungled in-between the
> mail of the v1 version. Now it's possible to get correct patch with b4
> - Rephrased commit message
> - Added Richard's Reviewed-by
> v2:
> - was mungled in v1 mail thread
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index f55cdebee5..1166e9f014 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -320,9 +320,6 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
> #ifdef __NR_exit_group
> _syscall1(int,exit_group,int,error_code)
> #endif
> -#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
> -_syscall1(int,set_tid_address,int *,tidptr)
> -#endif
> #if defined(__NR_futex)
> _syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
> const struct timespec *,timeout,int *,uaddr2,int,val3)
> @@ -12200,9 +12197,14 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
> }
> #endif
>
> -#if defined(TARGET_NR_set_tid_address) && defined(__NR_set_tid_address)
> +#if defined(TARGET_NR_set_tid_address)
> case TARGET_NR_set_tid_address:
> - return get_errno(set_tid_address((int *)g2h(cpu, arg1)));
> + {
> + TaskState *ts = cpu->opaque;
> + ts->child_tidptr = arg1;
> + /* do not call host set_tid_address() syscall, instead return tid() */
> + return get_errno(sys_gettid());
> + }
> #endif
>
> case TARGET_NR_tkill:
>
Applied to my linux-user-for-7.1 branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-21 18:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-28 10:52 [PATCH v3] linux-user: Adjust child_tidptr on set_tid_address() syscall Helge Deller
2022-06-21 18:26 ` Laurent Vivier
2022-06-21 18:33 ` 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).