linux-user: Adjust child_tidptr on set_tid_address() syscall
PATCH v3 1/1 linux-user: Adjust child_tidptr on set_tid_address() syscall
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.
--
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
linux-user/syscall.c +7 -5
@@ -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:
Le 28/05/2022 à 12:52, Helge Deller a écrit :
Quoted 39 lines
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 tochild_tidptrin theexit()path.Signed-off-by Helge Deller<[email protected]>Reviewed-by Richard Henderson <[email protected]>--
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 threadlinux-user/syscall.c +1
-4@@ -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:
linux-user/syscall.c static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, · line 12210
Quoted 10 lines
linux-user/syscall.c +6
-1-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:
Laurent Vivier
AppliedLe 28/05/2022 à 12:52, Helge Deller a écrit :
Quoted 39 lines
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 tochild_tidptrin theexit()path.Signed-off-by Helge Deller<[email protected]>Reviewed-by Richard Henderson <[email protected]>--
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 threadlinux-user/syscall.c +1
-4@@ -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:
linux-user/syscall.c static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1, · line 12210
Quoted 10 lines
linux-user/syscall.c +6
-1-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