qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] linux-user/syscall.c: add translation logic for epoll_pwait2 syscall
@ 2025-04-23  7:06 Zixing Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Zixing Liu @ 2025-04-23  7:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: Zixing Liu

Signed-off-by: Zixing Liu <liushuyu@aosc.io>
---
 linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++----
 1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8bfe491..6906e7b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -711,6 +711,11 @@ safe_syscall5(int, ppoll, struct pollfd *, ufds, unsigned int, nfds,
 safe_syscall6(int, epoll_pwait, int, epfd, struct epoll_event *, events,
               int, maxevents, int, timeout, const sigset_t *, sigmask,
               size_t, sigsetsize)
+#if defined(__NR_epoll_pwait2)
+safe_syscall6(int, epoll_pwait2, int, epfd, struct epoll_event *, events,
+              int, maxevents, struct timespec *, timeout, const sigset_t *, sigmask,
+              size_t, sigsetsize)
+#endif
 #if defined(__NR_futex)
 safe_syscall6(int,futex,int *,uaddr,int,op,int,val, \
               const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -13363,19 +13368,22 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     }
 #endif
 
-#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait)
+#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait) || defined(TARGET_NR_epoll_pwait2)
 #if defined(TARGET_NR_epoll_wait)
     case TARGET_NR_epoll_wait:
 #endif
 #if defined(TARGET_NR_epoll_pwait)
     case TARGET_NR_epoll_pwait:
+#endif
+#if defined(TARGET_NR_epoll_pwait2)
+    case TARGET_NR_epoll_pwait2:
 #endif
     {
         struct target_epoll_event *target_ep;
         struct epoll_event *ep;
         int epfd = arg1;
         int maxevents = arg3;
-        int timeout = arg4;
+        abi_long timeout = arg4;
 
         if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) {
             return -TARGET_EINVAL;
@@ -13396,6 +13404,9 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         switch (num) {
 #if defined(TARGET_NR_epoll_pwait)
         case TARGET_NR_epoll_pwait:
+#if defined(TARGET_NR_epoll_pwait2)
+        case TARGET_NR_epoll_pwait2:
+#endif
         {
             sigset_t *set = NULL;
 
@@ -13406,8 +13417,25 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
                 }
             }
 
-            ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, timeout,
-                                             set, SIGSET_T_SIZE));
+            if (num == TARGET_NR_epoll_pwait) {
+                ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, (int)timeout,
+                                                 set, SIGSET_T_SIZE));
+            } else {
+#if defined(TARGET_NR_epoll_pwait2)
+                struct timespec hspec;
+                struct timespec *ts_arg = NULL;
+                if (timeout) {
+                    if (target_to_host_timespec(&hspec, (abi_ulong)timeout)) {
+                        return -TARGET_EFAULT;
+                    }
+                    ts_arg = &hspec;
+                }
+                ret = get_errno(safe_epoll_pwait2(epfd, ep, maxevents, ts_arg,
+                                              set, SIGSET_T_SIZE));
+#else
+                return -TARGET_ENOSYS;
+#endif
+            }
 
             if (set) {
                 finish_sigsuspend_mask(ret);
-- 
2.49.0



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

* [PATCH] linux-user/syscall.c: add translation logic for epoll_pwait2 syscall
@ 2025-04-23  7:22 liushuyu
  0 siblings, 0 replies; 2+ messages in thread
From: liushuyu @ 2025-04-23  7:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: liushuyu011

Signed-off-by: Zixing Liu <liushuyu@aosc.io>
---
  linux-user/syscall.c | 36 ++++++++++++++++++++++++++++++++----
  1 file changed, 32 insertions(+), 4 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8bfe491..6906e7b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -711,6 +711,11 @@ safe_syscall5(int, ppoll, struct pollfd *, ufds, 
unsigned int, nfds,
  safe_syscall6(int, epoll_pwait, int, epfd, struct epoll_event *, 
events,
                int, maxevents, int, timeout, const sigset_t *, sigmask,
                size_t, sigsetsize)
+#if defined(__NR_epoll_pwait2)
+safe_syscall6(int, epoll_pwait2, int, epfd, struct epoll_event *, 
events,
+              int, maxevents, struct timespec *, timeout, const 
sigset_t *, sigmask,
+              size_t, sigsetsize)
+#endif
  #if defined(__NR_futex)
  safe_syscall6(int,futex,int *,uaddr,int,op,int,val, \
                const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -13363,19 +13368,22 @@ static abi_long do_syscall1(CPUArchState 
*cpu_env, int num, abi_long arg1,
      }
  #endif

-#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait)
+#if defined(TARGET_NR_epoll_wait) || defined(TARGET_NR_epoll_pwait) || 
defined(TARGET_NR_epoll_pwait2)
  #if defined(TARGET_NR_epoll_wait)
      case TARGET_NR_epoll_wait:
  #endif
  #if defined(TARGET_NR_epoll_pwait)
      case TARGET_NR_epoll_pwait:
+#endif
+#if defined(TARGET_NR_epoll_pwait2)
+    case TARGET_NR_epoll_pwait2:
  #endif
      {
          struct target_epoll_event *target_ep;
          struct epoll_event *ep;
          int epfd = arg1;
          int maxevents = arg3;
-        int timeout = arg4;
+        abi_long timeout = arg4;

          if (maxevents <= 0 || maxevents > TARGET_EP_MAX_EVENTS) {
              return -TARGET_EINVAL;
@@ -13396,6 +13404,9 @@ static abi_long do_syscall1(CPUArchState 
*cpu_env, int num, abi_long arg1,
          switch (num) {
  #if defined(TARGET_NR_epoll_pwait)
          case TARGET_NR_epoll_pwait:
+#if defined(TARGET_NR_epoll_pwait2)
+        case TARGET_NR_epoll_pwait2:
+#endif
          {
              sigset_t *set = NULL;

@@ -13406,8 +13417,25 @@ static abi_long do_syscall1(CPUArchState 
*cpu_env, int num, abi_long arg1,
                  }
              }

-            ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, 
timeout,
-                                             set, SIGSET_T_SIZE));
+            if (num == TARGET_NR_epoll_pwait) {
+                ret = get_errno(safe_epoll_pwait(epfd, ep, maxevents, 
(int)timeout,
+                                                 set, SIGSET_T_SIZE));
+            } else {
+#if defined(TARGET_NR_epoll_pwait2)
+                struct timespec hspec;
+                struct timespec *ts_arg = NULL;
+                if (timeout) {
+                    if (target_to_host_timespec(&hspec, 
(abi_ulong)timeout)) {
+                        return -TARGET_EFAULT;
+                    }
+                    ts_arg = &hspec;
+                }
+                ret = get_errno(safe_epoll_pwait2(epfd, ep, maxevents, 
ts_arg,
+                                              set, SIGSET_T_SIZE));
+#else
+                return -TARGET_ENOSYS;
+#endif
+            }

              if (set) {
                  finish_sigsuspend_mask(ret);
-- 
2.49.0



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

end of thread, other threads:[~2025-04-23 13:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23  7:06 [PATCH] linux-user/syscall.c: add translation logic for epoll_pwait2 syscall Zixing Liu
  -- strict thread matches above, loose matches on Subject: below --
2025-04-23  7:22 liushuyu

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).