qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] linux-user: Add close_range() syscall
@ 2022-09-27  9:35 Helge Deller
  2022-09-27  9:35 ` [PATCH 2/2] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
  2022-09-27 10:40 ` [PATCH 1/2] linux-user: Add close_range() syscall Laurent Vivier
  0 siblings, 2 replies; 5+ messages in thread
From: Helge Deller @ 2022-09-27  9:35 UTC (permalink / raw)
  To: Laurent Vivier, qemu-devel

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.list |  3 +++
 linux-user/syscall.c   | 19 +++++++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index 2fa74b7203..31a2ccd76d 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -103,6 +103,9 @@
 #ifdef TARGET_NR_close
 { TARGET_NR_close, "close" , "%s(%d)", NULL, NULL },
 #endif
+#ifdef TARGET_NR_close_range
+{ TARGET_NR_close_range, "close_range" , "%s(%u,%u,%u)", NULL, NULL },
+#endif
 #ifdef TARGET_NR_connect
 { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6219ef36c9..8e0bdd7a30 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -339,6 +339,13 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
 #ifdef __NR_exit_group
 _syscall1(int,exit_group,int,error_code)
 #endif
+#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
+#define __NR_sys_close_range __NR_close_range
+_syscall3(int,sys_close_range,int,first,int,last,int,flags)
+#ifndef CLOSE_RANGE_CLOEXEC
+#define CLOSE_RANGE_CLOEXEC     (1U << 2)
+#endif
+#endif
 #if defined(__NR_futex)
 _syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
           const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -8756,6 +8763,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_close:
         fd_trans_unregister(arg1);
         return get_errno(close(arg1));
+#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
+    case TARGET_NR_close_range:
+        if (!(arg3 & CLOSE_RANGE_CLOEXEC)) {
+            abi_long fd;
+            abi_long maxfd = (arg2 == (abi_long)-1) ? target_fd_max : arg2;
+
+            for (fd = arg1; fd <= maxfd; fd++) {
+                fd_trans_unregister(fd);
+            }
+        }
+        return get_errno(sys_close_range(arg1, arg2, arg3));
+#endif

     case TARGET_NR_brk:
         return do_brk(arg1);
--
2.37.3



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] linux-user: Add parameters of getrandom() syscall for strace
  2022-09-27  9:35 [PATCH 1/2] linux-user: Add close_range() syscall Helge Deller
@ 2022-09-27  9:35 ` Helge Deller
  2022-09-27 10:41   ` Laurent Vivier
  2022-09-27 11:00   ` Laurent Vivier
  2022-09-27 10:40 ` [PATCH 1/2] linux-user: Add close_range() syscall Laurent Vivier
  1 sibling, 2 replies; 5+ messages in thread
From: Helge Deller @ 2022-09-27  9:35 UTC (permalink / raw)
  To: Laurent Vivier, qemu-devel

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.list | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index 31a2ccd76d..9bb234a584 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -358,7 +358,7 @@
 { TARGET_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_getrandom
-{ TARGET_NR_getrandom, "getrandom", NULL, NULL, NULL },
+{ TARGET_NR_getrandom, "getrandom", "%s(%p,%u,%u)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_getresgid
 { TARGET_NR_getresgid, "getresgid" , NULL, NULL, NULL },
--
2.37.3



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] linux-user: Add close_range() syscall
  2022-09-27  9:35 [PATCH 1/2] linux-user: Add close_range() syscall Helge Deller
  2022-09-27  9:35 ` [PATCH 2/2] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
@ 2022-09-27 10:40 ` Laurent Vivier
  1 sibling, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2022-09-27 10:40 UTC (permalink / raw)
  To: Helge Deller, qemu-devel

Le 27/09/2022 à 11:35, Helge Deller a écrit :
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.list |  3 +++
>   linux-user/syscall.c   | 19 +++++++++++++++++++
>   2 files changed, 22 insertions(+)
> 
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 2fa74b7203..31a2ccd76d 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -103,6 +103,9 @@
>   #ifdef TARGET_NR_close
>   { TARGET_NR_close, "close" , "%s(%d)", NULL, NULL },
>   #endif
> +#ifdef TARGET_NR_close_range
> +{ TARGET_NR_close_range, "close_range" , "%s(%u,%u,%u)", NULL, NULL },
> +#endif
>   #ifdef TARGET_NR_connect
>   { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
>   #endif
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 6219ef36c9..8e0bdd7a30 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -339,6 +339,13 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
>   #ifdef __NR_exit_group
>   _syscall1(int,exit_group,int,error_code)
>   #endif
> +#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
> +#define __NR_sys_close_range __NR_close_range
> +_syscall3(int,sys_close_range,int,first,int,last,int,flags)
> +#ifndef CLOSE_RANGE_CLOEXEC
> +#define CLOSE_RANGE_CLOEXEC     (1U << 2)
> +#endif
> +#endif
>   #if defined(__NR_futex)
>   _syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
>             const struct timespec *,timeout,int *,uaddr2,int,val3)
> @@ -8756,6 +8763,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
>       case TARGET_NR_close:
>           fd_trans_unregister(arg1);
>           return get_errno(close(arg1));
> +#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
> +    case TARGET_NR_close_range:
> +        if (!(arg3 & CLOSE_RANGE_CLOEXEC)) {
> +            abi_long fd;
> +            abi_long maxfd = (arg2 == (abi_long)-1) ? target_fd_max : arg2;
> +
> +            for (fd = arg1; fd <= maxfd; fd++) {
> +                fd_trans_unregister(fd);
> +            }
> +        }
> +        return get_errno(sys_close_range(arg1, arg2, arg3));

fd_trans_unregister() must called only if close_range() doesn't fail.

Thanks,
Laurent

> +#endif
> 
>       case TARGET_NR_brk:
>           return do_brk(arg1);
> --
> 2.37.3
> 
> 



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] linux-user: Add parameters of getrandom() syscall for strace
  2022-09-27  9:35 ` [PATCH 2/2] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
@ 2022-09-27 10:41   ` Laurent Vivier
  2022-09-27 11:00   ` Laurent Vivier
  1 sibling, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2022-09-27 10:41 UTC (permalink / raw)
  To: Helge Deller, qemu-devel

Le 27/09/2022 à 11:35, Helge Deller a écrit :
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.list | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 31a2ccd76d..9bb234a584 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -358,7 +358,7 @@
>   { TARGET_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
>   #endif
>   #ifdef TARGET_NR_getrandom
> -{ TARGET_NR_getrandom, "getrandom", NULL, NULL, NULL },
> +{ TARGET_NR_getrandom, "getrandom", "%s(%p,%u,%u)", NULL, NULL },
>   #endif
>   #ifdef TARGET_NR_getresgid
>   { TARGET_NR_getresgid, "getresgid" , NULL, NULL, NULL },
> --
> 2.37.3
> 
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] linux-user: Add parameters of getrandom() syscall for strace
  2022-09-27  9:35 ` [PATCH 2/2] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
  2022-09-27 10:41   ` Laurent Vivier
@ 2022-09-27 11:00   ` Laurent Vivier
  1 sibling, 0 replies; 5+ messages in thread
From: Laurent Vivier @ 2022-09-27 11:00 UTC (permalink / raw)
  To: Helge Deller, qemu-devel

Le 27/09/2022 à 11:35, Helge Deller a écrit :
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.list | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 31a2ccd76d..9bb234a584 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -358,7 +358,7 @@
>   { TARGET_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
>   #endif
>   #ifdef TARGET_NR_getrandom
> -{ TARGET_NR_getrandom, "getrandom", NULL, NULL, NULL },
> +{ TARGET_NR_getrandom, "getrandom", "%s(%p,%u,%u)", NULL, NULL },
>   #endif
>   #ifdef TARGET_NR_getresgid
>   { TARGET_NR_getresgid, "getresgid" , NULL, NULL, NULL },
> --
> 2.37.3
> 
> 

Applied to my linux-user-for-7.2 branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-27 12:31 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-27  9:35 [PATCH 1/2] linux-user: Add close_range() syscall Helge Deller
2022-09-27  9:35 ` [PATCH 2/2] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
2022-09-27 10:41   ` Laurent Vivier
2022-09-27 11:00   ` Laurent Vivier
2022-09-27 10:40 ` [PATCH 1/2] linux-user: Add close_range() syscall 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).